Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/test/mcp/src/automationTools/quickAccess.ts
3520 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
7
import { ApplicationService } from '../application';
8
import { z } from 'zod';
9
10
/**
11
* Command Palette and Quick Access Tools
12
*/
13
export function applyQuickAccessTools(server: McpServer, appService: ApplicationService): RegisteredTool[] {
14
const tools: RegisteredTool[] = [];
15
16
tools.push(server.tool(
17
'vscode_automation_command_run',
18
'Run a command by name through the command palette',
19
{
20
command: z.string().describe('The command name to run'),
21
exactMatch: z.boolean().optional().describe('Whether to require exact label match')
22
},
23
async (args) => {
24
const { command, exactMatch } = args;
25
const app = await appService.getOrCreateApplication();
26
await app.workbench.quickaccess.runCommand(command, { exactLabelMatch: exactMatch, keepOpen: true });
27
return {
28
content: [{
29
type: 'text' as const,
30
text: `Executed command: "${command}"`
31
}]
32
};
33
}
34
));
35
36
tools.push(server.tool(
37
'vscode_automation_quick_open_file',
38
'Open quick file search and select a file',
39
{
40
fileName: z.string().describe('Name or pattern of file to search for'),
41
exactFileName: z.string().optional().describe('Exact file name to select from results')
42
},
43
async (args) => {
44
const { fileName, exactFileName } = args;
45
const app = await appService.getOrCreateApplication();
46
await app.workbench.quickaccess.openFileQuickAccessAndWait(fileName, exactFileName || fileName);
47
return {
48
content: [{
49
type: 'text' as const,
50
text: `Opened file through quick open: "${fileName}"`
51
}]
52
};
53
}
54
));
55
56
// Playwright can probably figure this one out
57
// server.tool(
58
// 'vscode_automation_quick_input_type',
59
// 'Type text into the currently open quick input',
60
// {
61
// text: z.string().describe('Text to type into quick input')
62
// },
63
// async (args) => {
64
// const { text } = args;
65
// await app.workbench.quickinput.type(text);
66
// return {
67
// content: [{
68
// type: 'text' as const,
69
// text: `Typed in quick input: "${text}"`
70
// }]
71
// };
72
// }
73
// );
74
75
// Playwright can probably figure this one out
76
// server.tool(
77
// 'vscode_automation_quick_input_select_item',
78
// 'Select an item from the quick input list',
79
// {
80
// index: z.number().optional().describe('Index of item to select (0-based)'),
81
// keepOpen: z.boolean().optional().describe('Keep quick input open after selection')
82
// },
83
// async (args) => {
84
// const { index = 0, keepOpen } = args;
85
// await app.workbench.quickinput.selectQuickInputElement(index, keepOpen);
86
// return {
87
// content: [{
88
// type: 'text' as const,
89
// text: `Selected quick input item at index ${index}`
90
// }]
91
// };
92
// }
93
// );
94
95
return tools;
96
}
97
98