Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/test/mcp/src/automationTools/scm.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
* Source Control Management Tools
12
*/
13
export function applySCMTools(server: McpServer, appService: ApplicationService): RegisteredTool[] {
14
const tools: RegisteredTool[] = [];
15
16
// Playwright can probably figure this one out
17
// server.tool(
18
// 'vscode_automation_scm_open',
19
// 'Open the Source Control Management viewlet',
20
// async () => {
21
// await app.workbench.scm.openSCMViewlet();
22
// return {
23
// content: [{
24
// type: 'text' as const,
25
// text: 'Opened SCM viewlet'
26
// }]
27
// };
28
// }
29
// );
30
31
// Playwright can probably figure this one out
32
// server.tool(
33
// 'vscode_automation_scm_wait_for_change',
34
// 'Wait for a specific change to appear in SCM',
35
// {
36
// name: z.string().describe('Name of the file change to wait for'),
37
// type: z.string().optional().describe('Type of change (optional)')
38
// },
39
// async (args) => {
40
// const { name, type } = args;
41
// await app.workbench.scm.waitForChange(name, type);
42
// return {
43
// content: [{
44
// type: 'text' as const,
45
// text: `Change detected: ${name}${type ? ` (${type})` : ''}`
46
// }]
47
// };
48
// }
49
// );
50
51
// Playwright can probably figure this one out
52
// server.tool(
53
// 'vscode_automation_scm_refresh',
54
// 'Refresh the SCM viewlet',
55
// async () => {
56
// await app.workbench.scm.refreshSCMViewlet();
57
// return {
58
// content: [{
59
// type: 'text' as const,
60
// text: 'Refreshed SCM viewlet'
61
// }]
62
// };
63
// }
64
// );
65
66
// Playwright can probably figure this one out
67
// server.tool(
68
// 'vscode_automation_scm_open_change',
69
// 'Open a specific change in the SCM viewlet',
70
// {
71
// name: z.string().describe('Name of the file change to open')
72
// },
73
// async (args) => {
74
// const { name } = args;
75
// await app.workbench.scm.openChange(name);
76
// return {
77
// content: [{
78
// type: 'text' as const,
79
// text: `Opened change: ${name}`
80
// }]
81
// };
82
// }
83
// );
84
85
// Playwright can probably figure this one out
86
// server.tool(
87
// 'vscode_automation_scm_stage',
88
// 'Stage a specific file change',
89
// {
90
// name: z.string().describe('Name of the file to stage')
91
// },
92
// async (args) => {
93
// const { name } = args;
94
// await app.workbench.scm.stage(name);
95
// return {
96
// content: [{
97
// type: 'text' as const,
98
// text: `Staged file: ${name}`
99
// }]
100
// };
101
// }
102
// );
103
104
// Playwright can probably figure this one out
105
// server.tool(
106
// 'vscode_automation_scm_unstage',
107
// 'Unstage a specific file change',
108
// {
109
// name: z.string().describe('Name of the file to unstage')
110
// },
111
// async (args) => {
112
// const { name } = args;
113
// await app.workbench.scm.unstage(name);
114
// return {
115
// content: [{
116
// type: 'text' as const,
117
// text: `Unstaged file: ${name}`
118
// }]
119
// };
120
// }
121
// );
122
123
tools.push(server.tool(
124
'vscode_automation_scm_commit',
125
'Commit staged changes with a message',
126
{
127
message: z.string().describe('Commit message')
128
},
129
async (args) => {
130
const { message } = args;
131
const app = await appService.getOrCreateApplication();
132
await app.workbench.scm.commit(message);
133
return {
134
content: [{
135
type: 'text' as const,
136
text: `Committed changes with message: "${message}"`
137
}]
138
};
139
}
140
));
141
142
return tools;
143
}
144
145