Add a send message tool for automation & mcp (#273306)

* Add a send message tool for automation & mcp

This also sents up the posibility of smoke tests.

* Add demonstrate.md and remove prompt

* add simple notification util

* notif
This commit is contained in:
Tyler James Leonhardt
2025-10-25 23:35:03 -07:00
committed by GitHub
parent 0279a827fa
commit c40db410b9
8 changed files with 243 additions and 16 deletions

View File

@@ -0,0 +1,45 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
import { ApplicationService } from '../application';
import { z } from 'zod';
/**
* Chat Tools
*/
export function applyChatTools(server: McpServer, appService: ApplicationService): RegisteredTool[] {
const tools: RegisteredTool[] = [];
tools.push(server.tool(
'vscode_automation_chat_send_message',
'Send a message to the VS Code chat panel',
{
message: z.string().describe('The message to send to the chat')
},
async (args) => {
const { message } = args;
const app = await appService.getOrCreateApplication();
try {
await app.workbench.chat.sendMessage(message);
return {
content: [{
type: 'text' as const,
text: `Sent chat message: "${message}"`
}]
};
} catch (error) {
return {
content: [{
type: 'text' as const,
text: `Failed to send chat message: ${error}`
}]
};
}
}
));
return tools;
}

View File

@@ -24,6 +24,7 @@ import { applyNotebookTools } from './notebook.js';
import { applyLocalizationTools } from './localization.js';
import { applyTaskTools } from './task.js';
import { applyProfilerTools } from './profiler.js';
import { applyChatTools } from './chat.js';
import { ApplicationService } from '../application';
/**
@@ -89,6 +90,9 @@ export function applyAllTools(server: McpServer, appService: ApplicationService)
// Profiler Tools
tools = tools.concat(applyProfilerTools(server, appService));
// Chat Tools
tools = tools.concat(applyChatTools(server, appService));
// Return all registered tools
return tools;
}
@@ -112,5 +116,6 @@ export {
applyNotebookTools,
applyLocalizationTools,
applyTaskTools,
applyProfilerTools
applyProfilerTools,
applyChatTools
};