@theia/ai-mcp 1.57.0-next.37

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.
Files changed (52) hide show
  1. package/README.md +91 -0
  2. package/lib/browser/mcp-command-contribution.d.ts +26 -0
  3. package/lib/browser/mcp-command-contribution.d.ts.map +1 -0
  4. package/lib/browser/mcp-command-contribution.js +146 -0
  5. package/lib/browser/mcp-command-contribution.js.map +1 -0
  6. package/lib/browser/mcp-frontend-application-contribution.d.ts +26 -0
  7. package/lib/browser/mcp-frontend-application-contribution.d.ts.map +1 -0
  8. package/lib/browser/mcp-frontend-application-contribution.js +129 -0
  9. package/lib/browser/mcp-frontend-application-contribution.js.map +1 -0
  10. package/lib/browser/mcp-frontend-module.d.ts +4 -0
  11. package/lib/browser/mcp-frontend-module.d.ts.map +1 -0
  12. package/lib/browser/mcp-frontend-module.js +34 -0
  13. package/lib/browser/mcp-frontend-module.js.map +1 -0
  14. package/lib/browser/mcp-preferences.d.ts +4 -0
  15. package/lib/browser/mcp-preferences.d.ts.map +1 -0
  16. package/lib/browser/mcp-preferences.js +83 -0
  17. package/lib/browser/mcp-preferences.js.map +1 -0
  18. package/lib/common/index.d.ts +2 -0
  19. package/lib/common/index.d.ts.map +1 -0
  20. package/lib/common/index.js +20 -0
  21. package/lib/common/index.js.map +1 -0
  22. package/lib/common/mcp-server-manager.d.ts +38 -0
  23. package/lib/common/mcp-server-manager.d.ts.map +1 -0
  24. package/lib/common/mcp-server-manager.js +21 -0
  25. package/lib/common/mcp-server-manager.js.map +1 -0
  26. package/lib/node/mcp-backend-module.d.ts +4 -0
  27. package/lib/node/mcp-backend-module.d.ts.map +1 -0
  28. package/lib/node/mcp-backend-module.js +29 -0
  29. package/lib/node/mcp-backend-module.js.map +1 -0
  30. package/lib/node/mcp-server-manager-impl.d.ts +14 -0
  31. package/lib/node/mcp-server-manager-impl.d.ts.map +1 -0
  32. package/lib/node/mcp-server-manager-impl.js +93 -0
  33. package/lib/node/mcp-server-manager-impl.js.map +1 -0
  34. package/lib/node/mcp-server.d.ts +19 -0
  35. package/lib/node/mcp-server.d.ts.map +1 -0
  36. package/lib/node/mcp-server.js +97 -0
  37. package/lib/node/mcp-server.js.map +1 -0
  38. package/lib/package.spec.d.ts +1 -0
  39. package/lib/package.spec.d.ts.map +1 -0
  40. package/lib/package.spec.js +26 -0
  41. package/lib/package.spec.js.map +1 -0
  42. package/package.json +50 -0
  43. package/src/browser/mcp-command-contribution.ts +142 -0
  44. package/src/browser/mcp-frontend-application-contribution.ts +141 -0
  45. package/src/browser/mcp-frontend-module.ts +33 -0
  46. package/src/browser/mcp-preferences.ts +83 -0
  47. package/src/common/index.ts +16 -0
  48. package/src/common/mcp-server-manager.ts +58 -0
  49. package/src/node/mcp-backend-module.ts +31 -0
  50. package/src/node/mcp-server-manager-impl.ts +93 -0
  51. package/src/node/mcp-server.ts +111 -0
  52. package/src/package.spec.ts +28 -0
