Path: blob/main/test/mcp/src/automationTools/quickAccess.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* Command Palette and Quick Access Tools11*/12export function applyQuickAccessTools(server: McpServer, appService: ApplicationService): RegisteredTool[] {13const tools: RegisteredTool[] = [];1415tools.push(server.tool(16'vscode_automation_command_run',17'Run a command by name through the command palette',18{19command: z.string().describe('The command name to run'),20exactMatch: z.boolean().optional().describe('Whether to require exact label match')21},22async (args) => {23const { command, exactMatch } = args;24const app = await appService.getOrCreateApplication();25await app.workbench.quickaccess.runCommand(command, { exactLabelMatch: exactMatch, keepOpen: true });26return {27content: [{28type: 'text' as const,29text: `Executed command: "${command}"`30}]31};32}33));3435tools.push(server.tool(36'vscode_automation_quick_open_file',37'Open quick file search and select a file',38{39fileName: z.string().describe('Name or pattern of file to search for'),40exactFileName: z.string().optional().describe('Exact file name to select from results')41},42async (args) => {43const { fileName, exactFileName } = args;44const app = await appService.getOrCreateApplication();45await app.workbench.quickaccess.openFileQuickAccessAndWait(fileName, exactFileName || fileName);46return {47content: [{48type: 'text' as const,49text: `Opened file through quick open: "${fileName}"`50}]51};52}53));5455// Playwright can probably figure this one out56// server.tool(57// 'vscode_automation_quick_input_type',58// 'Type text into the currently open quick input',59// {60// text: z.string().describe('Text to type into quick input')61// },62// async (args) => {63// const { text } = args;64// await app.workbench.quickinput.type(text);65// return {66// content: [{67// type: 'text' as const,68// text: `Typed in quick input: "${text}"`69// }]70// };71// }72// );7374// Playwright can probably figure this one out75// server.tool(76// 'vscode_automation_quick_input_select_item',77// 'Select an item from the quick input list',78// {79// index: z.number().optional().describe('Index of item to select (0-based)'),80// keepOpen: z.boolean().optional().describe('Keep quick input open after selection')81// },82// async (args) => {83// const { index = 0, keepOpen } = args;84// await app.workbench.quickinput.selectQuickInputElement(index, keepOpen);85// return {86// content: [{87// type: 'text' as const,88// text: `Selected quick input item at index ${index}`89// }]90// };91// }92// );9394return tools;95}969798