Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/test/mcp/src/automationTools/settings.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
* Settings Editor Tools
12
*/
13
export function applySettingsTools(server: McpServer, appService: ApplicationService): RegisteredTool[] {
14
const tools: RegisteredTool[] = [];
15
16
// I don't think we need this and the batch version
17
// server.tool(
18
// 'vscode_automation_settings_add_user_setting',
19
// 'Add a single user setting key-value pair',
20
// {
21
// setting: z.string().describe('Setting key (e.g., "editor.fontSize")'),
22
// value: z.string().describe('Setting value (as JSON string)')
23
// },
24
// async (args) => {
25
// const { setting, value } = args;
26
// await app.workbench.settingsEditor.addUserSetting(setting, value);
27
// return {
28
// content: [{
29
// type: 'text' as const,
30
// text: `Added user setting: ${setting} = ${value}`
31
// }]
32
// };
33
// }
34
// );
35
36
tools.push(server.tool(
37
'vscode_automation_settings_add_user_settings',
38
'Add multiple user settings at once',
39
{
40
settings: z.array(z.tuple([z.string(), z.string()])).describe('Array of [key, value] setting pairs')
41
},
42
async (args) => {
43
const { settings } = args;
44
const app = await appService.getOrCreateApplication();
45
await app.workbench.settingsEditor.addUserSettings(settings);
46
return {
47
content: [{
48
type: 'text' as const,
49
text: `Added ${settings.length} user settings: ${settings.map(([k, v]) => `${k}=${v}`).join(', ')}`
50
}]
51
};
52
}
53
));
54
55
tools.push(server.tool(
56
'vscode_automation_settings_clear_user_settings',
57
'Clear all user settings',
58
async () => {
59
const app = await appService.getOrCreateApplication();
60
await app.workbench.settingsEditor.clearUserSettings();
61
return {
62
content: [{
63
type: 'text' as const,
64
text: 'Cleared all user settings'
65
}]
66
};
67
}
68
));
69
70
// Playwright can probably figure this one out
71
// server.tool(
72
// 'vscode_automation_settings_open_user_file',
73
// 'Open the user settings JSON file',
74
// async () => {
75
// await app.workbench.settingsEditor.openUserSettingsFile();
76
// return {
77
// content: [{
78
// type: 'text' as const,
79
// text: 'Opened user settings file'
80
// }]
81
// };
82
// }
83
// );
84
85
// Playwright can probably figure this one out
86
// server.tool(
87
// 'vscode_automation_settings_open_user_ui',
88
// 'Open the user settings UI',
89
// async () => {
90
// await app.workbench.settingsEditor.openUserSettingsUI();
91
// return {
92
// content: [{
93
// type: 'text' as const,
94
// text: 'Opened user settings UI'
95
// }]
96
// };
97
// }
98
// );
99
100
// Playwright can probably figure this one out
101
// server.tool(
102
// 'vscode_automation_settings_search_ui',
103
// 'Search for settings in the settings UI',
104
// {
105
// query: z.string().describe('Search query for settings')
106
// },
107
// async (args) => {
108
// const { query } = args;
109
// await app.workbench.settingsEditor.searchSettingsUI(query);
110
// return {
111
// content: [{
112
// type: 'text' as const,
113
// text: `Searched settings UI for: "${query}"`
114
// }]
115
// };
116
// }
117
// );
118
119
return tools;
120
}
121
122