Path: blob/main/test/mcp/src/automationTools/search.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* Search Tools11*/12export function applySearchTools(server: McpServer, appService: ApplicationService): RegisteredTool[] {13const tools: RegisteredTool[] = [];1415// Playwright can probably figure this one out16// server.tool(17// 'vscode_automation_search_open',18// 'Open the search viewlet',19// async () => {20// await app.workbench.search.openSearchViewlet();21// return {22// content: [{23// type: 'text' as const,24// text: 'Opened search viewlet'25// }]26// };27// }28// );2930tools.push(server.tool(31'vscode_automation_search_for_text',32'Search for text in files',33{34searchText: z.string().describe('Text to search for')35},36async (args) => {37const { searchText } = args;38const app = await appService.getOrCreateApplication();39await app.workbench.search.openSearchViewlet();40await app.workbench.search.searchFor(searchText);41return {42content: [{43type: 'text' as const,44text: `Searched for: "${searchText}"`45}]46};47}48));4950// Seems too niche51// server.tool(52// 'vscode_automation_search_set_files_to_include',53// 'Set files to include in search',54// {55// pattern: z.string().describe('File pattern to include (e.g., "*.ts", "src/**")')56// },57// async (args) => {58// const { pattern } = args;59// await app.workbench.search.setFilesToIncludeText(pattern);60// return {61// content: [{62// type: 'text' as const,63// text: `Set files to include: "${pattern}"`64// }]65// };66// }67// );6869// Playwright can probably figure this one out70// server.tool(71// 'vscode_automation_search_submit',72// 'Submit the current search',73// async () => {74// await app.workbench.search.submitSearch();75// return {76// content: [{77// type: 'text' as const,78// text: 'Submitted search'79// }]80// };81// }82// );8384// Playwright can probably figure this one out85// server.tool(86// 'vscode_automation_search_clear_results',87// 'Clear search results',88// async () => {89// await app.workbench.search.clearSearchResults();90// return {91// content: [{92// type: 'text' as const,93// text: 'Cleared search results'94// }]95// };96// }97// );9899return tools;100}101102103