package/README.md ADDED
@@ -0,0 +1,91 @@
1
+ # Model Context Server (MCP) Integration
2
+
3
+ The AI MCP package provides an integration that allows users to start and use MCP servers to provide additional tool functions to LLMs, e.g. search or file access (outside of the workspace).
4
+
5
+ ## Features
6
+ - Add MCP servers via settings.json
7
+ - Start and stop MCP servers.
8
+ - Use tool functions provided by MCP servers in prompt templates
9
+
10
+ ## Commands
11
+
12
+ ### Start MCP Server
13
+
14
+ - **Command ID:** `mcp.startserver`
15
+ - **Label:** `MCP: Start MCP Server`
16
+ - **Functionality:** Allows you to start a MCP server by selecting from a list of configured servers.
17
+
18
+ ### Stop MCP Server
19
+
20
+ - **Command ID:** `mcp.stopserver`
21
+ - **Label:** `MCP: Stop MCP Server`
22
+ - **Functionality:** Allows you to stop a running MCP server by selecting from a list of currently running servers.
23
+
24
+ ## Usage
25
+
26
+ 1. **Starting a MCP Server:**
27
+
28
+ - Use the command palette to invoke `MCP: Start MCP Server`.
29
+ - A quick pick menu will appear with a list of configured MCP servers.
30
+ - Select a server to start.
31
+
32
+ 2. **Stopping a MCP Server:**
33
+ - Use the command palette to invoke `MCP: Stop MCP Server`.
34
+ - A quick pick menu will display a list of currently running MCP servers.
35
+ - Select a server to stop.
36
+
37
+ 3. **Using provided tool functions**
38
+ - Only functions of started MCP servers can be used
39
+ - Open a prompt template and add the added tool functions
40
+ - Type '~{' to open the auto completion
41
+
42
+ ## Configuration
43
+
44
+ Make sure to configure your MCP servers properly within the preference settings.
45
+
46
+ Example Configuration:
47
+
48
+ ```json
49
+ {
50
+ "ai-features.mcp.mcpServers": {
51
+ "memory": {
52
+ "command": "npx",
53
+ "args": [
54
+ "-y",
55
+ "@modelcontextprotocol/server-memory"
56
+ ]
57
+ },
58
+ "brave-search": {
59
+ "command": "npx",
60
+ "args": [
61
+ "-y",
62
+ "@modelcontextprotocol/server-brave-search"
63
+ ],
64
+ "env": {
65
+ "BRAVE_API_KEY": "YOUR_API_KEY"
66
+ }
67
+ },
68
+ "filesystem": {
69
+ "command": "npx",
70
+ "args": [
71
+ "-y",
72
+ "@modelcontextprotocol/server-filesystem",
73
+ "ABSOLUTE_PATH_TO_ALLOWED_DIRECTORY",
74
+ ]
75
+ },
76
+ }
77
+ }
78
+ ```
79
+
80
+ Example prompt (for search)
81
+ ```md
82
+ ~{mcp_brave-search_brave_web_search}
83
+ ```
84
+
85
+ Example User query
86
+ ```md
87
+ Search the internet for XYZ
88
+ ```
89
+
90
+ ## More Information
91
+ [List of available MCP servers](https://github.com/modelcontextprotocol/servers)
@@ -0,0 +1,26 @@
1
+ import { AICommandHandlerFactory } from '@theia/ai-core/lib/browser/ai-command-handler-factory';
2
+ import { CommandContribution, CommandRegistry, MessageService } from '@theia/core';
3
+ import { QuickInputService } from '@theia/core/lib/browser';
4
+ import { MCPServerManager } from '../common/mcp-server-manager';
5
+ import { ToolInvocationRegistry, ToolRequest } from '@theia/ai-core';
6
+ type MCPTool = Awaited<ReturnType<MCPServerManager['getTools']>>['tools'][number];
7
+ export declare const StartMCPServer: {
8
+ id: string;
9
+ label: string;
10
+ };
11
+ export declare const StopMCPServer: {
12
+ id: string;
13
+ label: string;
14
+ };
15
+ export declare class MCPCommandContribution implements CommandContribution {
16
+ protected readonly commandHandlerFactory: AICommandHandlerFactory;
17
+ protected readonly quickInputService: QuickInputService;
18
+ protected messageService: MessageService;
19
+ protected readonly mcpServerManager: MCPServerManager;
20
+ protected readonly toolInvocationRegistry: ToolInvocationRegistry;
21
+ private getMCPServerSelection;
22
+ registerCommands(commandRegistry: CommandRegistry): void;
23
+ convertToToolRequest(tool: MCPTool, serverName: string): ToolRequest;
24
+ }
25
+ export {};
26
+ //# sourceMappingURL=mcp-command-contribution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-command-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/mcp-command-contribution.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,uBAAuB,EAAE,MAAM,uDAAuD,CAAC;AAChG,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAErE,KAAK,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AAElF,eAAO,MAAM,cAAc;;;CAG1B,CAAC;AACF,eAAO,MAAM,aAAa;;;CAGzB,CAAC;AAEF,qBACa,sBAAuB,YAAW,mBAAmB;IAE9D,SAAS,CAAC,QAAQ,CAAC,qBAAqB,EAAE,uBAAuB,CAAC;IAGlE,SAAS,CAAC,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAGxD,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC;IAGzC,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAGtD,SAAS,CAAC,QAAQ,CAAC,sBAAsB,EAAE,sBAAsB,CAAC;YAEpD,qBAAqB;IASnC,gBAAgB,CAAC,eAAe,EAAE,eAAe,GAAG,IAAI;IA2DxD,oBAAoB,CAAC,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,WAAW;CAuBvE"}
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MCPCommandContribution = exports.StopMCPServer = exports.StartMCPServer = void 0;
4
+ const tslib_1 = require("tslib");
5
+ // *****************************************************************************
6
+ // Copyright (C) 2024 EclipseSource GmbH.
7
+ //
8
+ // This program and the accompanying materials are made available under the
9
+ // terms of the Eclipse Public License v. 2.0 which is available at
10
+ // http://www.eclipse.org/legal/epl-2.0.
11
+ //
12
+ // This Source Code may also be made available under the following Secondary
13
+ // Licenses when the conditions for such availability set forth in the Eclipse
14
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
15
+ // with the GNU Classpath Exception which is available at
16
+ // https://www.gnu.org/software/classpath/license.html.
17
+ //
18
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
19
+ // *****************************************************************************
20
+ const ai_command_handler_factory_1 = require("@theia/ai-core/lib/browser/ai-command-handler-factory");
21
+ const core_1 = require("@theia/core");
22
+ const browser_1 = require("@theia/core/lib/browser");
23
+ const inversify_1 = require("@theia/core/shared/inversify");
24
+ const mcp_server_manager_1 = require("../common/mcp-server-manager");
25
+ const ai_core_1 = require("@theia/ai-core");
26
+ exports.StartMCPServer = {
27
+ id: 'mcp.startserver',
28
+ label: 'MCP: Start MCP Server',
29
+ };
30
+ exports.StopMCPServer = {
31
+ id: 'mcp.stopserver',
32
+ label: 'MCP: Stop MCP Server',
33
+ };
34
+ let MCPCommandContribution = class MCPCommandContribution {
35
+ async getMCPServerSelection(serverNames) {
36
+ if (!serverNames || serverNames.length === 0) {
37
+ return undefined;
38
+ }
39
+ const options = serverNames.map(mcpServerName => ({ label: mcpServerName }));
40
+ const result = await this.quickInputService.showQuickPick(options);
41
+ return result === null || result === void 0 ? void 0 : result.label;
42
+ }
43
+ registerCommands(commandRegistry) {
44
+ commandRegistry.registerCommand(exports.StopMCPServer, this.commandHandlerFactory({
45
+ execute: async () => {
46
+ try {
47
+ const startedServers = await this.mcpServerManager.getStartedServers();
48
+ if (!startedServers || startedServers.length === 0) {
49
+ this.messageService.error('No MCP servers running.');
50
+ return;
51
+ }
52
+ const selection = await this.getMCPServerSelection(startedServers);
53
+ if (!selection) {
54
+ return;
55
+ }
56
+ this.toolInvocationRegistry.unregisterAllTools(`mcp_${selection}`);
57
+ this.mcpServerManager.stopServer(selection);
58
+ }
59
+ catch (error) {
60
+ console.error('Error while stopping MCP server:', error);
61
+ }
62
+ }
63
+ }));
64
+ commandRegistry.registerCommand(exports.StartMCPServer, this.commandHandlerFactory({
65
+ execute: async () => {
66
+ try {
67
+ const servers = await this.mcpServerManager.getServerNames();
68
+ const startedServers = await this.mcpServerManager.getStartedServers();
69
+ const startableServers = servers.filter(server => !startedServers.includes(server));
70
+ if (!startableServers || startableServers.length === 0) {
71
+ if (startedServers && startedServers.length > 0) {
72
+ this.messageService.error('All MCP servers are already running.');
73
+ }
74
+ else {
75
+ this.messageService.error('No MCP servers configured.');
76
+ }
77
+ return;
78
+ }
79
+ const selection = await this.getMCPServerSelection(startableServers);
80
+ if (!selection) {
81
+ return;
82
+ }
83
+ this.mcpServerManager.startServer(selection);
84
+ const { tools } = await this.mcpServerManager.getTools(selection);
85
+ const toolRequests = tools.map(tool => this.convertToToolRequest(tool, selection));
86
+ for (const toolRequest of toolRequests) {
87
+ this.toolInvocationRegistry.registerTool(toolRequest);
88
+ }
89
+ const toolNames = tools.map(tool => tool.name || 'Unnamed Tool').join(', ');
90
+ this.messageService.info(`MCP server "${selection}" successfully started. Registered tools: ${toolNames || 'No tools available.'}`);
91
+ }
92
+ catch (error) {
93
+ this.messageService.error('An error occurred while starting the MCP server.');
94
+ console.error('Error while starting MCP server:', error);
95
+ }
96
+ }
97
+ }));
98
+ }
99
+ convertToToolRequest(tool, serverName) {
100
+ const id = `mcp_${serverName}_${tool.name}`;
101
+ return {
102
+ id: id,
103
+ name: id,
104
+ providerName: `mcp_${serverName}`,
105
+ parameters: ai_core_1.ToolRequest.isToolRequestParameters(tool.inputSchema) ? {
106
+ type: tool.inputSchema.type,
107
+ properties: tool.inputSchema.properties,
108
+ } : undefined,
109
+ description: tool.description,
110
+ handler: async (arg_string) => {
111
+ try {
112
+ return await this.mcpServerManager.callTool(serverName, tool.name, arg_string);
113
+ }
114
+ catch (error) {
115
+ console.error(`Error in tool handler for ${tool.name} on MCP server ${serverName}:`, error);
116
+ throw error;
117
+ }
118
+ },
119
+ };
120
+ }
121
+ };
122
+ exports.MCPCommandContribution = MCPCommandContribution;
123
+ tslib_1.__decorate([
124
+ (0, inversify_1.inject)(ai_command_handler_factory_1.AICommandHandlerFactory),
125
+ tslib_1.__metadata("design:type", Function)
126
+ ], MCPCommandContribution.prototype, "commandHandlerFactory", void 0);
127
+ tslib_1.__decorate([
128
+ (0, inversify_1.inject)(browser_1.QuickInputService),
129
+ tslib_1.__metadata("design:type", Object)
130
+ ], MCPCommandContribution.prototype, "quickInputService", void 0);
131
+ tslib_1.__decorate([
132
+ (0, inversify_1.inject)(core_1.MessageService),
133
+ tslib_1.__metadata("design:type", core_1.MessageService)
134
+ ], MCPCommandContribution.prototype, "messageService", void 0);
135
+ tslib_1.__decorate([
136
+ (0, inversify_1.inject)(mcp_server_manager_1.MCPServerManager),
137
+ tslib_1.__metadata("design:type", Object)
138
+ ], MCPCommandContribution.prototype, "mcpServerManager", void 0);
139
+ tslib_1.__decorate([
140
+ (0, inversify_1.inject)(ai_core_1.ToolInvocationRegistry),
141
+ tslib_1.__metadata("design:type", Object)
142
+ ], MCPCommandContribution.prototype, "toolInvocationRegistry", void 0);
143
+ exports.MCPCommandContribution = MCPCommandContribution = tslib_1.__decorate([
144
+ (0, inversify_1.injectable)()
145
+ ], MCPCommandContribution);
146
+ //# sourceMappingURL=mcp-command-contribution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-command-contribution.js","sourceRoot":"","sources":["../../src/browser/mcp-command-contribution.ts"],"names":[],"mappings":";;;;AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;AAChF,sGAAgG;AAChG,sCAAmF;AACnF,qDAA4D;AAC5D,4DAAkE;AAClE,qEAAgE;AAChE,4CAAqE;AAIxD,QAAA,cAAc,GAAG;IAC1B,EAAE,EAAE,iBAAiB;IACrB,KAAK,EAAE,uBAAuB;CACjC,CAAC;AACW,QAAA,aAAa,GAAG;IACzB,EAAE,EAAE,gBAAgB;IACpB,KAAK,EAAE,sBAAsB;CAChC,CAAC;AAGK,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAgBvB,KAAK,CAAC,qBAAqB,CAAC,WAAqB;QACrD,IAAI,CAAC,WAAW,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3C,OAAO,SAAS,CAAC;QACrB,CAAC;QACD,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC;QAC7E,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACnE,OAAO,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC;IACzB,CAAC;IAED,gBAAgB,CAAC,eAAgC;QAC7C,eAAe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;;gEAC6B;AAGnC;IADlB,IAAA,kBAAM,EAAC,gCAAsB,CAAC;;sEACmC;iCAdzD,sBAAsB;IADlC,IAAA,sBAAU,GAAE;GACA,sBAAsB,CA2GlC"}
@@ -0,0 +1,26 @@
1
+ import { FrontendApplicationContribution, PreferenceService } from '@theia/core/lib/browser';
2
+ import { MCPServerDescription, MCPServerManager } from '../common';
3
+ interface MCPServersPreferenceValue {
4
+ command: string;
5
+ args?: string[];
6
+ env?: {
7
+ [key: string]: string;
8
+ };
9
+ }
10
+ interface MCPServersPreference {
11
+ [name: string]: MCPServersPreferenceValue;
12
+ }
13
+ declare namespace MCPServersPreference {
14
+ function isValue(obj: unknown): obj is MCPServersPreferenceValue;
15
+ }
16
+ export declare class McpFrontendApplicationContribution implements FrontendApplicationContribution {
17
+ protected preferenceService: PreferenceService;
18
+ protected manager: MCPServerManager;
19
+ protected prevServers: Map<string, MCPServerDescription>;
20
+ onStart(): void;
21
+ protected handleServerChanges(newServers: MCPServersPreference): void;
22
+ protected syncServers(servers: MCPServersPreference): void;
23
+ protected convertToMap(servers: MCPServersPreference): Map<string, MCPServerDescription>;
24
+ }
25
+ export {};
26
+ //# sourceMappingURL=mcp-frontend-application-contribution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-frontend-application-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/mcp-frontend-application-contribution.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,+BAA+B,EAAsB,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjH,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAInE,UAAU,yBAAyB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACnC;AAED,UAAU,oBAAoB;IAC1B,CAAC,IAAI,EAAE,MAAM,GAAG,yBAAyB,CAAA;CAC5C;AAED,kBAAU,oBAAoB,CAAC;IAC3B,SAAgB,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,yBAAyB,CAKtE;CACJ;AAeD,qBACa,kCAAmC,YAAW,+BAA+B;IAGtF,SAAS,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAG/C,SAAS,CAAC,OAAO,EAAE,gBAAgB,CAAC;IAEpC,SAAS,CAAC,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAa;IAErE,OAAO,IAAI,IAAI;IAiBf,SAAS,CAAC,mBAAmB,CAAC,UAAU,EAAE,oBAAoB,GAAG,IAAI;IAgCrE,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI;IAgB1D,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,oBAAoB,GAAG,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC;CAW3F"}
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.McpFrontendApplicationContribution = void 0;
4
+ const tslib_1 = require("tslib");
5
+ // *****************************************************************************
6
+ // Copyright (C) 2024 EclipseSource GmbH.
7
+ //
8
+ // This program and the accompanying materials are made available under the
9
+ // terms of the Eclipse Public License v. 2.0 which is available at
10
+ // http://www.eclipse.org/legal/epl-2.0.
11
+ //
12
+ // This Source Code may also be made available under the following Secondary
13
+ // Licenses when the conditions for such availability set forth in the Eclipse
14
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
15
+ // with the GNU Classpath Exception which is available at
16
+ // https://www.gnu.org/software/classpath/license.html.
17
+ //
18
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
19
+ // *****************************************************************************
20
+ const browser_1 = require("@theia/core/lib/browser");
21
+ const inversify_1 = require("@theia/core/shared/inversify");
22
+ const common_1 = require("../common");
23
+ const mcp_preferences_1 = require("./mcp-preferences");
24
+ ;
25
+ ;
26
+ var MCPServersPreference;
27
+ (function (MCPServersPreference) {
28
+ function isValue(obj) {
29
+ return !!obj && typeof obj === 'object' &&
30
+ 'command' in obj && typeof obj.command === 'string' &&
31
+ (!('args' in obj) || Array.isArray(obj.args) && obj.args.every(arg => typeof arg === 'string')) &&
32
+ (!('env' in obj) || !!obj.env && typeof obj.env === 'object' && Object.values(obj.env).every(value => typeof value === 'string'));
33
+ }
34
+ MCPServersPreference.isValue = isValue;
35
+ })(MCPServersPreference || (MCPServersPreference = {}));
36
+ function filterValidValues(servers) {
37
+ const result = {};
38
+ if (!servers || typeof servers !== 'object') {
39
+ return result;
40
+ }
41
+ for (const [name, value] of Object.entries(servers)) {
42
+ if (typeof name === 'string' && MCPServersPreference.isValue(value)) {
43
+ result[name] = value;
44
+ }
45
+ }
46
+ return result;
47
+ }
48
+ let McpFrontendApplicationContribution = class McpFrontendApplicationContribution {
49
+ constructor() {
50
+ this.prevServers = new Map();
51
+ }
52
+ onStart() {
53
+ this.preferenceService.ready.then(() => {
54
+ const servers = filterValidValues(this.preferenceService.get(mcp_preferences_1.MCP_SERVERS_PREF, {}));
55
+ this.syncServers(servers);
56
+ this.prevServers = this.convertToMap(servers);
57
+ this.preferenceService.onPreferenceChanged(event => {
58
+ if (event.preferenceName === mcp_preferences_1.MCP_SERVERS_PREF) {
59
+ this.handleServerChanges(filterValidValues(event.newValue));
60
+ }
61
+ });
62
+ });
63
+ }
64
+ handleServerChanges(newServers) {
65
+ const oldServers = this.prevServers;
66
+ const updatedServers = this.convertToMap(newServers);
67
+ for (const [name] of oldServers) {
68
+ if (!updatedServers.has(name)) {
69
+ this.manager.removeServer(name);
70
+ }
71
+ }
72
+ for (const [name, description] of updatedServers) {
73
+ const oldDescription = oldServers.get(name);
74
+ let diff = false;
75
+ try {
76
+ // We know that that the descriptions are actual JSONObjects as we construct them ourselves
77
+ if (!oldDescription || !browser_1.PreferenceProvider.deepEqual(oldDescription, description)) {
78
+ diff = true;
79
+ }
80
+ }
81
+ catch (e) {
82
+ // In some cases the deepEqual function throws an error, so we fall back to assuming that there is a difference
83
+ // This seems to happen in cases where the objects are structured differently, e.g. whole sub-objects are missing
84
+ console.debug('Failed to compare MCP server descriptions, assuming a difference', e);
85
+ diff = true;
86
+ }
87
+ if (diff) {
88
+ this.manager.addOrUpdateServer(description);
89
+ }
90
+ }
91
+ this.prevServers = updatedServers;
92
+ }
93
+ syncServers(servers) {
94
+ const updatedServers = this.convertToMap(servers);
95
+ for (const [, description] of updatedServers) {
96
+ this.manager.addOrUpdateServer(description);
97
+ }
98
+ for (const [name] of this.prevServers) {
99
+ if (!updatedServers.has(name)) {
100
+ this.manager.removeServer(name);
101
+ }
102
+ }
103
+ this.prevServers = updatedServers;
104
+ }
105
+ convertToMap(servers) {
106
+ const map = new Map();
107
+ Object.entries(servers).forEach(([name, description]) => {
108
+ map.set(name, {
109
+ name,
110
+ ...description,
111
+ env: description.env || undefined
112
+ });
113
+ });
114
+ return map;
115
+ }
116
+ };
117
+ exports.McpFrontendApplicationContribution = McpFrontendApplicationContribution;
118
+ tslib_1.__decorate([
119
+ (0, inversify_1.inject)(browser_1.PreferenceService),
120
+ tslib_1.__metadata("design:type", Object)
121
+ ], McpFrontendApplicationContribution.prototype, "preferenceService", void 0);
122
+ tslib_1.__decorate([
123
+ (0, inversify_1.inject)(common_1.MCPServerManager),
124
+ tslib_1.__metadata("design:type", Object)
125
+ ], McpFrontendApplicationContribution.prototype, "manager", void 0);
126
+ exports.McpFrontendApplicationContribution = McpFrontendApplicationContribution = tslib_1.__decorate([
127
+ (0, inversify_1.injectable)()
128
+ ], McpFrontendApplicationContribution);
129
+ //# sourceMappingURL=mcp-frontend-application-contribution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-frontend-application-contribution.js","sourceRoot":"","sources":["../../src/browser/mcp-frontend-application-contribution.ts"],"names":[],"mappings":";;;;AAAA,gFAAgF;AAChF,yCAAyC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C,CAAC;YACpC,CAAC;QACL,CAAC;QAED,IAAI,CAAC,WAAW,GAAG,cAAc,CAAC;IACtC,CAAC;IAES,YAAY,CAAC,OAA6B;QAChD,MAAM,GAAG,GAAG,IAAI,GAAG,EAAgC,CAAC;QACpD,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE,EAAE;YACpD,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE;gBACV,IAAI;gBACJ,GAAG,WAAW;gBACd,GAAG,EAAE,WAAW,CAAC,GAAG,IAAI,SAAS;aACpC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;QACH,OAAO,GAAG,CAAC;IACf,CAAC;CACJ,CAAA;AAtFY,gFAAkC;AAGjC;IADT,IAAA,kBAAM,EAAC,2BAAiB,CAAC;;6EACqB;AAGrC;IADT,IAAA,kBAAM,EAAC,yBAAgB,CAAC;;mEACW;6CAN3B,kCAAkC;IAD9C,IAAA,sBAAU,GAAE;GACA,kCAAkC,CAsF9C"}
@@ -0,0 +1,4 @@
1
+ import { ContainerModule } from '@theia/core/shared/inversify';
2
+ declare const _default: ContainerModule;
3
+ export default _default;
4
+ //# sourceMappingURL=mcp-frontend-module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-frontend-module.d.ts","sourceRoot":"","sources":["../../src/browser/mcp-frontend-module.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;;AAO/D,wBAQG"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2024 EclipseSource GmbH.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const core_1 = require("@theia/core");
19
+ const inversify_1 = require("@theia/core/shared/inversify");
20
+ const mcp_command_contribution_1 = require("./mcp-command-contribution");
21
+ const browser_1 = require("@theia/core/lib/browser");
22
+ const mcp_server_manager_1 = require("../common/mcp-server-manager");
23
+ const mcp_preferences_1 = require("./mcp-preferences");
24
+ const mcp_frontend_application_contribution_1 = require("./mcp-frontend-application-contribution");
25
+ exports.default = new inversify_1.ContainerModule(bind => {
26
+ bind(browser_1.PreferenceContribution).toConstantValue({ schema: mcp_preferences_1.McpServersPreferenceSchema });
27
+ bind(browser_1.FrontendApplicationContribution).to(mcp_frontend_application_contribution_1.McpFrontendApplicationContribution).inSingletonScope();
28
+ bind(core_1.CommandContribution).to(mcp_command_contribution_1.MCPCommandContribution);
29
+ bind(mcp_server_manager_1.MCPServerManager).toDynamicValue(ctx => {
30
+ const connection = ctx.container.get(browser_1.RemoteConnectionProvider);
31
+ return connection.createProxy(mcp_server_manager_1.MCPServerManagerPath);
32
+ }).inSingletonScope();
33
+ });
34
+ //# sourceMappingURL=mcp-frontend-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-frontend-module.js","sourceRoot":"","sources":["../../src/browser/mcp-frontend-module.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;AAEhF,sCAAkD;AAClD,4DAA+D;AAC/D,yEAAoE;AACpE,qDAAuJ;AACvJ,qEAAsF;AACtF,uDAA+D;AAC/D,mGAA6F;AAE7F,kBAAe,IAAI,2BAAe,CAAC,IAAI,CAAC,EAAE;IACtC,IAAI,CAAC,gCAAsB,CAAC,CAAC,eAAe,CAAC,EAAE,MAAM,EAAE,4CAA0B,EAAE,CAAC,CAAC;IACrF,IAAI,CAAC,yCAA+B,CAAC,CAAC,EAAE,CAAC,0EAAkC,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAChG,IAAI,CAAC,0BAAmB,CAAC,CAAC,EAAE,CAAC,iDAAsB,CAAC,CAAC;IACrD,IAAI,CAAC,qCAAgB,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;QACxC,MAAM,UAAU,GAAG,GAAG,CAAC,SAAS,CAAC,GAAG,CAA4B,kCAAwB,CAAC,CAAC;QAC1F,OAAO,UAAU,CAAC,WAAW,CAAmB,yCAAoB,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC;AAC1B,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { PreferenceSchema } from '@theia/core/lib/browser/preferences/preference-contribution';
2
+ export declare const MCP_SERVERS_PREF = "ai-features.mcp.mcpServers";
3
+ export declare const McpServersPreferenceSchema: PreferenceSchema;
4
+ //# sourceMappingURL=mcp-preferences.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-preferences.d.ts","sourceRoot":"","sources":["../../src/browser/mcp-preferences.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6DAA6D,CAAC;AAE/F,eAAO,MAAM,gBAAgB,+BAA+B,CAAC;AAE7D,eAAO,MAAM,0BAA0B,EAAE,gBA8DxC,CAAC"}
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2024 EclipseSource GmbH.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.McpServersPreferenceSchema = exports.MCP_SERVERS_PREF = void 0;
19
+ exports.MCP_SERVERS_PREF = 'ai-features.mcp.mcpServers';
20
+ exports.McpServersPreferenceSchema = {
21
+ type: 'object',
22
+ properties: {
23
+ [exports.MCP_SERVERS_PREF]: {
24
+ type: 'object',
25
+ title: 'MCP Servers Configuration',
26
+ markdownDescription: 'Configure MCP servers with command, arguments and optionally environment variables. Each server is identified by a unique key, such as\
27
+ "brave-search" or "filesystem".\
28
+ To start a server, use the "MCP: Start MCP Server" command, which enables you to select the desired server.\
29
+ To stop a server, use the "MCP: Stop MCP Server" command.\
30
+ \n\
31
+ Example configuration:\n\
32
+ ```\
33
+ {\n\
34
+ "brave-search": {\n\
35
+ "command": "npx",\n\
36
+ "args": [\n\
37
+ "-y",\n\
38
+ "@modelcontextprotocol/server-brave-search"\n\
39
+ ],\n\
40
+ "env": {\n\
41
+ "BRAVE_API_KEY": "YOUR_API_KEY"\n\
42
+ }\n\
43
+ },\n\
44
+ "filesystem": {\n\
45
+ "command": "npx",\n\
46
+ "args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/YOUR_USERNAME/Desktop"],\n\
47
+ "env": {\n\
48
+ "CUSTOM_ENV_VAR": "custom-value"\n\
49
+ }\n\
50
+ }\n\
51
+ }\
52
+ ```',
53
+ additionalProperties: {
54
+ type: 'object',
55
+ properties: {
56
+ command: {
57
+ type: 'string',
58
+ title: 'Command to execute the MCP server',
59
+ markdownDescription: 'The command used to start the MCP server, e.g., "uvx" or "npx".'
60
+ },
61
+ args: {
62
+ type: 'array',
63
+ title: 'Arguments for the command',
64
+ markdownDescription: 'An array of arguments to pass to the command.',
65
+ items: {
66
+ type: 'string'
67
+ }
68
+ },
69
+ env: {
70
+ type: 'object',
71
+ title: 'Environment variables',
72
+ markdownDescription: 'Optional environment variables to set for the server, such as an API key.',
73
+ additionalProperties: {
74
+ type: 'string'
75
+ }
76
+ }
77
+ },
78
+ required: ['command', 'args']
79
+ }
80
+ }
81
+ }
82
+ };
83
+ //# sourceMappingURL=mcp-preferences.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-preferences.js","sourceRoot":"","sources":["../../src/browser/mcp-preferences.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;AAInE,QAAA,gBAAgB,GAAG,4BAA4B,CAAC;AAEhD,QAAA,0BAA0B,GAAqB;IACxD,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACR,CAAC,wBAAgB,CAAC,EAAE;YAChB,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,2BAA2B;YAClC,mBAAmB,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;gBA0BjB;YACJ,oBAAoB,EAAE;gBAClB,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACR,OAAO,EAAE;wBACL,IAAI,EAAE,QAAQ;wBACd,KAAK,EAAE,mCAAmC;wBAC1C,mBAAmB,EAAE,iEAAiE;qBACzF;oBACD,IAAI,EAAE;wBACF,IAAI,EAAE,OAAO;wBACb,KAAK,EAAE,2BAA2B;wBAClC,mBAAmB,EAAE,+CAA+C;wBACpE,KAAK,EAAE;4BACH,IAAI,EAAE,QAAQ;yBACjB;qBACJ;oBACD,GAAG,EAAE;wBACD,IAAI,EAAE,QAAQ;wBACd,KAAK,EAAE,uBAAuB;wBAC9B,mBAAmB,EAAE,2EAA2E;wBAChG,oBAAoB,EAAE;4BAClB,IAAI,EAAE,QAAQ;yBACjB;qBACJ;iBACJ;gBACD,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC;aAChC;SACJ;KACJ;CACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './mcp-server-manager';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAeA,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ // *****************************************************************************
5
+ // Copyright (C) 2024 EclipseSource GmbH.
6
+ //
7
+ // This program and the accompanying materials are made available under the
8
+ // terms of the Eclipse Public License v. 2.0 which is available at
9
+ // http://www.eclipse.org/legal/epl-2.0.
10
+ //
11
+ // This Source Code may also be made available under the following Secondary
12
+ // Licenses when the conditions for such availability set forth in the Eclipse
13
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
14
+ // with the GNU Classpath Exception which is available at
15
+ // https://www.gnu.org/software/classpath/license.html.
16
+ //
17
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
18
+ // *****************************************************************************
19
+ tslib_1.__exportStar(require("./mcp-server-manager"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";;;AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;AAChF,+DAAqC"}