@codingame/monaco-vscode-mcp-service-override 28.4.1 → 29.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/vscode/src/vs/base/common/jsonRpcProtocol.d.ts +13 -1
- package/vscode/src/vs/base/common/jsonRpcProtocol.js +26 -13
- package/vscode/src/vs/platform/mcp/common/allowedMcpServersService.js +1 -1
- package/vscode/src/vs/platform/mcp/common/mcpGalleryManifestService.js +2 -1
- package/vscode/src/vs/platform/mcp/common/mcpGalleryService.js +8 -5
- package/vscode/src/vs/platform/mcp/common/mcpGateway.d.ts +49 -18
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcp.contribution.js +3 -3
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpAddContextContribution.js +2 -2
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpCommands.js +81 -67
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpElicitationService.d.ts +11 -0
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpElicitationService.js +267 -50
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpGatewayService.js +17 -3
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpLanguageFeatures.js +24 -21
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpMigration.js +4 -4
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpResourceQuickAccess.js +8 -8
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpServersView.js +18 -18
- package/vscode/src/vs/workbench/contrib/mcp/browser/mcpWorkbenchService.js +37 -9
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/extensionMcpDiscovery.js +4 -4
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/nativeMcpDiscoveryAbstract.js +1 -1
- package/vscode/src/vs/workbench/contrib/mcp/common/discovery/pluginMcpDiscovery.js +11 -3
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpContextKeys.js +4 -4
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpGatewayToolBrokerChannel.d.ts +8 -9
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpGatewayToolBrokerChannel.js +147 -132
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpLanguageModelToolContribution.js +10 -6
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpRegistry.js +14 -14
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpSamplingLog.js +1 -1
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpSamplingService.js +11 -11
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpSandboxService.d.ts +2 -0
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpSandboxService.js +15 -8
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpServerConnection.js +7 -22
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpService.d.ts +4 -1
- package/vscode/src/vs/workbench/contrib/mcp/common/mcpService.js +16 -4
- package/vscode/src/vs/workbench/services/authentication/browser/authenticationMcpService.js +9 -9
- package/vscode/src/vs/workbench/services/mcp/browser/mcpGalleryManifestService.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-mcp-service-override",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "29.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "VSCode public API plugged on the monaco editor - mcp service-override",
|
|
6
6
|
"keywords": [],
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@codingame/monaco-vscode-api": "
|
|
18
|
+
"@codingame/monaco-vscode-api": "29.0.0"
|
|
19
19
|
},
|
|
20
20
|
"main": "index.js",
|
|
21
21
|
"module": "index.js",
|
|
@@ -28,6 +28,7 @@ export interface IJsonRpcErrorResponse {
|
|
|
28
28
|
error: IJsonRpcError;
|
|
29
29
|
}
|
|
30
30
|
export type JsonRpcMessage = IJsonRpcRequest | IJsonRpcNotification | IJsonRpcSuccessResponse | IJsonRpcErrorResponse;
|
|
31
|
+
export type JsonRpcResponse = IJsonRpcSuccessResponse | IJsonRpcErrorResponse;
|
|
31
32
|
export interface IJsonRpcProtocolHandlers {
|
|
32
33
|
handleRequest?(request: IJsonRpcRequest, token: CancellationToken): Promise<unknown> | unknown;
|
|
33
34
|
handleNotification?(notification: IJsonRpcNotification): void;
|
|
@@ -51,7 +52,18 @@ export declare class JsonRpcProtocol extends Disposable {
|
|
|
51
52
|
constructor(_send: (message: JsonRpcMessage) => void, _handlers: IJsonRpcProtocolHandlers);
|
|
52
53
|
sendNotification(notification: Omit<IJsonRpcNotification, "jsonrpc">): void;
|
|
53
54
|
sendRequest<T = unknown>(request: Omit<IJsonRpcRequest, "jsonrpc" | "id">, token?: CancellationToken, onCancel?: (id: JsonRpcId) => void): Promise<T>;
|
|
54
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Handles one or more incoming JSON-RPC messages.
|
|
57
|
+
*
|
|
58
|
+
* Returns an array of JSON-RPC response objects generated for any incoming
|
|
59
|
+
* requests in the message(s). Notifications and responses to our own
|
|
60
|
+
* outgoing requests do not produce return values. For batch inputs, the
|
|
61
|
+
* returned responses are in the same order as the corresponding requests.
|
|
62
|
+
*
|
|
63
|
+
* Note: responses are also emitted via the `_send` callback, so callers
|
|
64
|
+
* that rely on the return value should not re-send them.
|
|
65
|
+
*/
|
|
66
|
+
handleMessage(message: JsonRpcMessage | JsonRpcMessage[]): Promise<JsonRpcResponse[]>;
|
|
55
67
|
cancelPendingRequest(id: JsonRpcId): void;
|
|
56
68
|
cancelAllRequests(): void;
|
|
57
69
|
private _handleMessage;
|
|
@@ -68,12 +68,17 @@ class JsonRpcProtocol extends Disposable {
|
|
|
68
68
|
}
|
|
69
69
|
async handleMessage(message) {
|
|
70
70
|
if (Array.isArray(message)) {
|
|
71
|
+
const replies = [];
|
|
71
72
|
for (const single of message) {
|
|
72
|
-
await this._handleMessage(single);
|
|
73
|
+
const reply = await this._handleMessage(single);
|
|
74
|
+
if (reply) {
|
|
75
|
+
replies.push(reply);
|
|
76
|
+
}
|
|
73
77
|
}
|
|
74
|
-
return;
|
|
78
|
+
return replies;
|
|
75
79
|
}
|
|
76
|
-
await this._handleMessage(message);
|
|
80
|
+
const reply = await this._handleMessage(message);
|
|
81
|
+
return reply ? [reply] : [];
|
|
77
82
|
}
|
|
78
83
|
cancelPendingRequest(id) {
|
|
79
84
|
const request = this._pendingRequests.get(id);
|
|
@@ -101,13 +106,15 @@ class JsonRpcProtocol extends Disposable {
|
|
|
101
106
|
} else {
|
|
102
107
|
this._handleError(message);
|
|
103
108
|
}
|
|
109
|
+
return undefined;
|
|
104
110
|
}
|
|
105
111
|
if (isJsonRpcRequest(message)) {
|
|
106
|
-
|
|
112
|
+
return this._handleRequest(message);
|
|
107
113
|
}
|
|
108
114
|
if (isJsonRpcNotification(message)) {
|
|
109
115
|
this._handlers.handleNotification?.(message);
|
|
110
116
|
}
|
|
117
|
+
return undefined;
|
|
111
118
|
}
|
|
112
119
|
_handleResult(response) {
|
|
113
120
|
const request = this._pendingRequests.get(response.id);
|
|
@@ -130,29 +137,33 @@ class JsonRpcProtocol extends Disposable {
|
|
|
130
137
|
}
|
|
131
138
|
async _handleRequest(request) {
|
|
132
139
|
if (!this._handlers.handleRequest) {
|
|
133
|
-
|
|
140
|
+
const response = {
|
|
134
141
|
jsonrpc: "2.0",
|
|
135
142
|
id: request.id,
|
|
136
143
|
error: {
|
|
137
144
|
code: JsonRpcProtocol.MethodNotFound,
|
|
138
145
|
message: `Method not found: ${request.method}`
|
|
139
146
|
}
|
|
140
|
-
}
|
|
141
|
-
|
|
147
|
+
};
|
|
148
|
+
this._send(response);
|
|
149
|
+
return response;
|
|
142
150
|
}
|
|
143
151
|
const cts = ( new CancellationTokenSource());
|
|
144
152
|
this._register(toDisposable(() => cts.dispose(true)));
|
|
145
153
|
try {
|
|
146
154
|
const resultOrThenable = this._handlers.handleRequest(request, cts.token);
|
|
147
155
|
const result = isThenable(resultOrThenable) ? await resultOrThenable : resultOrThenable;
|
|
148
|
-
|
|
156
|
+
const response = {
|
|
149
157
|
jsonrpc: "2.0",
|
|
150
158
|
id: request.id,
|
|
151
159
|
result
|
|
152
|
-
}
|
|
160
|
+
};
|
|
161
|
+
this._send(response);
|
|
162
|
+
return response;
|
|
153
163
|
} catch (error) {
|
|
164
|
+
let response;
|
|
154
165
|
if (error instanceof JsonRpcError) {
|
|
155
|
-
|
|
166
|
+
response = {
|
|
156
167
|
jsonrpc: "2.0",
|
|
157
168
|
id: request.id,
|
|
158
169
|
error: {
|
|
@@ -160,17 +171,19 @@ class JsonRpcProtocol extends Disposable {
|
|
|
160
171
|
message: error.message,
|
|
161
172
|
data: error.data
|
|
162
173
|
}
|
|
163
|
-
}
|
|
174
|
+
};
|
|
164
175
|
} else {
|
|
165
|
-
|
|
176
|
+
response = {
|
|
166
177
|
jsonrpc: "2.0",
|
|
167
178
|
id: request.id,
|
|
168
179
|
error: {
|
|
169
180
|
code: JsonRpcProtocol.InternalError,
|
|
170
181
|
message: error instanceof Error ? error.message : "Internal error"
|
|
171
182
|
}
|
|
172
|
-
}
|
|
183
|
+
};
|
|
173
184
|
}
|
|
185
|
+
this._send(response);
|
|
186
|
+
return response;
|
|
174
187
|
} finally {
|
|
175
188
|
cts.dispose(true);
|
|
176
189
|
}
|
|
@@ -27,7 +27,7 @@ let AllowedMcpServersService = class AllowedMcpServersService extends Disposable
|
|
|
27
27
|
query: `@id:${mcpAccessConfig}`
|
|
28
28
|
}).toString());
|
|
29
29
|
return (new MarkdownString(localize(
|
|
30
|
-
|
|
30
|
+
2040,
|
|
31
31
|
"Model Context Protocol servers are disabled in the Editor. Please check your [settings]({0}).",
|
|
32
32
|
settingsCommandLink
|
|
33
33
|
)));
|
|
@@ -108,7 +108,8 @@ let McpGalleryManifestService = class McpGalleryManifestService extends Disposab
|
|
|
108
108
|
try {
|
|
109
109
|
const context = await this.requestService.request({
|
|
110
110
|
type: "GET",
|
|
111
|
-
url: `${url}/${version}/servers?limit=1
|
|
111
|
+
url: `${url}/${version}/servers?limit=1`,
|
|
112
|
+
callSite: "mcpGalleryManifestService.checkVersion"
|
|
112
113
|
}, CancellationToken.None);
|
|
113
114
|
if (isSuccess(context)) {
|
|
114
115
|
return true;
|
|
@@ -456,7 +456,7 @@ let McpGalleryService = class McpGalleryService extends Disposable {
|
|
|
456
456
|
async getReadme(gallery, token) {
|
|
457
457
|
const readmeUrl = gallery.readmeUrl;
|
|
458
458
|
if (!readmeUrl) {
|
|
459
|
-
return Promise.resolve(( localize(
|
|
459
|
+
return Promise.resolve(( localize(2041, "No README available")));
|
|
460
460
|
}
|
|
461
461
|
const uri = ( URI.parse(readmeUrl));
|
|
462
462
|
if (uri.scheme === Schemas.file) {
|
|
@@ -468,11 +468,12 @@ let McpGalleryService = class McpGalleryService extends Disposable {
|
|
|
468
468
|
}
|
|
469
469
|
}
|
|
470
470
|
if (uri.authority !== "raw.githubusercontent.com") {
|
|
471
|
-
return ( new MarkdownString(( localize(
|
|
471
|
+
return ( new MarkdownString(( localize(2042, "You can find information about this server [here]({0})", readmeUrl)))).value;
|
|
472
472
|
}
|
|
473
473
|
const context = await this.requestService.request({
|
|
474
474
|
type: "GET",
|
|
475
|
-
url: readmeUrl
|
|
475
|
+
url: readmeUrl,
|
|
476
|
+
callSite: "mcpGalleryService.getReadme"
|
|
476
477
|
}, token);
|
|
477
478
|
const result = await asText(context);
|
|
478
479
|
if (!result) {
|
|
@@ -597,7 +598,8 @@ let McpGalleryService = class McpGalleryService extends Disposable {
|
|
|
597
598
|
}
|
|
598
599
|
const context = await this.requestService.request({
|
|
599
600
|
type: "GET",
|
|
600
|
-
url
|
|
601
|
+
url,
|
|
602
|
+
callSite: "mcpGalleryService.queryMcpServers"
|
|
601
603
|
}, token);
|
|
602
604
|
const data = await asJson(context);
|
|
603
605
|
if (!data) {
|
|
@@ -617,7 +619,8 @@ let McpGalleryService = class McpGalleryService extends Disposable {
|
|
|
617
619
|
async getMcpServer(mcpServerUrl, mcpGalleryManifest) {
|
|
618
620
|
const context = await this.requestService.request({
|
|
619
621
|
type: "GET",
|
|
620
|
-
url: mcpServerUrl
|
|
622
|
+
url: mcpServerUrl,
|
|
623
|
+
callSite: "mcpGalleryService.getMcpServer"
|
|
621
624
|
}, CancellationToken.None);
|
|
622
625
|
if (context.res.statusCode && context.res.statusCode >= 400 && context.res.statusCode < 500) {
|
|
623
626
|
return undefined;
|
|
@@ -3,37 +3,68 @@ import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
|
|
|
3
3
|
import { MCP } from "@codingame/monaco-vscode-api/vscode/vs/platform/mcp/common/modelContextProtocol";
|
|
4
4
|
export declare const McpGatewayChannelName = "mcpGateway";
|
|
5
5
|
export declare const McpGatewayToolBrokerChannelName = "mcpGatewayToolBroker";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Descriptor for an MCP server known to the gateway.
|
|
8
|
+
*/
|
|
9
|
+
export interface IMcpGatewayServerDescriptor {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly label: string;
|
|
9
12
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
/**
|
|
14
|
+
* A single server entry exposed by the gateway.
|
|
15
|
+
*/
|
|
16
|
+
export interface IMcpGatewayServerInfo {
|
|
17
|
+
readonly label: string;
|
|
18
|
+
readonly address: URI;
|
|
13
19
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Per-server tool invoker used by a single gateway route/session.
|
|
22
|
+
* All methods operate on the specific server this invoker is bound to.
|
|
23
|
+
*/
|
|
24
|
+
export interface IMcpGatewaySingleServerInvoker {
|
|
25
|
+
readonly onDidChangeTools: Event<void>;
|
|
26
|
+
readonly onDidChangeResources: Event<void>;
|
|
27
|
+
listTools(): Promise<readonly MCP.Tool[]>;
|
|
28
|
+
callTool(name: string, args: Record<string, unknown>): Promise<MCP.CallToolResult>;
|
|
29
|
+
listResources(): Promise<readonly MCP.Resource[]>;
|
|
30
|
+
readResource(uri: string): Promise<MCP.ReadResourceResult>;
|
|
31
|
+
listResourceTemplates(): Promise<readonly MCP.ResourceTemplate[]>;
|
|
17
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Aggregating tool invoker that provides per-server operations and
|
|
35
|
+
* server lifecycle tracking. Used by the gateway service to create
|
|
36
|
+
* and manage per-server routes.
|
|
37
|
+
*/
|
|
18
38
|
export interface IMcpGatewayToolInvoker {
|
|
39
|
+
readonly onDidChangeServers: Event<readonly IMcpGatewayServerDescriptor[]>;
|
|
19
40
|
readonly onDidChangeTools: Event<void>;
|
|
20
41
|
readonly onDidChangeResources: Event<void>;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
42
|
+
listServers(): readonly IMcpGatewayServerDescriptor[];
|
|
43
|
+
listToolsForServer(serverId: string): Promise<readonly MCP.Tool[]>;
|
|
44
|
+
callToolForServer(serverId: string, name: string, args: Record<string, unknown>): Promise<MCP.CallToolResult>;
|
|
45
|
+
listResourcesForServer(serverId: string): Promise<readonly MCP.Resource[]>;
|
|
46
|
+
readResourceForServer(serverId: string, uri: string): Promise<MCP.ReadResourceResult>;
|
|
47
|
+
listResourceTemplatesForServer(serverId: string): Promise<readonly MCP.ResourceTemplate[]>;
|
|
26
48
|
}
|
|
27
49
|
/**
|
|
28
|
-
*
|
|
50
|
+
* Serializable result of creating an MCP gateway (safe for IPC).
|
|
29
51
|
*/
|
|
30
|
-
export interface
|
|
52
|
+
export interface IMcpGatewayDto {
|
|
31
53
|
/**
|
|
32
|
-
* The
|
|
54
|
+
* The servers currently exposed by this gateway.
|
|
33
55
|
*/
|
|
34
|
-
readonly
|
|
56
|
+
readonly servers: readonly IMcpGatewayServerInfo[];
|
|
35
57
|
/**
|
|
36
58
|
* The unique identifier for this gateway, used for disposal.
|
|
37
59
|
*/
|
|
38
60
|
readonly gatewayId: string;
|
|
39
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Result of creating an MCP gateway (in-process, includes event).
|
|
64
|
+
*/
|
|
65
|
+
export interface IMcpGatewayInfo extends IMcpGatewayDto {
|
|
66
|
+
/**
|
|
67
|
+
* Event that fires when the set of servers changes.
|
|
68
|
+
*/
|
|
69
|
+
readonly onDidChangeServers: Event<readonly IMcpGatewayServerInfo[]>;
|
|
70
|
+
}
|
|
@@ -115,16 +115,16 @@ registerWorkbenchContribution2(
|
|
|
115
115
|
const jsonRegistry = ( Registry.as(Extensions.JSONContribution));
|
|
116
116
|
jsonRegistry.registerSchema(mcpSchemaId, mcpServerSchema);
|
|
117
117
|
( Registry.as(EditorExtensions.EditorPane)).registerEditorPane(
|
|
118
|
-
EditorPaneDescriptor.create(McpServerEditor, McpServerEditor.ID, ( localize(
|
|
118
|
+
EditorPaneDescriptor.create(McpServerEditor, McpServerEditor.ID, ( localize(10329, "MCP Server"))),
|
|
119
119
|
[( new SyncDescriptor(McpServerEditorInput))]
|
|
120
120
|
);
|
|
121
121
|
( Registry.as(Extensions$1.Quickaccess)).registerQuickAccessProvider({
|
|
122
122
|
ctor: McpResourceQuickAccess,
|
|
123
123
|
prefix: McpResourceQuickAccess.PREFIX,
|
|
124
124
|
when: ChatContextKeys.enabled,
|
|
125
|
-
placeholder: ( localize(
|
|
125
|
+
placeholder: ( localize(10330, "Filter to an MCP resource")),
|
|
126
126
|
helpEntries: [{
|
|
127
|
-
description: ( localize(
|
|
127
|
+
description: ( localize(10331, "MCP Server Resources")),
|
|
128
128
|
commandId: McpCommandIds.AddConfiguration
|
|
129
129
|
}]
|
|
130
130
|
});
|
|
@@ -43,7 +43,7 @@ let McpAddContextContribution = class McpAddContextContribution extends Disposab
|
|
|
43
43
|
_registerAddContextMenu() {
|
|
44
44
|
this._addContextMenu.value = this._chatContextPickService.registerChatContextItem({
|
|
45
45
|
type: "pickerPick",
|
|
46
|
-
label: ( localize(
|
|
46
|
+
label: ( localize(10332, "MCP Resources...")),
|
|
47
47
|
icon: Codicon.mcp,
|
|
48
48
|
isEnabled(widget) {
|
|
49
49
|
return !!widget.attachmentCapabilities.supportsMCPAttachments;
|
|
@@ -51,7 +51,7 @@ let McpAddContextContribution = class McpAddContextContribution extends Disposab
|
|
|
51
51
|
asPicker: () => {
|
|
52
52
|
const helper = this._instantiationService.createInstance(McpResourcePickHelper);
|
|
53
53
|
return {
|
|
54
|
-
placeholder: ( localize(
|
|
54
|
+
placeholder: ( localize(10333, "Select MCP Resource...")),
|
|
55
55
|
picks: (_query, token) => this._getResourcePicks(token, helper),
|
|
56
56
|
goBack: () => {
|
|
57
57
|
return helper.navigateBack();
|