Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/test/mcp/src/automationTools/task.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
* Task Tools
12
*/
13
export function applyTaskTools(server: McpServer, appService: ApplicationService): RegisteredTool[] {
14
const tools: RegisteredTool[] = [];
15
16
// Seems too niche
17
// server.tool(
18
// 'vscode_automation_task_assert_tasks',
19
// 'Assert that specific tasks exist with given properties',
20
// {
21
// filter: z.string().describe('Filter string for tasks'),
22
// expected: z.array(z.object({
23
// label: z.string().optional(),
24
// type: z.string().optional(),
25
// command: z.string().optional(),
26
// identifier: z.string().optional(),
27
// group: z.string().optional(),
28
// isBackground: z.boolean().optional(),
29
// promptOnClose: z.boolean().optional(),
30
// icon: z.object({
31
// id: z.string().optional(),
32
// color: z.string().optional()
33
// }).optional(),
34
// hide: z.boolean().optional()
35
// })).describe('Array of expected task properties'),
36
// type: z.enum(['run', 'configure']).describe('Type of task operation')
37
// },
38
// async (args) => {
39
// const { filter, expected, type } = args;
40
// await app.workbench.task.assertTasks(filter, expected, type);
41
// return {
42
// content: [{
43
// type: 'text' as const,
44
// text: `Asserted ${expected.length} tasks for ${type} with filter: "${filter}"`
45
// }]
46
// };
47
// }
48
// );
49
50
tools.push(server.tool(
51
'vscode_automation_task_configure',
52
'Configure a task with specific properties',
53
{
54
properties: z.object({
55
label: z.string().optional(),
56
type: z.string().optional(),
57
command: z.string().optional(),
58
identifier: z.string().optional(),
59
group: z.string().optional(),
60
isBackground: z.boolean().optional(),
61
promptOnClose: z.boolean().optional(),
62
icon: z.object({
63
id: z.string().optional(),
64
color: z.string().optional()
65
}).optional(),
66
hide: z.boolean().optional()
67
}).describe('Task configuration properties')
68
},
69
async (args) => {
70
const { properties } = args;
71
const app = await appService.getOrCreateApplication();
72
await app.workbench.task.configureTask(properties);
73
return {
74
content: [{
75
type: 'text' as const,
76
text: `Configured task: ${properties.label || properties.identifier || 'unnamed task'}`
77
}]
78
};
79
}
80
));
81
82
return tools;
83
}
84
85