mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-03 15:01:57 +01:00
Add another server built on top of our own automation framework (#262984)
* Add another server built on top of our own automation framework It's a big PR but a lot of this is boiler plate. It's just essentially wrapping our Automation framework in a bunch of tools. * Lay the foundation for multiplexing
This commit is contained in:
committed by
GitHub
parent
7db6be89a1
commit
a7cdeedd57
77
test/mcp/src/automationTools/task.ts
Normal file
77
test/mcp/src/automationTools/task.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
||||
import { Application } from '../../../automation';
|
||||
import { z } from 'zod';
|
||||
|
||||
/**
|
||||
* Task Tools
|
||||
*/
|
||||
export function applyTaskTools(server: McpServer, app: Application) {
|
||||
server.tool(
|
||||
'vscode_automation_task_assert_tasks',
|
||||
'Assert that specific tasks exist with given properties',
|
||||
{
|
||||
filter: z.string().describe('Filter string for tasks'),
|
||||
expected: z.array(z.object({
|
||||
label: z.string().optional(),
|
||||
type: z.string().optional(),
|
||||
command: z.string().optional(),
|
||||
identifier: z.string().optional(),
|
||||
group: z.string().optional(),
|
||||
isBackground: z.boolean().optional(),
|
||||
promptOnClose: z.boolean().optional(),
|
||||
icon: z.object({
|
||||
id: z.string().optional(),
|
||||
color: z.string().optional()
|
||||
}).optional(),
|
||||
hide: z.boolean().optional()
|
||||
})).describe('Array of expected task properties'),
|
||||
type: z.enum(['run', 'configure']).describe('Type of task operation')
|
||||
},
|
||||
async (args) => {
|
||||
const { filter, expected, type } = args;
|
||||
await app.workbench.task.assertTasks(filter, expected, type);
|
||||
return {
|
||||
content: [{
|
||||
type: 'text' as const,
|
||||
text: `Asserted ${expected.length} tasks for ${type} with filter: "${filter}"`
|
||||
}]
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
server.tool(
|
||||
'vscode_automation_task_configure',
|
||||
'Configure a task with specific properties',
|
||||
{
|
||||
properties: z.object({
|
||||
label: z.string().optional(),
|
||||
type: z.string().optional(),
|
||||
command: z.string().optional(),
|
||||
identifier: z.string().optional(),
|
||||
group: z.string().optional(),
|
||||
isBackground: z.boolean().optional(),
|
||||
promptOnClose: z.boolean().optional(),
|
||||
icon: z.object({
|
||||
id: z.string().optional(),
|
||||
color: z.string().optional()
|
||||
}).optional(),
|
||||
hide: z.boolean().optional()
|
||||
}).describe('Task configuration properties')
|
||||
},
|
||||
async (args) => {
|
||||
const { properties } = args;
|
||||
await app.workbench.task.configureTask(properties);
|
||||
return {
|
||||
content: [{
|
||||
type: 'text' as const,
|
||||
text: `Configured task: ${properties.label || properties.identifier || 'unnamed task'}`
|
||||
}]
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user