Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/test/mcp/src/automation.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 } from '@modelcontextprotocol/sdk/server/mcp.js';
7
import { ApplicationService } from './application';
8
import { applyAllTools } from './automationTools/index.js';
9
import type { Server } from '@modelcontextprotocol/sdk/server/index.js';
10
11
export async function getServer(appService: ApplicationService): Promise<Server> {
12
const server = new McpServer({
13
name: 'VS Code Automation Server',
14
version: '1.0.0',
15
title: 'An MCP Server that can interact with a local build of VS Code. Used for verifying UI behavior.'
16
}, { capabilities: { logging: {} } });
17
18
server.tool(
19
'vscode_automation_start',
20
'Start VS Code Build',
21
{},
22
async () => {
23
const app = await appService.getOrCreateApplication();
24
return {
25
content: [{
26
type: 'text' as const,
27
text: app ? `VS Code started successfully` : `Failed to start VS Code`
28
}]
29
};
30
}
31
);
32
33
// Apply all VS Code automation tools using the modular structure
34
const registeredTools = applyAllTools(server, appService);
35
const app = appService.application;
36
if (app) {
37
registeredTools.forEach(t => t.enable());
38
} else {
39
registeredTools.forEach(t => t.disable());
40
}
41
42
appService.onApplicationChange(app => {
43
if (app) {
44
registeredTools.forEach(t => t.enable());
45
} else {
46
registeredTools.forEach(t => t.disable());
47
}
48
});
49
50
return server.server;
51
}
52
53