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