@theia/ai-mcp 1.64.0-next.28 → 1.64.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/README.md +11 -34
- package/lib/browser/mcp-frontend-module.d.ts.map +1 -1
- package/lib/browser/mcp-frontend-module.js +0 -5
- package/lib/browser/mcp-frontend-module.js.map +1 -1
- package/package.json +6 -5
- package/src/browser/mcp-frontend-module.ts +1 -6
- package/lib/browser/mcp-command-contribution.d.ts +0 -21
- package/lib/browser/mcp-command-contribution.d.ts.map +0 -1
- package/lib/browser/mcp-command-contribution.js +0 -128
- package/lib/browser/mcp-command-contribution.js.map +0 -1
- package/src/browser/mcp-command-contribution.ts +0 -120
package/README.md
CHANGED
|
@@ -3,48 +3,21 @@
|
|
|
3
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
4
|
|
|
5
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
6
|
|
|
10
|
-
|
|
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:**
|
|
7
|
+
- Offers the framework to add/remove and start/stop MCP servers
|
|
8
|
+
- Use tool functions provided by MCP servers in prompt templates
|
|
27
9
|
|
|
28
|
-
|
|
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.
|
|
10
|
+
## Commands
|
|
36
11
|
|
|
37
|
-
|
|
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
|
|
12
|
+
- Include `@theia/ai-mcp-ui` to gain access to the start and stop MCP sever commands.
|
|
41
13
|
|
|
42
14
|
## Configuration
|
|
43
15
|
|
|
44
|
-
To configure MCP servers,
|
|
16
|
+
To configure MCP servers, include `@theia/mcp-ui` or `bind` the included `mcp-preferences`.
|
|
45
17
|
|
|
46
|
-
|
|
18
|
+
Afterwards, open the preferences and add entries to the `MCP Servers Configuration` section. Each server requires a unique identifier (e.g., `"brave-search"` or `"filesystem"`) and configuration details such as the command, arguments, optional environment variables, and autostart (true by default).
|
|
47
19
|
|
|
20
|
+
`"autostart"` (true by default) will automatically start the respective MCP server whenever you restart your Theia application. In your current session, however, you'll still need to **manually start it** using the `"MCP: Start MCP Server"` command.
|
|
48
21
|
|
|
49
22
|
Example Configuration:
|
|
50
23
|
|
|
@@ -99,15 +72,19 @@ Example Configuration:
|
|
|
99
72
|
```
|
|
100
73
|
|
|
101
74
|
Example prompt (for search)
|
|
75
|
+
|
|
102
76
|
```md
|
|
103
77
|
~{mcp_brave-search_brave_web_search}
|
|
104
78
|
```
|
|
105
79
|
|
|
106
80
|
Example User query
|
|
81
|
+
|
|
107
82
|
```md
|
|
108
83
|
Search the internet for XYZ
|
|
109
84
|
```
|
|
110
85
|
|
|
111
86
|
## More Information
|
|
87
|
+
|
|
88
|
+
[Theia AI MCP UI README](https://github.com/eclipse-theia/theia/tree/master/packages/ai-mcp-ui)
|
|
112
89
|
[User documentation on MCP in the Theia IDE](https://theia-ide.org/docs/user_ai/#mcp-integration)
|
|
113
90
|
[List of available MCP servers](https://github.com/modelcontextprotocol/servers)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-frontend-module.d.ts","sourceRoot":"","sources":["../../src/browser/mcp-frontend-module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mcp-frontend-module.d.ts","sourceRoot":"","sources":["../../src/browser/mcp-frontend-module.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;;AAO/D,wBASG"}
|
|
@@ -15,19 +15,14 @@
|
|
|
15
15
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
16
|
// *****************************************************************************
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
const core_1 = require("@theia/core");
|
|
19
18
|
const inversify_1 = require("@theia/core/shared/inversify");
|
|
20
|
-
const mcp_command_contribution_1 = require("./mcp-command-contribution");
|
|
21
19
|
const browser_1 = require("@theia/core/lib/browser");
|
|
22
20
|
const mcp_server_manager_1 = require("../common/mcp-server-manager");
|
|
23
|
-
const mcp_preferences_1 = require("./mcp-preferences");
|
|
24
21
|
const mcp_frontend_application_contribution_1 = require("./mcp-frontend-application-contribution");
|
|
25
22
|
const mcp_frontend_service_1 = require("./mcp-frontend-service");
|
|
26
23
|
const mcp_frontend_notification_service_1 = require("./mcp-frontend-notification-service");
|
|
27
24
|
exports.default = new inversify_1.ContainerModule(bind => {
|
|
28
|
-
bind(browser_1.PreferenceContribution).toConstantValue({ schema: mcp_preferences_1.McpServersPreferenceSchema });
|
|
29
25
|
bind(browser_1.FrontendApplicationContribution).to(mcp_frontend_application_contribution_1.McpFrontendApplicationContribution).inSingletonScope();
|
|
30
|
-
bind(core_1.CommandContribution).to(mcp_command_contribution_1.MCPCommandContribution);
|
|
31
26
|
bind(mcp_server_manager_1.MCPFrontendService).to(mcp_frontend_service_1.MCPFrontendServiceImpl).inSingletonScope();
|
|
32
27
|
bind(mcp_server_manager_1.MCPFrontendNotificationService).to(mcp_frontend_notification_service_1.MCPFrontendNotificationServiceImpl).inSingletonScope();
|
|
33
28
|
bind(mcp_server_manager_1.MCPServerManager).toDynamicValue(ctx => {
|
|
@@ -1 +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,
|
|
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,4DAA+D;AAC/D,qDAA+H;AAC/H,qEAA0I;AAC1I,mGAA6F;AAC7F,iEAAgE;AAChE,2FAAyF;AAEzF,kBAAe,IAAI,2BAAe,CAAC,IAAI,CAAC,EAAE;IACtC,IAAI,CAAC,yCAA+B,CAAC,CAAC,EAAE,CAAC,0EAAkC,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAChG,IAAI,CAAC,uCAAkB,CAAC,CAAC,EAAE,CAAC,6CAAsB,CAAC,CAAC,gBAAgB,EAAE,CAAC;IACvE,IAAI,CAAC,mDAA8B,CAAC,CAAC,EAAE,CAAC,sEAAkC,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAC/F,IAAI,CAAC,qCAAgB,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;QACxC,MAAM,UAAU,GAAG,GAAG,CAAC,SAAS,CAAC,GAAG,CAA4B,kCAAwB,CAAC,CAAC;QAC1F,MAAM,MAAM,GAAG,GAAG,CAAC,SAAS,CAAC,GAAG,CAAiC,mDAA8B,CAAC,CAAC;QACjG,OAAO,UAAU,CAAC,WAAW,CAAmB,yCAAoB,EAAE,MAAM,CAAC,CAAC;IAClF,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC;AAC1B,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/ai-mcp",
|
|
3
|
-
"version": "1.64.0
|
|
3
|
+
"version": "1.64.0",
|
|
4
4
|
"description": "Theia - MCP Integration",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@modelcontextprotocol/sdk": "^1.15.1",
|
|
7
|
-
"@theia/ai-core": "1.64.0
|
|
8
|
-
"@theia/core": "1.64.0
|
|
7
|
+
"@theia/ai-core": "1.64.0",
|
|
8
|
+
"@theia/core": "1.64.0"
|
|
9
9
|
},
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
|
+
"main": "lib/common",
|
|
13
14
|
"theiaExtensions": [
|
|
14
15
|
{
|
|
15
16
|
"frontend": "lib/browser/mcp-frontend-module",
|
|
@@ -41,10 +42,10 @@
|
|
|
41
42
|
"watch": "theiaext watch"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
|
-
"@theia/ext-scripts": "1.
|
|
45
|
+
"@theia/ext-scripts": "1.64.0"
|
|
45
46
|
},
|
|
46
47
|
"nyc": {
|
|
47
48
|
"extends": "../../configs/nyc.json"
|
|
48
49
|
},
|
|
49
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "4c074e0d16c48e96a044b2f8bc4717de2e031c4b"
|
|
50
51
|
}
|
|
@@ -14,20 +14,15 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
-
import { CommandContribution } from '@theia/core';
|
|
18
17
|
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
19
|
-
import {
|
|
20
|
-
import { FrontendApplicationContribution, PreferenceContribution, RemoteConnectionProvider, ServiceConnectionProvider } from '@theia/core/lib/browser';
|
|
18
|
+
import { FrontendApplicationContribution, RemoteConnectionProvider, ServiceConnectionProvider } from '@theia/core/lib/browser';
|
|
21
19
|
import { MCPFrontendService, MCPServerManager, MCPServerManagerPath, MCPFrontendNotificationService } from '../common/mcp-server-manager';
|
|
22
|
-
import { McpServersPreferenceSchema } from './mcp-preferences';
|
|
23
20
|
import { McpFrontendApplicationContribution } from './mcp-frontend-application-contribution';
|
|
24
21
|
import { MCPFrontendServiceImpl } from './mcp-frontend-service';
|
|
25
22
|
import { MCPFrontendNotificationServiceImpl } from './mcp-frontend-notification-service';
|
|
26
23
|
|
|
27
24
|
export default new ContainerModule(bind => {
|
|
28
|
-
bind(PreferenceContribution).toConstantValue({ schema: McpServersPreferenceSchema });
|
|
29
25
|
bind(FrontendApplicationContribution).to(McpFrontendApplicationContribution).inSingletonScope();
|
|
30
|
-
bind(CommandContribution).to(MCPCommandContribution);
|
|
31
26
|
bind(MCPFrontendService).to(MCPFrontendServiceImpl).inSingletonScope();
|
|
32
27
|
bind(MCPFrontendNotificationService).to(MCPFrontendNotificationServiceImpl).inSingletonScope();
|
|
33
28
|
bind(MCPServerManager).toDynamicValue(ctx => {
|
|
@@ -1,21 +0,0 @@
|
|
|
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 { MCPFrontendService } from '../common/mcp-server-manager';
|
|
5
|
-
export declare const StartMCPServer: {
|
|
6
|
-
id: string;
|
|
7
|
-
label: string;
|
|
8
|
-
};
|
|
9
|
-
export declare const StopMCPServer: {
|
|
10
|
-
id: string;
|
|
11
|
-
label: string;
|
|
12
|
-
};
|
|
13
|
-
export declare class MCPCommandContribution implements CommandContribution {
|
|
14
|
-
protected readonly commandHandlerFactory: AICommandHandlerFactory;
|
|
15
|
-
protected readonly quickInputService: QuickInputService;
|
|
16
|
-
protected messageService: MessageService;
|
|
17
|
-
protected readonly mcpFrontendService: MCPFrontendService;
|
|
18
|
-
private getMCPServerSelection;
|
|
19
|
-
registerCommands(commandRegistry: CommandRegistry): void;
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=mcp-command-contribution.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,EAAO,MAAM,aAAa,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,kBAAkB,EAAmB,MAAM,8BAA8B,CAAC;AAEnF,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,kBAAkB,EAAE,kBAAkB,CAAC;YAE5C,qBAAqB;IASnC,gBAAgB,CAAC,eAAe,EAAE,eAAe,GAAG,IAAI;CAkE3D"}
|
|
@@ -1,128 +0,0 @@
|
|
|
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
|
-
exports.StartMCPServer = {
|
|
26
|
-
id: 'mcp.startserver',
|
|
27
|
-
label: core_1.nls.localize('theia/ai/mcp/start/label', 'MCP: Start MCP Server'),
|
|
28
|
-
};
|
|
29
|
-
exports.StopMCPServer = {
|
|
30
|
-
id: 'mcp.stopserver',
|
|
31
|
-
label: core_1.nls.localize('theia/ai/mcp/stop/label', 'MCP: Stop MCP Server'),
|
|
32
|
-
};
|
|
33
|
-
let MCPCommandContribution = class MCPCommandContribution {
|
|
34
|
-
async getMCPServerSelection(serverNames) {
|
|
35
|
-
if (!serverNames || serverNames.length === 0) {
|
|
36
|
-
return undefined;
|
|
37
|
-
}
|
|
38
|
-
const options = serverNames.map(mcpServerName => ({ label: mcpServerName }));
|
|
39
|
-
const result = await this.quickInputService.showQuickPick(options);
|
|
40
|
-
return result === null || result === void 0 ? void 0 : result.label;
|
|
41
|
-
}
|
|
42
|
-
registerCommands(commandRegistry) {
|
|
43
|
-
commandRegistry.registerCommand(exports.StopMCPServer, this.commandHandlerFactory({
|
|
44
|
-
execute: async () => {
|
|
45
|
-
try {
|
|
46
|
-
const startedServers = await this.mcpFrontendService.getStartedServers();
|
|
47
|
-
if (!startedServers || startedServers.length === 0) {
|
|
48
|
-
this.messageService.error(core_1.nls.localize('theia/ai/mcp/error/noRunningServers', 'No MCP servers running.'));
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
const selection = await this.getMCPServerSelection(startedServers);
|
|
52
|
-
if (!selection) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
await this.mcpFrontendService.stopServer(selection);
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
console.error('Error while stopping MCP server:', error);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}));
|
|
62
|
-
commandRegistry.registerCommand(exports.StartMCPServer, this.commandHandlerFactory({
|
|
63
|
-
execute: async () => {
|
|
64
|
-
try {
|
|
65
|
-
const servers = await this.mcpFrontendService.getServerNames();
|
|
66
|
-
const startedServers = await this.mcpFrontendService.getStartedServers();
|
|
67
|
-
const startableServers = servers.filter(server => !startedServers.includes(server));
|
|
68
|
-
if (!startableServers || startableServers.length === 0) {
|
|
69
|
-
if (startedServers && startedServers.length > 0) {
|
|
70
|
-
this.messageService.error(core_1.nls.localize('theia/ai/mcp/error/allServersRunning', 'All MCP servers are already running.'));
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
this.messageService.error(core_1.nls.localize('theia/ai/mcp/error/noServersConfigured', 'No MCP servers configured.'));
|
|
74
|
-
}
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
const selection = await this.getMCPServerSelection(startableServers);
|
|
78
|
-
if (!selection) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
await this.mcpFrontendService.startServer(selection);
|
|
82
|
-
const serverDescription = await this.mcpFrontendService.getServerDescription(selection);
|
|
83
|
-
if (serverDescription && serverDescription.status) {
|
|
84
|
-
if (serverDescription.status === mcp_server_manager_1.MCPServerStatus.Running
|
|
85
|
-
|| serverDescription.status === mcp_server_manager_1.MCPServerStatus.Connected) {
|
|
86
|
-
let toolNames = undefined;
|
|
87
|
-
if (serverDescription.tools) {
|
|
88
|
-
toolNames = serverDescription.tools.map(tool => tool.name).join(',');
|
|
89
|
-
}
|
|
90
|
-
this.messageService.info(core_1.nls.localize('theia/ai/mcp/info/serverStarted', 'MCP server "{0}" successfully started. Registered tools: {1}', selection, toolNames ||
|
|
91
|
-
core_1.nls.localize('theia/ai/mcp/tool/noTools', 'No tools available.')));
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
if (serverDescription.error) {
|
|
95
|
-
console.error('Error while starting MCP server:', serverDescription.error);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
this.messageService.error(core_1.nls.localize('theia/ai/mcp/error/startFailed', 'An error occurred while starting the MCP server.'));
|
|
99
|
-
}
|
|
100
|
-
catch (error) {
|
|
101
|
-
this.messageService.error(core_1.nls.localize('theia/ai/mcp/error/startFailed', 'An error occurred while starting the MCP server.'));
|
|
102
|
-
console.error('Error while starting MCP server:', error);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}));
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
exports.MCPCommandContribution = MCPCommandContribution;
|
|
109
|
-
tslib_1.__decorate([
|
|
110
|
-
(0, inversify_1.inject)(ai_command_handler_factory_1.AICommandHandlerFactory),
|
|
111
|
-
tslib_1.__metadata("design:type", Function)
|
|
112
|
-
], MCPCommandContribution.prototype, "commandHandlerFactory", void 0);
|
|
113
|
-
tslib_1.__decorate([
|
|
114
|
-
(0, inversify_1.inject)(browser_1.QuickInputService),
|
|
115
|
-
tslib_1.__metadata("design:type", Object)
|
|
116
|
-
], MCPCommandContribution.prototype, "quickInputService", void 0);
|
|
117
|
-
tslib_1.__decorate([
|
|
118
|
-
(0, inversify_1.inject)(core_1.MessageService),
|
|
119
|
-
tslib_1.__metadata("design:type", core_1.MessageService)
|
|
120
|
-
], MCPCommandContribution.prototype, "messageService", void 0);
|
|
121
|
-
tslib_1.__decorate([
|
|
122
|
-
(0, inversify_1.inject)(mcp_server_manager_1.MCPFrontendService),
|
|
123
|
-
tslib_1.__metadata("design:type", Object)
|
|
124
|
-
], MCPCommandContribution.prototype, "mcpFrontendService", void 0);
|
|
125
|
-
exports.MCPCommandContribution = MCPCommandContribution = tslib_1.__decorate([
|
|
126
|
-
(0, inversify_1.injectable)()
|
|
127
|
-
], MCPCommandContribution);
|
|
128
|
-
//# sourceMappingURL=mcp-command-contribution.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,sCAAwF;AACxF,qDAA4D;AAC5D,4DAAkE;AAClE,qEAAmF;AAEtE,QAAA,cAAc,GAAG;IAC1B,EAAE,EAAE,iBAAiB;IACrB,KAAK,EAAE,UAAG,CAAC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C,kCAAkC,EAAE,KAAK,CAAC,CAAC;gBAC7D,CAAC;YACL,CAAC;SACJ,CAAC,CAAC,CAAC;IACR,CAAC;CACJ,CAAA;AAxFY,wDAAsB;AAEZ;IADlB,IAAA,kBAAM,EAAC,oDAAuB,CAAC;;qEACkC;AAG/C;IADlB,IAAA,kBAAM,EAAC,2BAAiB,CAAC;;iEAC8B;AAG9C;IADT,IAAA,kBAAM,EAAC,qBAAc,CAAC;sCACG,qBAAc;8DAAC;AAGtB;IADlB,IAAA,kBAAM,EAAC,uCAAkB,CAAC;;kEAC+B;iCAXjD,sBAAsB;IADlC,IAAA,sBAAU,GAAE;GACA,sBAAsB,CAwFlC"}
|
|
@@ -1,120 +0,0 @@
|
|
|
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, nls } from '@theia/core';
|
|
18
|
-
import { QuickInputService } from '@theia/core/lib/browser';
|
|
19
|
-
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
20
|
-
import { MCPFrontendService, MCPServerStatus } from '../common/mcp-server-manager';
|
|
21
|
-
|
|
22
|
-
export const StartMCPServer = {
|
|
23
|
-
id: 'mcp.startserver',
|
|
24
|
-
label: nls.localize('theia/ai/mcp/start/label', 'MCP: Start MCP Server'),
|
|
25
|
-
};
|
|
26
|
-
export const StopMCPServer = {
|
|
27
|
-
id: 'mcp.stopserver',
|
|
28
|
-
label: nls.localize('theia/ai/mcp/stop/label', 'MCP: Stop MCP Server'),
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
@injectable()
|
|
32
|
-
export class MCPCommandContribution implements CommandContribution {
|
|
33
|
-
@inject(AICommandHandlerFactory)
|
|
34
|
-
protected readonly commandHandlerFactory: AICommandHandlerFactory;
|
|
35
|
-
|
|
36
|
-
@inject(QuickInputService)
|
|
37
|
-
protected readonly quickInputService: QuickInputService;
|
|
38
|
-
|
|
39
|
-
@inject(MessageService)
|
|
40
|
-
protected messageService: MessageService;
|
|
41
|
-
|
|
42
|
-
@inject(MCPFrontendService)
|
|
43
|
-
protected readonly mcpFrontendService: MCPFrontendService;
|
|
44
|
-
|
|
45
|
-
private async getMCPServerSelection(serverNames: string[]): Promise<string | undefined> {
|
|
46
|
-
if (!serverNames || serverNames.length === 0) {
|
|
47
|
-
return undefined;
|
|
48
|
-
}
|
|
49
|
-
const options = serverNames.map(mcpServerName => ({ label: mcpServerName }));
|
|
50
|
-
const result = await this.quickInputService.showQuickPick(options);
|
|
51
|
-
return result?.label;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
registerCommands(commandRegistry: CommandRegistry): void {
|
|
55
|
-
commandRegistry.registerCommand(StopMCPServer, this.commandHandlerFactory({
|
|
56
|
-
execute: async () => {
|
|
57
|
-
try {
|
|
58
|
-
const startedServers = await this.mcpFrontendService.getStartedServers();
|
|
59
|
-
if (!startedServers || startedServers.length === 0) {
|
|
60
|
-
this.messageService.error(nls.localize('theia/ai/mcp/error/noRunningServers', 'No MCP servers running.'));
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
const selection = await this.getMCPServerSelection(startedServers);
|
|
64
|
-
if (!selection) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
await this.mcpFrontendService.stopServer(selection);
|
|
68
|
-
} catch (error) {
|
|
69
|
-
console.error('Error while stopping MCP server:', error);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}));
|
|
73
|
-
|
|
74
|
-
commandRegistry.registerCommand(StartMCPServer, this.commandHandlerFactory({
|
|
75
|
-
execute: async () => {
|
|
76
|
-
try {
|
|
77
|
-
const servers = await this.mcpFrontendService.getServerNames();
|
|
78
|
-
const startedServers = await this.mcpFrontendService.getStartedServers();
|
|
79
|
-
const startableServers = servers.filter(server => !startedServers.includes(server));
|
|
80
|
-
if (!startableServers || startableServers.length === 0) {
|
|
81
|
-
if (startedServers && startedServers.length > 0) {
|
|
82
|
-
this.messageService.error(nls.localize('theia/ai/mcp/error/allServersRunning', 'All MCP servers are already running.'));
|
|
83
|
-
} else {
|
|
84
|
-
this.messageService.error(nls.localize('theia/ai/mcp/error/noServersConfigured', 'No MCP servers configured.'));
|
|
85
|
-
}
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const selection = await this.getMCPServerSelection(startableServers);
|
|
90
|
-
if (!selection) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
await this.mcpFrontendService.startServer(selection);
|
|
94
|
-
const serverDescription = await this.mcpFrontendService.getServerDescription(selection);
|
|
95
|
-
if (serverDescription && serverDescription.status) {
|
|
96
|
-
if (serverDescription.status === MCPServerStatus.Running
|
|
97
|
-
|| serverDescription.status === MCPServerStatus.Connected) {
|
|
98
|
-
let toolNames: string | undefined = undefined;
|
|
99
|
-
if (serverDescription.tools) {
|
|
100
|
-
toolNames = serverDescription.tools.map(tool => tool.name).join(',');
|
|
101
|
-
}
|
|
102
|
-
this.messageService.info(
|
|
103
|
-
nls.localize('theia/ai/mcp/info/serverStarted', 'MCP server "{0}" successfully started. Registered tools: {1}', selection, toolNames ||
|
|
104
|
-
nls.localize('theia/ai/mcp/tool/noTools', 'No tools available.'))
|
|
105
|
-
);
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
if (serverDescription.error) {
|
|
109
|
-
console.error('Error while starting MCP server:', serverDescription.error);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
this.messageService.error(nls.localize('theia/ai/mcp/error/startFailed', 'An error occurred while starting the MCP server.'));
|
|
113
|
-
} catch (error) {
|
|
114
|
-
this.messageService.error(nls.localize('theia/ai/mcp/error/startFailed', 'An error occurred while starting the MCP server.'));
|
|
115
|
-
console.error('Error while starting MCP server:', error);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}));
|
|
119
|
-
}
|
|
120
|
-
}
|