/*---------------------------------------------------------------------------------------------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';78/**9* Core Application Management Tools10*/11export function applyCoreTools(server: McpServer, appService: ApplicationService): RegisteredTool[] {12const tools: RegisteredTool[] = [];1314// Playwright keeps using this as a start... maybe it needs some massaging15// server.tool(16// 'vscode_automation_restart',17// 'Restart VS Code with optional workspace or folder and extra arguments',18// {19// workspaceOrFolder: z.string().optional().describe('Optional path to workspace or folder to open'),20// extraArgs: z.array(z.string()).optional().describe('Optional extra command line arguments')21// },22// async (args) => {23// const { workspaceOrFolder, extraArgs } = args;24// await app.restart({ workspaceOrFolder, extraArgs });25// return {26// content: [{27// type: 'text' as const,28// text: `VS Code restarted successfully${workspaceOrFolder ? ` with workspace: ${workspaceOrFolder}` : ''}`29// }]30// };31// }32// );3334// I don't think Playwright needs this35// server.tool(36// 'vscode_automation_stop',37// 'Stop the VS Code application',38// async () => {39// await app.stop();40// return {41// content: [{42// type: 'text' as const,43// text: 'VS Code stopped successfully'44// }]45// };46// }47// );4849// This doesn't seem particularly useful50// server.tool(51// 'vscode_automation_get_quality',52// 'Get the quality/build type of VS Code (Dev, Insiders, Stable, etc.)',53// async () => {54// const info = {55// quality: app.quality,56// remote: app.remote,57// web: app.web,58// workspacePathOrFolder: app.workspacePathOrFolder,59// extensionsPath: app.extensionsPath,60// userDataPath: app.userDataPath61// };62// return {63// content: [{64// type: 'text' as const,65// text: `VS Code Info:\n${JSON.stringify(info, null, 2)}`66// }]67// };68// }69// );7071// This doesn't seem particularly useful72// server.tool(73// 'vscode_automation_wait_for_element',74// 'Wait for a UI element to appear using CSS selector - prefer using specific workbench methods when available',75// {76// selector: z.string().describe('CSS selector for the element to wait for'),77// timeout: z.number().optional().default(20).describe('Timeout in seconds (default: 20)')78// },79// async (args) => {80// const { selector, timeout = 20 } = args;81// const retryCount = Math.floor((timeout * 1000) / 100); // 100ms intervals82// const element = await app.code.waitForElement(selector, undefined, retryCount);83// return {84// content: [{85// type: 'text' as const,86// text: `Element found: ${selector} (${!!element ? 'success' : 'not found'})`87// }]88// };89// }90// );9192// Defer to Playwright's tool93// server.tool(94// 'vscode_automation_click_element',95// 'Click on a UI element - prefer using specific workbench methods when available',96// {97// selector: z.string().describe('CSS selector for the element to click'),98// xOffset: z.number().optional().describe('Optional X offset from element center'),99// yOffset: z.number().optional().describe('Optional Y offset from element center')100// },101// async (args) => {102// const { selector, xOffset, yOffset } = args;103// await app.code.waitAndClick(selector, xOffset, yOffset);104// return {105// content: [{106// type: 'text' as const,107// text: `Clicked element: ${selector}${xOffset !== undefined ? ` (offset: ${xOffset}, ${yOffset})` : ''}`108// }]109// };110// }111// );112113// Defer to Playwright's tool114// server.tool(115// 'vscode_automation_send_keybinding',116// 'Send a keybinding to VS Code (e.g., ctrl+shift+p, cmd+s)',117// {118// keybinding: z.string().describe('The keybinding to send (e.g., ctrl+shift+p, cmd+s, escape)'),119// waitSelector: z.string().optional().describe('Optional CSS selector to wait for after sending the keybinding')120// },121// async (args) => {122// const { keybinding, waitSelector } = args;123// await app.code.dispatchKeybinding(keybinding, async () => {124// if (waitSelector) {125// await app.code.waitForElement(waitSelector);126// }127// });128// return {129// content: [{130// type: 'text' as const,131// text: `Sent keybinding: ${keybinding}${waitSelector ? ` (waited for: ${waitSelector})` : ''}`132// }]133// };134// }135// );136137// Defer to Playwright's tool138// server.tool(139// 'vscode_automation_get_text_content',140// 'Get text content from a UI element using CSS selector',141// {142// selector: z.string().describe('CSS selector for the element'),143// expectedText: z.string().optional().describe('Optional expected text to wait for')144// },145// async (args) => {146// const { selector, expectedText } = args;147// const text = await app.code.waitForTextContent(selector, expectedText);148// return {149// content: [{150// type: 'text' as const,151// text: `Text content from ${selector}: "${text}"`152// }]153// };154// }155// );156157return tools;158}159160161