Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/test/mcp/src/automationTools/chat.ts
4774 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
* Chat Tools
12
*/
13
export function applyChatTools(server: McpServer, appService: ApplicationService): RegisteredTool[] {
14
const tools: RegisteredTool[] = [];
15
16
tools.push(server.tool(
17
'vscode_automation_chat_send_message',
18
'Send a message to the VS Code chat panel',
19
{
20
message: z.string().describe('The message to send to the chat')
21
},
22
async (args) => {
23
const { message } = args;
24
const app = await appService.getOrCreateApplication();
25
try {
26
await app.workbench.chat.sendMessage(message);
27
return {
28
content: [{
29
type: 'text' as const,
30
text: `Sent chat message: "${message}"`
31
}]
32
};
33
} catch (error) {
34
return {
35
content: [{
36
type: 'text' as const,
37
text: `Failed to send chat message: ${error}`
38
}]
39
};
40
}
41
}
42
));
43
44
return tools;
45
}
46
47