Path: blob/main/test/mcp/src/automationTools/extensions.ts
3520 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';6import { ApplicationService } from '../application';7import { z } from 'zod';89/**10* Extensions Tools11*/12export function applyExtensionsTools(server: McpServer, appService: ApplicationService): RegisteredTool[] {13const tools: RegisteredTool[] = [];1415// Playwright can probably figure this out16// server.tool(17// 'vscode_automation_extensions_search',18// 'Search for an extension by ID',19// {20// extensionId: z.string().describe('Extension ID to search for (e.g., "ms-python.python")')21// },22// async (args) => {23// const { extensionId } = args;24// await app.workbench.extensions.searchForExtension(extensionId);25// return {26// content: [{27// type: 'text' as const,28// text: `Searched for extension: ${extensionId}`29// }]30// };31// }32// );3334tools.push(server.tool(35'vscode_automation_extensions_open',36'Open an extension by ID',37{38extensionId: z.string().describe('Extension ID to open (e.g., "ms-python.python")')39},40async (args) => {41const { extensionId } = args;42const app = await appService.getOrCreateApplication();43await app.workbench.extensions.openExtension(extensionId);44return {45content: [{46type: 'text' as const,47text: `Opened extension: ${extensionId}`48}]49};50}51));5253// Playwright can probably figure this out54// server.tool(55// 'vscode_automation_extensions_close',56// 'Close an extension tab by title',57// {58// title: z.string().describe('Extension title to close')59// },60// async (args) => {61// const { title } = args;62// await app.workbench.extensions.closeExtension(title);63// return {64// content: [{65// type: 'text' as const,66// text: `Closed extension: ${title}`67// }]68// };69// }70// );7172tools.push(server.tool(73'vscode_automation_extensions_install',74'Install an extension by ID',75{76extensionId: z.string().describe('Extension ID to install (e.g., "ms-python.python")'),77waitUntilEnabled: z.boolean().optional().default(true).describe('Whether to wait until the extension is enabled')78},79async (args) => {80const { extensionId, waitUntilEnabled = true } = args;81const app = await appService.getOrCreateApplication();82await app.workbench.extensions.installExtension(extensionId, waitUntilEnabled);83return {84content: [{85type: 'text' as const,86text: `Installed extension: ${extensionId}${waitUntilEnabled ? ' (waited until enabled)' : ''}`87}]88};89}90));9192return tools;93}949596