Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/test/mcp/src/automationTools/search.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
* Search Tools
12
*/
13
export function applySearchTools(server: McpServer, appService: ApplicationService): RegisteredTool[] {
14
const tools: RegisteredTool[] = [];
15
16
// Playwright can probably figure this one out
17
// server.tool(
18
// 'vscode_automation_search_open',
19
// 'Open the search viewlet',
20
// async () => {
21
// await app.workbench.search.openSearchViewlet();
22
// return {
23
// content: [{
24
// type: 'text' as const,
25
// text: 'Opened search viewlet'
26
// }]
27
// };
28
// }
29
// );
30
31
tools.push(server.tool(
32
'vscode_automation_search_for_text',
33
'Search for text in files',
34
{
35
searchText: z.string().describe('Text to search for')
36
},
37
async (args) => {
38
const { searchText } = args;
39
const app = await appService.getOrCreateApplication();
40
await app.workbench.search.openSearchViewlet();
41
await app.workbench.search.searchFor(searchText);
42
return {
43
content: [{
44
type: 'text' as const,
45
text: `Searched for: "${searchText}"`
46
}]
47
};
48
}
49
));
50
51
// Seems too niche
52
// server.tool(
53
// 'vscode_automation_search_set_files_to_include',
54
// 'Set files to include in search',
55
// {
56
// pattern: z.string().describe('File pattern to include (e.g., "*.ts", "src/**")')
57
// },
58
// async (args) => {
59
// const { pattern } = args;
60
// await app.workbench.search.setFilesToIncludeText(pattern);
61
// return {
62
// content: [{
63
// type: 'text' as const,
64
// text: `Set files to include: "${pattern}"`
65
// }]
66
// };
67
// }
68
// );
69
70
// Playwright can probably figure this one out
71
// server.tool(
72
// 'vscode_automation_search_submit',
73
// 'Submit the current search',
74
// async () => {
75
// await app.workbench.search.submitSearch();
76
// return {
77
// content: [{
78
// type: 'text' as const,
79
// text: 'Submitted search'
80
// }]
81
// };
82
// }
83
// );
84
85
// Playwright can probably figure this one out
86
// server.tool(
87
// 'vscode_automation_search_clear_results',
88
// 'Clear search results',
89
// async () => {
90
// await app.workbench.search.clearSearchResults();
91
// return {
92
// content: [{
93
// type: 'text' as const,
94
// text: 'Cleared search results'
95
// }]
96
// };
97
// }
98
// );
99
100
return tools;
101
}
102
103