Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/test/mcp/src/automationTools/problems.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
* Problems Panel Tools
12
*/
13
export function applyProblemsTools(server: McpServer, appService: ApplicationService): RegisteredTool[] {
14
const tools: RegisteredTool[] = [];
15
16
tools.push(server.tool(
17
'vscode_automation_problems_show',
18
'Show the problems view',
19
async () => {
20
const app = await appService.getOrCreateApplication();
21
await app.workbench.problems.showProblemsView();
22
return {
23
content: [{
24
type: 'text' as const,
25
text: 'Showed problems view'
26
}]
27
};
28
}
29
));
30
31
tools.push(server.tool(
32
'vscode_automation_problems_hide',
33
'Hide the problems view',
34
async () => {
35
const app = await appService.getOrCreateApplication();
36
await app.workbench.problems.hideProblemsView();
37
return {
38
content: [{
39
type: 'text' as const,
40
text: 'Hid problems view'
41
}]
42
};
43
}
44
));
45
46
// Playwright can probably figure this one out
47
// server.tool(
48
// 'vscode_automation_problems_wait_for_view',
49
// 'Wait for the problems view to appear',
50
// async () => {
51
// await app.workbench.problems.waitForProblemsView();
52
// return {
53
// content: [{
54
// type: 'text' as const,
55
// text: 'Problems view is now visible'
56
// }]
57
// };
58
// }
59
// );
60
61
tools.push(server.tool(
62
'vscode_automation_problems_get_selector_in_view',
63
'Get CSS selector for problems of a specific severity in the problems view',
64
{
65
severity: z.enum(['WARNING', 'ERROR']).describe('Problem severity (WARNING or ERROR)')
66
},
67
async (args) => {
68
const { severity } = args;
69
const severityMap: Record<string, number> = {
70
'WARNING': 0,
71
'ERROR': 1
72
};
73
74
// This is a static method that returns a selector, not an async operation
75
const app = await appService.getOrCreateApplication();
76
const selector = (app.workbench.problems.constructor as any).getSelectorInProblemsView(severityMap[severity]);
77
return {
78
content: [{
79
type: 'text' as const,
80
text: `CSS selector for ${severity} problems in view: ${selector}`
81
}]
82
};
83
}
84
));
85
86
// Seems too niche
87
// server.tool(
88
// 'vscode_automation_problems_get_selector_in_editor',
89
// 'Get CSS selector for problems of a specific severity in the editor',
90
// {
91
// severity: z.enum(['WARNING', 'ERROR']).describe('Problem severity (WARNING or ERROR)')
92
// },
93
// async (args) => {
94
// const { severity } = args;
95
// const severityMap: Record<string, number> = {
96
// 'WARNING': 0,
97
// 'ERROR': 1
98
// };
99
100
// // This is a static method that returns a selector, not an async operation
101
// const selector = (app.workbench.problems.constructor as any).getSelectorInEditor(severityMap[severity]);
102
// return {
103
// content: [{
104
// type: 'text' as const,
105
// text: `CSS selector for ${severity} problems in editor: ${selector}`
106
// }]
107
// };
108
// }
109
// );
110
111
return tools;
112
}
113
114