@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
@@ -0,0 +1,38 @@
1
+ import type { Client } from '@modelcontextprotocol/sdk/client/index';
2
+ export interface MCPServer {
3
+ callTool(toolName: string, arg_string: string): ReturnType<Client['callTool']>;
4
+ getTools(): ReturnType<Client['listTools']>;
5
+ }
6
+ export interface MCPServerManager {
7
+ callTool(serverName: string, toolName: string, arg_string: string): ReturnType<MCPServer['callTool']>;
8
+ removeServer(name: string): void;
9
+ addOrUpdateServer(description: MCPServerDescription): void;
10
+ getTools(serverName: string): ReturnType<MCPServer['getTools']>;
11
+ getServerNames(): Promise<string[]>;
12
+ startServer(serverName: string): Promise<void>;
13
+ stopServer(serverName: string): Promise<void>;
14
+ getStartedServers(): Promise<string[]>;
15
+ }
16
+ export interface MCPServerDescription {
17
+ /**
18
+ * The unique name of the MCP server.
19
+ */
20
+ name: string;
21
+ /**
22
+ * The command to execute the MCP server.
23
+ */
24
+ command: string;
25
+ /**
26
+ * An array of arguments to pass to the command.
27
+ */
28
+ args?: string[];
29
+ /**
30
+ * Optional environment variables to set when starting the server.
31
+ */
32
+ env?: {
33
+ [key: string]: string;
34
+ };
35
+ }
36
+ export declare const MCPServerManager: unique symbol;
37
+ export declare const MCPServerManagerPath = "/services/mcpservermanager";
38
+ //# sourceMappingURL=mcp-server-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-server-manager.d.ts","sourceRoot":"","sources":["../../src/common/mcp-server-manager.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wCAAwC,CAAC;AAErE,MAAM,WAAW,SAAS;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;IAC/E,QAAQ,IAAI,UAAU,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;CAC/C;AAED,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;IACtG,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,iBAAiB,CAAC,WAAW,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAC3D,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAA;IAC/D,cAAc,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACpC,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,iBAAiB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;CAC1C;AAED,MAAM,WAAW,oBAAoB;IACjC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAEhB;;OAEG;IACH,GAAG,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACnC;AAED,eAAO,MAAM,gBAAgB,eAA6B,CAAC;AAC3D,eAAO,MAAM,oBAAoB,+BAA+B,CAAC"}
@@ -0,0 +1,21 @@
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.MCPServerManagerPath = exports.MCPServerManager = void 0;
19
+ exports.MCPServerManager = Symbol('MCPServerManager');
20
+ exports.MCPServerManagerPath = '/services/mcpservermanager';
21
+ //# sourceMappingURL=mcp-server-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-server-manager.js","sourceRoot":"","sources":["../../src/common/mcp-server-manager.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;;;AA0CnE,QAAA,gBAAgB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAC9C,QAAA,oBAAoB,GAAG,4BAA4B,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { ContainerModule } from '@theia/core/shared/inversify';
2
+ declare const _default: ContainerModule;
3
+ export default _default;
4
+ //# sourceMappingURL=mcp-backend-module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-backend-module.d.ts","sourceRoot":"","sources":["../../src/node/mcp-backend-module.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;;AAK/D,wBASG"}
@@ -0,0 +1,29 @@
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 inversify_1 = require("@theia/core/shared/inversify");
19
+ const core_1 = require("@theia/core");
20
+ const mcp_server_manager_impl_1 = require("./mcp-server-manager-impl");
21
+ const mcp_server_manager_1 = require("../common/mcp-server-manager");
22
+ exports.default = new inversify_1.ContainerModule(bind => {
23
+ bind(mcp_server_manager_1.MCPServerManager).to(mcp_server_manager_impl_1.MCPServerManagerImpl).inSingletonScope();
24
+ bind(core_1.ConnectionHandler).toDynamicValue(ctx => new core_1.RpcConnectionHandler(mcp_server_manager_1.MCPServerManagerPath, () => {
25
+ const service = ctx.container.get(mcp_server_manager_1.MCPServerManager);
26
+ return service;
27
+ })).inSingletonScope();
28
+ });
29
+ //# sourceMappingURL=mcp-backend-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-backend-module.js","sourceRoot":"","sources":["../../src/node/mcp-backend-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,4DAA+D;AAC/D,sCAAsE;AACtE,uEAAiE;AACjE,qEAAsF;AAEtF,kBAAe,IAAI,2BAAe,CAAC,IAAI,CAAC,EAAE;IACtC,IAAI,CAAC,qCAAgB,CAAC,CAAC,EAAE,CAAC,8CAAoB,CAAC,CAAC,gBAAgB,EAAE,CAAC;IACnE,IAAI,CAAC,wBAAiB,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,2BAAoB,CAClE,yCAAoB,EACpB,GAAG,EAAE;QACD,MAAM,OAAO,GAAG,GAAG,CAAC,SAAS,CAAC,GAAG,CAAmB,qCAAgB,CAAC,CAAC;QACtE,OAAO,OAAO,CAAC;IACnB,CAAC,CACJ,CAAC,CAAC,gBAAgB,EAAE,CAAC;AAC1B,CAAC,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { MCPServerDescription, MCPServerManager } from '../common/mcp-server-manager';
2
+ import { MCPServer } from './mcp-server';
3
+ export declare class MCPServerManagerImpl implements MCPServerManager {
4
+ protected servers: Map<string, MCPServer>;
5
+ stopServer(serverName: string): Promise<void>;
6
+ getStartedServers(): Promise<string[]>;
7
+ callTool(serverName: string, toolName: string, arg_string: string): ReturnType<MCPServer['callTool']>;
8
+ startServer(serverName: string): Promise<void>;
9
+ getServerNames(): Promise<string[]>;
10
+ getTools(serverName: string): ReturnType<MCPServer['getTools']>;
11
+ addOrUpdateServer(description: MCPServerDescription): void;
12
+ removeServer(name: string): void;
13
+ }
14
+ //# sourceMappingURL=mcp-server-manager-impl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-server-manager-impl.d.ts","sourceRoot":"","sources":["../../src/node/mcp-server-manager-impl.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACtF,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,qBACa,oBAAqB,YAAW,gBAAgB;IAEzD,SAAS,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAa;IAEhD,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS7C,iBAAiB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAU5C,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAQ/F,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAO9C,cAAc,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAI5B,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAS5E,iBAAiB,CAAC,WAAW,EAAE,oBAAoB,GAAG,IAAI;IAY1D,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;CASnC"}
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MCPServerManagerImpl = 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 inversify_1 = require("@theia/core/shared/inversify");
21
+ const mcp_server_1 = require("./mcp-server");
22
+ let MCPServerManagerImpl = class MCPServerManagerImpl {
23
+ constructor() {
24
+ this.servers = new Map();
25
+ }
26
+ async stopServer(serverName) {
27
+ const server = this.servers.get(serverName);
28
+ if (!server) {
29
+ throw new Error(`MCP server "${serverName}" not found.`);
30
+ }
31
+ server.stop();
32
+ console.log(`MCP server "${serverName}" stopped.`);
33
+ }
34
+ async getStartedServers() {
35
+ const startedServers = [];
36
+ for (const [name, server] of this.servers.entries()) {
37
+ if (server.isStarted()) {
38
+ startedServers.push(name);
39
+ }
40
+ }
41
+ return startedServers;
42
+ }
43
+ callTool(serverName, toolName, arg_string) {
44
+ const server = this.servers.get(serverName);
45
+ if (!server) {
46
+ throw new Error(`MCP server "${toolName}" not found.`);
47
+ }
48
+ return server.callTool(toolName, arg_string);
49
+ }
50
+ async startServer(serverName) {
51
+ const server = this.servers.get(serverName);
52
+ if (!server) {
53
+ throw new Error(`MCP server "${serverName}" not found.`);
54
+ }
55
+ await server.start();
56
+ }
57
+ async getServerNames() {
58
+ return Array.from(this.servers.keys());
59
+ }
60
+ async getTools(serverName) {
61
+ const server = this.servers.get(serverName);
62
+ if (!server) {
63
+ throw new Error(`MCP server "${serverName}" not found.`);
64
+ }
65
+ return server.getTools();
66
+ }
67
+ addOrUpdateServer(description) {
68
+ const { name, command, args, env } = description;
69
+ const existingServer = this.servers.get(name);
70
+ if (existingServer) {
71
+ existingServer.update(command, args, env);
72
+ }
73
+ else {
74
+ const newServer = new mcp_server_1.MCPServer(name, command, args, env);
75
+ this.servers.set(name, newServer);
76
+ }
77
+ }
78
+ removeServer(name) {
79
+ const server = this.servers.get(name);
80
+ if (server) {
81
+ server.stop();
82
+ this.servers.delete(name);
83
+ }
84
+ else {
85
+ console.warn(`MCP server "${name}" not found.`);
86
+ }
87
+ }
88
+ };
89
+ exports.MCPServerManagerImpl = MCPServerManagerImpl;
90
+ exports.MCPServerManagerImpl = MCPServerManagerImpl = tslib_1.__decorate([
91
+ (0, inversify_1.injectable)()
92
+ ], MCPServerManagerImpl);
93
+ //# sourceMappingURL=mcp-server-manager-impl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-server-manager-impl.js","sourceRoot":"","sources":["../../src/node/mcp-server-manager-impl.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,4DAA0D;AAE1D,6CAAyC;AAGlC,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAA1B;QAEO,YAAO,GAA2B,IAAI,GAAG,EAAE,CAAC;IAsE1D,CAAC;IApEG,KAAK,CAAC,UAAU,CAAC,UAAkB;QAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAC5C,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,eAAe,UAAU,cAAc,CAAC,CAAC;QAC7D,CAAC;QACD,MAAM,CAAC,IAAI,EAAE,CAAC;QACd,OAAO,CAAC,GAAG,CAAC,eAAe,UAAU,YAAY,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,iBAAiB;QACnB,M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;QACD,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC;IAE7B,CAAC;IAED,iBAAiB,CAAC,WAAiC;QAC/C,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,WAAW,CAAC;QACjD,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAE9C,IAAI,cAAc,EAAE,CAAC;YACjB,cAAc,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;QAC9C,CAAC;aAAM,CAAC;YACJ,MAAM,SAAS,GAAG,IAAI,sBAAS,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;YAC1D,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QACtC,CAAC;IACL,CAAC;IAED,YAAY,CAAC,IAAY;QACrB,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,MAAM,EAAE,CAAC;YACT,MAAM,CAAC,IAAI,EAAE,CAAC;YACd,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9B,CAAC;aAAM,CAAC;YACJ,OAAO,CAAC,IAAI,CAAC,eAAe,IAAI,cAAc,CAAC,CAAC;QACpD,CAAC;IACL,CAAC;CACJ,CAAA;AAxEY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,sBAAU,GAAE;GACA,oBAAoB,CAwEhC"}
@@ -0,0 +1,19 @@
1
+ import { Client } from '@modelcontextprotocol/sdk/client/index.js';
2
+ export declare class MCPServer {
3
+ private name;
4
+ private command;
5
+ private args?;
6
+ private client;
7
+ private env?;
8
+ private started;
9
+ constructor(name: string, command: string, args?: string[], env?: Record<string, string>);
10
+ isStarted(): boolean;
11
+ start(): Promise<void>;
12
+ callTool(toolName: string, arg_string: string): ReturnType<Client['callTool']>;
13
+ getTools(): ReturnType<Client['listTools']>;
14
+ update(command: string, args?: string[], env?: {
15
+ [key: string]: string;
16
+ }): void;
17
+ stop(): void;
18
+ }
19
+ //# sourceMappingURL=mcp-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../../src/node/mcp-server.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAEnE,qBAAa,SAAS;IAClB,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,IAAI,CAAC,CAAW;IACxB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,GAAG,CAAC,CAA4B;IACxC,OAAO,CAAC,OAAO,CAAkB;gBAErB,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAOxF,SAAS,IAAI,OAAO;IAId,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAqCtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAkB9E,QAAQ,IAAI,UAAU,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAIjD,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,IAAI;IAM/E,IAAI,IAAI,IAAI;CAQf"}
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MCPServer = void 0;
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
+ const stdio_1 = require("@modelcontextprotocol/sdk/client/stdio");
20
+ const index_js_1 = require("@modelcontextprotocol/sdk/client/index.js");
21
+ class MCPServer {
22
+ constructor(name, command, args, env) {
23
+ this.started = false;
24
+ this.name = name;
25
+ this.command = command;
26
+ this.args = args;
27
+ this.env = env;
28
+ }
29
+ isStarted() {
30
+ return this.started;
31
+ }
32
+ async start() {
33
+ var _a;
34
+ if (this.started) {
35
+ return;
36
+ }
37
+ console.log(`Starting server "${this.name}" with command: ${this.command} and args: ${(_a = this.args) === null || _a === void 0 ? void 0 : _a.join(' ')} and env: ${JSON.stringify(this.env)}`);
38
+ // Filter process.env to exclude undefined values
39
+ const sanitizedEnv = Object.fromEntries(Object.entries(process.env).filter((entry) => entry[1] !== undefined));
40
+ const mergedEnv = {
41
+ ...sanitizedEnv,
42
+ ...(this.env || {})
43
+ };
44
+ const transport = new stdio_1.StdioClientTransport({
45
+ command: this.command,
46
+ args: this.args,
47
+ env: mergedEnv,
48
+ });
49
+ transport.onerror = error => {
50
+ console.error('Error: ' + error);
51
+ };
52
+ this.client = new index_js_1.Client({
53
+ name: 'theia-client',
54
+ version: '1.0.0',
55
+ }, {
56
+ capabilities: {}
57
+ });
58
+ this.client.onerror = error => {
59
+ console.error('Error in MCP client: ' + error);
60
+ };
61
+ await this.client.connect(transport);
62
+ this.started = true;
63
+ }
64
+ async callTool(toolName, arg_string) {
65
+ let args;
66
+ try {
67
+ args = JSON.parse(arg_string);
68
+ }
69
+ catch (error) {
70
+ console.error(`Failed to parse arguments for calling tool "${toolName}" in MCP server "${this.name}" with command "${this.command}".
71
+ Invalid JSON: ${arg_string}`, error);
72
+ }
73
+ const params = {
74
+ name: toolName,
75
+ arguments: args,
76
+ };
77
+ return this.client.callTool(params);
78
+ }
79
+ async getTools() {
80
+ return this.client.listTools();
81
+ }
82
+ update(command, args, env) {
83
+ this.command = command;
84
+ this.args = args;
85
+ this.env = env;
86
+ }
87
+ stop() {
88
+ if (!this.started || !this.client) {
89
+ return;
90
+ }
91
+ console.log(`Stopping MCP server "${this.name}"`);
92
+ this.client.close();
93
+ this.started = false;
94
+ }
95
+ }
96
+ exports.MCPServer = MCPServer;
97
+ //# sourceMappingURL=mcp-server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-server.js","sourceRoot":"","sources":["../../src/node/mcp-server.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,kEAA8E;AAC9E,wEAAmE;AAEnE,MAAa,SAAS;IAQlB,YAAY,IAAY,EAAE,OAAe,EAAE,IAAe,EAAE,GAA4B;QAFhF,YAAO,GAAY,KAAK,CAAC;QAG7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACnB,CAAC;IAED,SAAS;QACL,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,KAAK;;QACP,IAAI,IAAI,CAAC,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oot":"","sources":["../src/package.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 EclipseSource GmbH and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+ /* note: this bogus test file is required so that
17
+ we are able to run mocha unit tests on this
18
+ package, without having any actual unit tests in it.
19
+ This way a coverage report will be generated,
20
+ showing 0% coverage, instead of no report.
21
+ This file can be removed once we have real unit
22
+ tests in place. */
23
+ describe('ai-mcp package', () => {
24
+ it('support code coverage statistics', () => true);
25
+ });
26
+ //# sourceMappingURL=package.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.spec.js","sourceRoot":"","sources":["../src/package.spec.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,oDAAoD;AACpD,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;;;;;;qBAMqB;AAErB,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAE5B,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;AACvD,CAAC,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@theia/ai-mcp",
3
+ "version": "1.57.0-next.37+4e3b183da",
4
+ "description": "Theia - MCP Integration",
5
+ "dependencies": {
6
+ "@modelcontextprotocol/sdk": "1.0.1",
7
+ "@theia/ai-core": "1.57.0-next.37+4e3b183da",
8
+ "@theia/core": "1.57.0-next.37+4e3b183da"
9
+ },
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "theiaExtensions": [
14
+ {
15
+ "frontend": "lib/browser/mcp-frontend-module",
16
+ "backend": "lib/node/mcp-backend-module"
17
+ }
18
+ ],
19
+ "keywords": [
20
+ "theia-extension"
21
+ ],
22
+ "license": "EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/eclipse-theia/theia.git"
26
+ },
27
+ "bugs": {
28
+ "url": "https://github.com/eclipse-theia/theia/issues"
29
+ },
30
+ "homepage": "https://github.com/eclipse-theia/theia",
31
+ "files": [
32
+ "lib",
33
+ "src"
34
+ ],
35
+ "scripts": {
36
+ "build": "theiaext build",
37
+ "clean": "theiaext clean",
38
+ "compile": "theiaext compile",
39
+ "lint": "theiaext lint",
40
+ "test": "theiaext test",
41
+ "watch": "theiaext watch"
42
+ },
43
+ "devDependencies": {
44
+ "@theia/ext-scripts": "1.57.0"
45
+ },
46
+ "nyc": {
47
+ "extends": "../../configs/nyc.json"
48
+ },
49
+ "gitHead": "4e3b183daab034ae86eaa610421d4d9791ffdaa5"
50
+ }
@@ -0,0 +1,142 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 EclipseSource GmbH.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+ import { AICommandHandlerFactory } from '@theia/ai-core/lib/browser/ai-command-handler-factory';
17
+ import { CommandContribution, CommandRegistry, MessageService } from '@theia/core';
18
+ import { QuickInputService } from '@theia/core/lib/browser';
19
+ import { inject, injectable } from '@theia/core/shared/inversify';
20
+ import { MCPServerManager } from '../common/mcp-server-manager';
21
+ import { ToolInvocationRegistry, ToolRequest } from '@theia/ai-core';
22
+
23
+ type MCPTool = Awaited<ReturnType<MCPServerManager['getTools']>>['tools'][number];
24
+
25
+ export const StartMCPServer = {
26
+ id: 'mcp.startserver',
27
+ label: 'MCP: Start MCP Server',
28
+ };
29
+ export const StopMCPServer = {
30
+ id: 'mcp.stopserver',
31
+ label: 'MCP: Stop MCP Server',
32
+ };
33
+
34
+ @injectable()
35
+ export class MCPCommandContribution implements CommandContribution {
36
+ @inject(AICommandHandlerFactory)
37
+ protected readonly commandHandlerFactory: AICommandHandlerFactory;
38
+
39
+ @inject(QuickInputService)
40
+ protected readonly quickInputService: QuickInputService;
41
+
42
+ @inject(MessageService)
43
+ protected messageService: MessageService;
44
+
45
+ @inject(MCPServerManager)
46
+ protected readonly mcpServerManager: MCPServerManager;
47
+
48
+ @inject(ToolInvocationRegistry)
49
+ protected readonly toolInvocationRegistry: ToolInvocationRegistry;
50
+
51
+ private async getMCPServerSelection(serverNames: string[]): Promise<string | undefined> {
52
+ if (!serverNames || serverNames.length === 0) {
53
+ return undefined;
54
+ }
55
+ const options = serverNames.map(mcpServerName => ({ label: mcpServerName }));
56
+ const result = await this.quickInputService.showQuickPick(options);
57
+ return result?.label;
58
+ }
59
+
60
+ registerCommands(commandRegistry: CommandRegistry): void {
61
+ commandRegistry.registerCommand(StopMCPServer, this.commandHandlerFactory({
62
+ execute: async () => {
63
+ try {
64
+ const startedServers = await this.mcpServerManager.getStartedServers();
65
+ if (!startedServers || startedServers.length === 0) {
66
+ this.messageService.error('No MCP servers running.');
67
+ return;
68
+ }
69
+ const selection = await this.getMCPServerSelection(startedServers);
70
+ if (!selection) {
71
+ return;
72
+ }
73
+ this.toolInvocationRegistry.unregisterAllTools(`mcp_${selection}`);
74
+ this.mcpServerManager.stopServer(selection);
75
+ } catch (error) {
76
+ console.error('Error while stopping MCP server:', error);
77
+ }
78
+ }
79
+ }));
80
+
81
+ commandRegistry.registerCommand(StartMCPServer, this.commandHandlerFactory({
82
+ execute: async () => {
83
+ try {
84
+ const servers = await this.mcpServerManager.getServerNames();
85
+ const startedServers = await this.mcpServerManager.getStartedServers();
86
+ const startableServers = servers.filter(server => !startedServers.includes(server));
87
+ if (!startableServers || startableServers.length === 0) {
88
+ if (startedServers && startedServers.length > 0) {
89
+ this.messageService.error('All MCP servers are already running.');
90
+ } else {
91
+ this.messageService.error('No MCP servers configured.');
92
+ }
93
+ return;
94
+ }
95
+
96
+ const selection = await this.getMCPServerSelection(startableServers);
97
+ if (!selection) {
98
+ return;
99
+ }
100
+ this.mcpServerManager.startServer(selection);
101
+ const { tools } = await this.mcpServerManager.getTools(selection);
102
+ const toolRequests: ToolRequest[] = tools.map(tool => this.convertToToolRequest(tool, selection));
103
+
104
+ for (const toolRequest of toolRequests) {
105
+ this.toolInvocationRegistry.registerTool(toolRequest);
106
+ }
107
+ const toolNames = tools.map(tool => tool.name || 'Unnamed Tool').join(', ');
108
+ this.messageService.info(
109
+ `MCP server "${selection}" successfully started. Registered tools: ${toolNames || 'No tools available.'}`
110
+ );
111
+ } catch (error) {
112
+ this.messageService.error('An error occurred while starting the MCP server.');
113
+ console.error('Error while starting MCP server:', error);
114
+ }
115
+ }
116
+ }));
117
+ }
118
+
119
+ convertToToolRequest(tool: MCPTool, serverName: string): ToolRequest {
120
+ const id = `mcp_${serverName}_${tool.name}`;
121
+
122
+ return {
123
+ id: id,
124
+ name: id,
125
+ providerName: `mcp_${serverName}`,
126
+ parameters: ToolRequest.isToolRequestParameters(tool.inputSchema) ? {
127
+ type: tool.inputSchema.type,
128
+ properties: tool.inputSchema.properties,
129
+ } : undefined,
130
+ description: tool.description,
131
+ handler: async (arg_string: string) => {
132
+ try {
133
+ return await this.mcpServerManager.callTool(serverName, tool.name, arg_string);
134
+ } catch (error) {
135
+ console.error(`Error in tool handler for ${tool.name} on MCP server ${serverName}:`, error);
136
+ throw error;
137
+ }
138
+ },
139
+ };
140
+ }
141
+
142
+ }