@loop_ouroboros/mcp-hub-lite 1.1.0 → 1.2.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/CHANGELOG.md +141 -0
- package/README.md +74 -116
- package/dist/client/assets/{HomeView-Bu2joUvW.js → HomeView-BBwvy1oj.js} +1 -1
- package/dist/client/assets/{ResourceDetailView-BvrhDCD1.js → ResourceDetailView-CZ2aB73w.js} +1 -1
- package/dist/client/assets/{ResourcesView-LjqioF_s.js → ResourcesView-CN1NlhWs.js} +1 -1
- package/dist/client/assets/{ServerDashboard-FhHJFvUi.js → ServerDashboard-k652Vw4Z.js} +1 -1
- package/dist/client/assets/{ServerDetail-BKV-M4qT.js → ServerDetail-BLQ-a4cO.js} +1 -1
- package/dist/client/assets/{ServerListView-BXgtDyt3.js → ServerListView-BHrsFD5i.js} +4 -4
- package/dist/client/assets/{ServerStatusTags.vue_vue_type_script_setup_true_lang-D-ooYNdN.js → ServerStatusTags.vue_vue_type_script_setup_true_lang-BHhwEuGe.js} +1 -1
- package/dist/client/assets/{SettingsView-CMFG91Z4.js → SettingsView-CUOFNXrz.js} +1 -1
- package/dist/client/assets/{ToolCallDialog-Bf4Xe4gH.js → ToolCallDialog-BfPjLxfV.js} +1 -1
- package/dist/client/assets/ToolsView-BxgXvPC3.css +1 -0
- package/dist/client/assets/ToolsView-CyuhYAE2.js +1 -0
- package/dist/client/assets/{_baseClone-Bp9Rjwd7.js → _baseClone-DO5qfalW.js} +1 -1
- package/dist/client/assets/{el-form-item-DdSUWYsl.js → el-form-item-CcGsD2K_.js} +2 -2
- package/dist/client/assets/{el-input-99gMrutP.js → el-input-tYgeiaCT.js} +1 -1
- package/dist/client/assets/{el-loading-CIQ5pD5u.js → el-loading-Dwl9E_Vr.js} +1 -1
- package/dist/client/assets/{el-overlay-BVM6msGX.js → el-overlay-kqX_BABo.js} +1 -1
- package/dist/client/assets/{el-radio-group-DhXWy7ry.js → el-radio-group-D8aWBVOT.js} +1 -1
- package/dist/client/assets/el-skeleton-item-BRwIFspE.js +1 -0
- package/dist/client/assets/{el-switch-Bu8AQ5uM.js → el-switch-BF8c-xeU.js} +1 -1
- package/dist/client/assets/{el-tab-pane-BnGMaV56.js → el-tab-pane-C4Ep94cd.js} +1 -1
- package/dist/client/assets/{el-table-column-BMWOaLS_.js → el-table-column-Cog6uCh-.js} +1 -1
- package/dist/client/assets/{index-C2V-ZGji.js → index-ByNBhPAR.js} +1 -1
- package/dist/client/assets/index-CTB6oe-9.js +2 -0
- package/dist/client/assets/omit-CUnDT6sS.js +1 -0
- package/dist/client/assets/{raf-C2wXzaVU.js → raf-CmzeRPMd.js} +1 -1
- package/dist/client/assets/{vue-vendor-BLHLXXJK.js → vue-vendor-CbgVSHIh.js} +3 -3
- package/dist/client/index.html +2 -2
- package/dist/server/src/api/mcp/debug-response-wrapper.js +2 -2
- package/dist/server/src/api/mcp/gateway.d.ts.map +1 -1
- package/dist/server/src/api/mcp/gateway.js +17 -3
- package/dist/server/src/api/mcp/session-context-extractor.d.ts.map +1 -1
- package/dist/server/src/api/mcp/session-context-extractor.js +14 -5
- package/dist/server/src/cli/commands/mcp-tool-use.d.ts +62 -0
- package/dist/server/src/cli/commands/mcp-tool-use.d.ts.map +1 -0
- package/dist/server/src/cli/commands/mcp-tool-use.js +174 -0
- package/dist/server/src/cli/commands/server.d.ts +57 -0
- package/dist/server/src/cli/commands/server.d.ts.map +1 -0
- package/dist/server/src/cli/commands/server.js +169 -0
- package/dist/server/src/cli/commands/tool-use.d.ts +95 -0
- package/dist/server/src/cli/commands/tool-use.d.ts.map +1 -0
- package/dist/server/src/cli/commands/tool-use.js +255 -0
- package/dist/server/src/cli/index.d.ts +4 -2
- package/dist/server/src/cli/index.d.ts.map +1 -1
- package/dist/server/src/cli/index.js +35 -3
- package/dist/server/src/config/config-loader.js +1 -1
- package/dist/server/src/config/config-manager.js +1 -1
- package/dist/server/src/models/system-tools.constants.d.ts +2 -2
- package/dist/server/src/models/system-tools.constants.d.ts.map +1 -1
- package/dist/server/src/models/system-tools.constants.js +2 -2
- package/dist/server/src/services/connection/tool-cache.d.ts.map +1 -1
- package/dist/server/src/services/connection/tool-cache.js +3 -1
- package/dist/server/src/services/gateway/gateway.service.d.ts.map +1 -1
- package/dist/server/src/services/gateway/gateway.service.js +38 -4
- package/dist/server/src/services/gateway/global-transport.d.ts +14 -5
- package/dist/server/src/services/gateway/global-transport.d.ts.map +1 -1
- package/dist/server/src/services/gateway/global-transport.js +54 -30
- package/dist/server/src/services/gateway/request-handlers/initialize-handler.d.ts.map +1 -1
- package/dist/server/src/services/gateway/request-handlers/initialize-handler.js +12 -1
- package/dist/server/src/services/gateway/request-handlers/system-tools-handler.js +2 -2
- package/dist/server/src/services/gateway/request-handlers/tools-handler.d.ts.map +1 -1
- package/dist/server/src/services/gateway/request-handlers/tools-handler.js +3 -4
- package/dist/server/src/services/hub-tools/system-tool-definitions.d.ts +1 -0
- package/dist/server/src/services/hub-tools/system-tool-definitions.d.ts.map +1 -1
- package/dist/server/src/services/hub-tools/system-tool-definitions.js +4 -3
- package/dist/server/src/services/hub-tools.service.d.ts +3 -2
- package/dist/server/src/services/hub-tools.service.d.ts.map +1 -1
- package/dist/server/src/services/hub-tools.service.js +36 -19
- package/dist/server/src/services/search/search-core.service.d.ts +5 -5
- package/dist/server/src/services/search/search-core.service.js +11 -11
- package/dist/server/src/services/session/session-manager.d.ts +256 -12
- package/dist/server/src/services/session/session-manager.d.ts.map +1 -1
- package/dist/server/src/services/session/session-manager.js +585 -23
- package/dist/server/src/services/session-tracker.service.d.ts +10 -2
- package/dist/server/src/services/session-tracker.service.d.ts.map +1 -1
- package/dist/server/src/services/session-tracker.service.js +53 -2
- package/dist/server/src/services/system-tool-handler.js +2 -2
- package/dist/server/src/utils/index.d.ts +1 -0
- package/dist/server/src/utils/index.d.ts.map +1 -1
- package/dist/server/src/utils/index.js +1 -0
- package/dist/server/src/utils/name-converter.d.ts +17 -0
- package/dist/server/src/utils/name-converter.d.ts.map +1 -0
- package/dist/server/src/utils/name-converter.js +27 -0
- package/dist/server/src/utils/request-context.d.ts +18 -0
- package/dist/server/src/utils/request-context.d.ts.map +1 -1
- package/dist/server/src/utils/request-context.js +20 -0
- package/dist/server/tests/evaluation/evaluation.test.js +9 -10
- package/dist/server/tests/integration/api/gateway.test.js +2 -2
- package/dist/server/tests/unit/services/hub-tools.service.test.js +1 -1
- package/dist/server/tests/unit/utils/name-converter.test.d.ts +2 -0
- package/dist/server/tests/unit/utils/name-converter.test.d.ts.map +1 -0
- package/dist/server/tests/unit/utils/name-converter.test.js +69 -0
- package/dist/server/tests/unit/utils/request-context.test.js +24 -5
- package/package.json +3 -1
- package/dist/client/assets/ToolsView-DFpha1z0.js +0 -1
- package/dist/client/assets/ToolsView-E3Ps9c7i.css +0 -1
- package/dist/client/assets/el-skeleton-item-DJz-Us12.js +0 -1
- package/dist/client/assets/index-vhkqgpmN.js +0 -2
- package/dist/client/assets/omit-CqPQN3XP.js +0 -1
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* MCP transport factory for per-request transport instances.
|
|
3
3
|
*
|
|
4
|
-
* This module provides a
|
|
5
|
-
*
|
|
4
|
+
* This module provides a factory function to create isolated MCP transport and server instances
|
|
5
|
+
* for each HTTP request, ensuring proper state isolation between concurrent clients.
|
|
6
6
|
*/
|
|
7
7
|
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new MCP transport and server instance for a single request session.
|
|
10
|
+
* Each call returns isolated instances that should be cleaned up after the request completes.
|
|
11
|
+
*
|
|
12
|
+
* @returns {Promise<{ transport: StreamableHTTPServerTransport, server: import('@modelcontextprotocol/sdk/server/mcp.js').McpServer }>}
|
|
13
|
+
* Object containing the transport and server instances
|
|
14
|
+
*/
|
|
15
|
+
export declare function createSessionTransport(): Promise<{
|
|
16
|
+
transport: StreamableHTTPServerTransport;
|
|
17
|
+
server: import("@modelcontextprotocol/sdk/server/mcp").McpServer;
|
|
18
|
+
}>;
|
|
10
19
|
//# sourceMappingURL=global-transport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global-transport.d.ts","sourceRoot":"","sources":["../../../../../src/services/gateway/global-transport.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;
|
|
1
|
+
{"version":3,"file":"global-transport.d.ts","sourceRoot":"","sources":["../../../../../src/services/gateway/global-transport.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AAMnG;;;;;;GAMG;AACH,wBAAsB,sBAAsB;;;GA+D3C"}
|
|
@@ -1,42 +1,66 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* MCP transport factory for per-request transport instances.
|
|
3
3
|
*
|
|
4
|
-
* This module provides a
|
|
5
|
-
*
|
|
4
|
+
* This module provides a factory function to create isolated MCP transport and server instances
|
|
5
|
+
* for each HTTP request, ensuring proper state isolation between concurrent clients.
|
|
6
6
|
*/
|
|
7
7
|
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
8
8
|
import { gateway } from './gateway.service.js';
|
|
9
9
|
import { logger, LOG_MODULES } from '../../utils/logger/index.js';
|
|
10
|
-
import { getMcpCommDebugSetting } from '../../utils/json-utils.js';
|
|
10
|
+
import { stringifyForLogging, getMcpCommDebugSetting } from '../../utils/json-utils.js';
|
|
11
11
|
import { formatMcpMessageForLogging, logNotificationMessage } from '../../utils/logger/log-output.js';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
transport
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (getMcpCommDebugSetting()) {
|
|
26
|
-
const originalSend = transport.send;
|
|
27
|
-
transport.send = async (message, options) => {
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new MCP transport and server instance for a single request session.
|
|
14
|
+
* Each call returns isolated instances that should be cleaned up after the request completes.
|
|
15
|
+
*
|
|
16
|
+
* @returns {Promise<{ transport: StreamableHTTPServerTransport, server: import('@modelcontextprotocol/sdk/server/mcp.js').McpServer }>}
|
|
17
|
+
* Object containing the transport and server instances
|
|
18
|
+
*/
|
|
19
|
+
export async function createSessionTransport() {
|
|
20
|
+
const transport = new StreamableHTTPServerTransport();
|
|
21
|
+
const server = gateway.createConnectionServer();
|
|
22
|
+
// Set up message logging (use empty string for sessionId in per-request mode)
|
|
23
|
+
transport.onmessage = (message) => {
|
|
24
|
+
logger.debug(`Session transport onmessage called with: ${stringifyForLogging(message)}`, LOG_MODULES.GATEWAY);
|
|
28
25
|
try {
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
if (getMcpCommDebugSetting()) {
|
|
27
|
+
const logMessage = formatMcpMessageForLogging(message);
|
|
28
|
+
logger.debug(`MCP message received: ${logMessage}`, LOG_MODULES.COMMUNICATION);
|
|
29
|
+
}
|
|
30
|
+
logNotificationMessage(message, ''); // Empty sessionId for per-request
|
|
31
|
+
logger.debug(`Session transport onmessage completed successfully`, LOG_MODULES.GATEWAY);
|
|
31
32
|
}
|
|
32
|
-
catch {
|
|
33
|
-
|
|
33
|
+
catch (error) {
|
|
34
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
35
|
+
logger.error(`Error in session transport onmessage handler: ${errorMessage}`, LOG_MODULES.GATEWAY);
|
|
36
|
+
logger.error(`Message that caused error: ${stringifyForLogging(message)}`, LOG_MODULES.GATEWAY);
|
|
34
37
|
}
|
|
35
|
-
return await originalSend.call(transport, message, options);
|
|
36
38
|
};
|
|
39
|
+
// Wrap send method for debug logging
|
|
40
|
+
if (getMcpCommDebugSetting()) {
|
|
41
|
+
const originalSend = transport.send;
|
|
42
|
+
transport.send = async (message, options) => {
|
|
43
|
+
try {
|
|
44
|
+
const logMessage = formatMcpMessageForLogging(message);
|
|
45
|
+
logger.debug(`MCP message sent: ${logMessage}`, LOG_MODULES.COMMUNICATION);
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
logger.debug(`MCP message sent: [Error formatting response]`, LOG_MODULES.COMMUNICATION);
|
|
49
|
+
}
|
|
50
|
+
return await originalSend.call(transport, message, options);
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
// Connect server to transport
|
|
54
|
+
logger.debug('About to connect session server to transport', LOG_MODULES.GATEWAY);
|
|
55
|
+
try {
|
|
56
|
+
await server.connect(transport);
|
|
57
|
+
logger.info('MCP session transport initialized (per-request mode)', LOG_MODULES.GATEWAY);
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
61
|
+
logger.error(`Failed to connect session server to transport: ${errorMessage}`, LOG_MODULES.GATEWAY);
|
|
62
|
+
logger.error(`Transport connection error details: ${stringifyForLogging(error)}`, LOG_MODULES.GATEWAY);
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
return { transport, server };
|
|
37
66
|
}
|
|
38
|
-
// Connect server to transport
|
|
39
|
-
await server.connect(transport);
|
|
40
|
-
logger.info('Global MCP transport initialized (stateless mode)', LOG_MODULES.GATEWAY);
|
|
41
|
-
export const globalTransport = transport;
|
|
42
|
-
export const globalServer = server;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize-handler.d.ts","sourceRoot":"","sources":["../../../../../../src/services/gateway/request-handlers/initialize-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAWpE;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"initialize-handler.d.ts","sourceRoot":"","sources":["../../../../../../src/services/gateway/request-handlers/initialize-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAWpE;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA+DlE"}
|
|
@@ -40,7 +40,18 @@ export function registerInitializeHandlers(server) {
|
|
|
40
40
|
server.server.setRequestHandler(PingRequestSchema, async () => {
|
|
41
41
|
return { pong: true };
|
|
42
42
|
});
|
|
43
|
-
server.server.setNotificationHandler(InitializedNotificationSchema, async () => {
|
|
43
|
+
server.server.setNotificationHandler(InitializedNotificationSchema, async (notification) => {
|
|
44
44
|
logger.debug('Received initialized notification from client', LOG_MODULES.GATEWAY);
|
|
45
|
+
logger.debug(`Initialized notification details: ${JSON.stringify(notification)}`, LOG_MODULES.GATEWAY);
|
|
46
|
+
try {
|
|
47
|
+
// Process the notification
|
|
48
|
+
logger.debug('Successfully processed initialized notification', LOG_MODULES.GATEWAY);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
52
|
+
logger.error(`Error processing initialized notification: ${errorMessage}`, LOG_MODULES.GATEWAY);
|
|
53
|
+
logger.error(`Notification that caused error: ${JSON.stringify(notification)}`, LOG_MODULES.GATEWAY);
|
|
54
|
+
throw error; // Re-throw to see if this is the source of the problem
|
|
55
|
+
}
|
|
45
56
|
});
|
|
46
57
|
}
|
|
@@ -6,7 +6,7 @@ import { McpError } from '@modelcontextprotocol/sdk/types.js';
|
|
|
6
6
|
import { logger } from '../../../utils/index.js';
|
|
7
7
|
import { LOG_MODULES } from '../../../utils/logger/log-modules.js';
|
|
8
8
|
import { hubToolsService } from '../../hub-tools.service.js';
|
|
9
|
-
import { LIST_SERVERS_TOOL,
|
|
9
|
+
import { LIST_SERVERS_TOOL, LIST_TOOLS_TOOL, GET_TOOL_TOOL, CALL_TOOL_TOOL, UPDATE_SERVER_DESCRIPTION_TOOL } from '../../../models/system-tools.constants.js';
|
|
10
10
|
/**
|
|
11
11
|
* Register system tools handlers on the MCP server.
|
|
12
12
|
*
|
|
@@ -26,7 +26,7 @@ export function registerSystemToolsHandlers(server) {
|
|
|
26
26
|
});
|
|
27
27
|
// List all tools in a specific server
|
|
28
28
|
const ListToolsInServerRequestSchema = z.object({
|
|
29
|
-
method: z.literal(
|
|
29
|
+
method: z.literal(LIST_TOOLS_TOOL),
|
|
30
30
|
params: z.object({
|
|
31
31
|
serverName: z.string(),
|
|
32
32
|
requestOptions: z
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools-handler.d.ts","sourceRoot":"","sources":["../../../../../../src/services/gateway/request-handlers/tools-handler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"tools-handler.d.ts","sourceRoot":"","sources":["../../../../../../src/services/gateway/request-handlers/tools-handler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAMzE;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAqE7D"}
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { McpError } from '@modelcontextprotocol/sdk/types.js';
|
|
6
6
|
import { logger } from '../../../utils/index.js';
|
|
7
|
-
import { LOG_MODULES } from '../../../utils/logger/log-modules.js';
|
|
8
7
|
import { searchCoreService } from '../../search/search-core.service.js';
|
|
9
8
|
import { hubManager } from '../../hub-manager.service.js';
|
|
10
9
|
/**
|
|
@@ -43,7 +42,7 @@ export function registerToolsHandlers(server) {
|
|
|
43
42
|
filters: {}
|
|
44
43
|
};
|
|
45
44
|
if (filters.serverName) {
|
|
46
|
-
const serverInstances = hubManager.
|
|
45
|
+
const serverInstances = hubManager.getServerInstanceByName(filters.serverName);
|
|
47
46
|
if (serverInstances.length > 0) {
|
|
48
47
|
// Use the first instance's ID as filter condition
|
|
49
48
|
searchOptions.filters.serverId = serverInstances[0].id;
|
|
@@ -68,11 +67,11 @@ export function registerToolsHandlers(server) {
|
|
|
68
67
|
}
|
|
69
68
|
catch (error) {
|
|
70
69
|
if (error instanceof Error) {
|
|
71
|
-
logger.error(`Search tools error:`, error
|
|
70
|
+
logger.error(`Search tools error:`, error);
|
|
72
71
|
throw new McpError(-32802, `Search failed: ${error.message}`);
|
|
73
72
|
}
|
|
74
73
|
else {
|
|
75
|
-
logger.error(`Search tools error:`, error
|
|
74
|
+
logger.error(`Search tools error:`, error);
|
|
76
75
|
throw new McpError(-32802, `Search failed: ${String(error)}`);
|
|
77
76
|
}
|
|
78
77
|
}
|
|
@@ -30,6 +30,7 @@ export interface SystemToolDefinition {
|
|
|
30
30
|
* - list-tools-in-server: List tools from a specific server
|
|
31
31
|
* - get-tool: Get complete tool schema
|
|
32
32
|
* - call-tool: Call a specific tool from a specific server
|
|
33
|
+
* - update-server-description: Update the description of a specific MCP server
|
|
33
34
|
*
|
|
34
35
|
* @returns {Array<{ name: string; description: string; inputSchema: JsonSchema; annotations?: ToolAnnotations }>}
|
|
35
36
|
* Array of system tool configurations
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system-tool-definitions.d.ts","sourceRoot":"","sources":["../../../../../src/services/hub-tools/system-tool-definitions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAU/D;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,UAAU,CAAC;IACxB,WAAW,CAAC,EAAE,eAAe,CAAC;CAC/B;AAED
|
|
1
|
+
{"version":3,"file":"system-tool-definitions.d.ts","sourceRoot":"","sources":["../../../../../src/services/hub-tools/system-tool-definitions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAU/D;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,UAAU,CAAC;IACxB,WAAW,CAAC,EAAE,eAAe,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,cAAc,IAAI,oBAAoB,EAAE,CA6IvD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SYSTEM_TOOL_NAMES, LIST_SERVERS_TOOL,
|
|
1
|
+
import { SYSTEM_TOOL_NAMES, LIST_SERVERS_TOOL, LIST_TOOLS_TOOL, GET_TOOL_TOOL, CALL_TOOL_TOOL, UPDATE_SERVER_DESCRIPTION_TOOL } from '../../models/system-tools.constants.js';
|
|
2
2
|
/**
|
|
3
3
|
* Retrieves the complete list of system tools provided by this service.
|
|
4
4
|
*
|
|
@@ -11,6 +11,7 @@ import { SYSTEM_TOOL_NAMES, LIST_SERVERS_TOOL, LIST_TOOLS_IN_SERVER_TOOL, GET_TO
|
|
|
11
11
|
* - list-tools-in-server: List tools from a specific server
|
|
12
12
|
* - get-tool: Get complete tool schema
|
|
13
13
|
* - call-tool: Call a specific tool from a specific server
|
|
14
|
+
* - update-server-description: Update the description of a specific MCP server
|
|
14
15
|
*
|
|
15
16
|
* @returns {Array<{ name: string; description: string; inputSchema: JsonSchema; annotations?: ToolAnnotations }>}
|
|
16
17
|
* Array of system tool configurations
|
|
@@ -43,7 +44,7 @@ export function getSystemTools() {
|
|
|
43
44
|
}
|
|
44
45
|
});
|
|
45
46
|
break;
|
|
46
|
-
case
|
|
47
|
+
case LIST_TOOLS_TOOL:
|
|
47
48
|
systemTools.push({
|
|
48
49
|
name: toolName,
|
|
49
50
|
description: 'List all tools from a specific server',
|
|
@@ -102,7 +103,7 @@ export function getSystemTools() {
|
|
|
102
103
|
systemTools.push({
|
|
103
104
|
name: toolName,
|
|
104
105
|
description: 'Call a specific tool from an external MCP server. ' +
|
|
105
|
-
'System tools (list_servers,
|
|
106
|
+
'System tools (list_servers, list_tools, get_tool, update_server_description) ' +
|
|
106
107
|
'must be called directly via tools/call, not through this tool.',
|
|
107
108
|
inputSchema: {
|
|
108
109
|
type: 'object',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Tool, ToolSummary } from '../../shared/models/tool.model.js';
|
|
2
2
|
import type { Resource } from '../../shared/models/resource.model.js';
|
|
3
|
-
import { LIST_SERVERS_TOOL,
|
|
3
|
+
import { LIST_SERVERS_TOOL, LIST_TOOLS_TOOL, GET_TOOL_TOOL, CALL_TOOL_TOOL, UPDATE_SERVER_DESCRIPTION_TOOL } from '../models/system-tools.constants.js';
|
|
4
4
|
import type { SystemToolName, ListServersParams, ListToolsInServerParams, GetToolParams, CallToolParams, UpdateServerDescriptionParams } from '../models/system-tools.constants.js';
|
|
5
5
|
/**
|
|
6
6
|
* Central service for managing system tools and MCP server interactions in the MCP Hub Lite gateway.
|
|
@@ -26,6 +26,7 @@ import type { SystemToolName, ListServersParams, ListToolsInServerParams, GetToo
|
|
|
26
26
|
* - `list-tools-in-server`: List all tools from a specific server
|
|
27
27
|
* - `get-tool`: Retrieve complete schema for a specific tool
|
|
28
28
|
* - `call-tool`: Execute a tool on a specific server
|
|
29
|
+
* - `update-server-description`: Update the description of a specific MCP server
|
|
29
30
|
*
|
|
30
31
|
* ## Architecture Integration
|
|
31
32
|
*
|
|
@@ -133,7 +134,7 @@ export declare class HubToolsService {
|
|
|
133
134
|
* @returns {Promise<ConditionalReturnType>} Tool execution result with accurate type safety matching actual method return types
|
|
134
135
|
* @throws {Error} If the system tool is not found or execution fails
|
|
135
136
|
*/
|
|
136
|
-
callSystemTool<T extends SystemToolName>(toolName: T, toolArgs: T extends typeof LIST_SERVERS_TOOL ? ListServersParams : T extends typeof
|
|
137
|
+
callSystemTool<T extends SystemToolName>(toolName: T, toolArgs: T extends typeof LIST_SERVERS_TOOL ? ListServersParams : T extends typeof LIST_TOOLS_TOOL ? ListToolsInServerParams : T extends typeof GET_TOOL_TOOL ? GetToolParams : T extends typeof CALL_TOOL_TOOL ? CallToolParams : T extends typeof UPDATE_SERVER_DESCRIPTION_TOOL ? UpdateServerDescriptionParams : never): Promise<T extends typeof LIST_SERVERS_TOOL ? Record<string, string> : T extends typeof LIST_TOOLS_TOOL ? {
|
|
137
138
|
serverName: string;
|
|
138
139
|
tools: ToolSummary[];
|
|
139
140
|
} : T extends typeof GET_TOOL_TOOL ? Tool | undefined : T extends typeof CALL_TOOL_TOOL ? unknown : T extends typeof UPDATE_SERVER_DESCRIPTION_TOOL ? {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hub-tools.service.d.ts","sourceRoot":"","sources":["../../../../src/services/hub-tools.service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"hub-tools.service.d.ts","sourceRoot":"","sources":["../../../../src/services/hub-tools.service.ts"],"names":[],"mappings":"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"}
|
|
@@ -4,8 +4,9 @@ import { eventBus, EventTypes } from './event-bus.service.js';
|
|
|
4
4
|
import { gateway } from './gateway.service.js';
|
|
5
5
|
import { logger, LOG_MODULES } from '../utils/logger.js';
|
|
6
6
|
import { stringifyForLogging } from '../utils/json-utils.js';
|
|
7
|
+
import { normalizeToolName } from '../utils/name-converter.js';
|
|
7
8
|
import { McpError } from '@modelcontextprotocol/sdk/types.js';
|
|
8
|
-
import { MCP_HUB_LITE_SERVER, LIST_SERVERS_TOOL,
|
|
9
|
+
import { MCP_HUB_LITE_SERVER, LIST_SERVERS_TOOL, LIST_TOOLS_TOOL, GET_TOOL_TOOL, CALL_TOOL_TOOL, UPDATE_SERVER_DESCRIPTION_TOOL, SYSTEM_TOOL_NAMES } from '../models/system-tools.constants.js';
|
|
9
10
|
import { ToolArgsParser } from '../utils/tool-args-parser.js';
|
|
10
11
|
import { hasValidId, selectBestInstance, getServerDescription, getSystemTools, generateDynamicResources, readResource as readResourceUtil } from './hub-tools/index.js';
|
|
11
12
|
/**
|
|
@@ -32,6 +33,7 @@ import { hasValidId, selectBestInstance, getServerDescription, getSystemTools, g
|
|
|
32
33
|
* - `list-tools-in-server`: List all tools from a specific server
|
|
33
34
|
* - `get-tool`: Retrieve complete schema for a specific tool
|
|
34
35
|
* - `call-tool`: Execute a tool on a specific server
|
|
36
|
+
* - `update-server-description`: Update the description of a specific MCP server
|
|
35
37
|
*
|
|
36
38
|
* ## Architecture Integration
|
|
37
39
|
*
|
|
@@ -182,7 +184,7 @@ export class HubToolsService {
|
|
|
182
184
|
// Handle MCP Hub Lite server (return system tool)
|
|
183
185
|
if (typeof args.serverName === 'string' && args.serverName === MCP_HUB_LITE_SERVER) {
|
|
184
186
|
const systemTools = getSystemTools();
|
|
185
|
-
const found = systemTools.find((tool) => tool.name === args.toolName);
|
|
187
|
+
const found = systemTools.find((tool) => normalizeToolName(tool.name) === normalizeToolName(args.toolName));
|
|
186
188
|
if (found) {
|
|
187
189
|
return {
|
|
188
190
|
...found,
|
|
@@ -197,7 +199,7 @@ export class HubToolsService {
|
|
|
197
199
|
if (tools.length === 0) {
|
|
198
200
|
throw new Error(`Server not found: ${args.serverName}`);
|
|
199
201
|
}
|
|
200
|
-
return tools.find((t) => t.name === args.toolName);
|
|
202
|
+
return tools.find((t) => normalizeToolName(t.name) === normalizeToolName(args.toolName));
|
|
201
203
|
}
|
|
202
204
|
/**
|
|
203
205
|
* Updates the description of a specific MCP server.
|
|
@@ -251,7 +253,7 @@ export class HubToolsService {
|
|
|
251
253
|
case LIST_SERVERS_TOOL:
|
|
252
254
|
result = await this.listServers();
|
|
253
255
|
break;
|
|
254
|
-
case
|
|
256
|
+
case LIST_TOOLS_TOOL: {
|
|
255
257
|
result = await this.listToolsInServer(toolArgs);
|
|
256
258
|
break;
|
|
257
259
|
}
|
|
@@ -335,7 +337,7 @@ export class HubToolsService {
|
|
|
335
337
|
if (serverInfo && serverInfo.instance.id) {
|
|
336
338
|
const instanceIndex = serverInfo.instance.index;
|
|
337
339
|
const tools = mcpConnectionManager.getTools(server.name, instanceIndex);
|
|
338
|
-
if (tools.some((tool) => tool.name === toolName)) {
|
|
340
|
+
if (tools.some((tool) => normalizeToolName(tool.name) === normalizeToolName(toolName))) {
|
|
339
341
|
matchingServers.push(server.name);
|
|
340
342
|
}
|
|
341
343
|
}
|
|
@@ -354,13 +356,16 @@ export class HubToolsService {
|
|
|
354
356
|
// Validate tool exists before doing strict instance selection
|
|
355
357
|
// Use strictMode=false to get serverInfo without triggering tag-match-unique errors
|
|
356
358
|
const validationServerInfo = selectBestInstance(serverName, requestOptions, false);
|
|
359
|
+
let actualToolName;
|
|
357
360
|
if (validationServerInfo && validationServerInfo.instance.id) {
|
|
358
361
|
const instanceIndex = validationServerInfo.instance.index;
|
|
359
362
|
const tools = mcpConnectionManager.getTools(serverName, instanceIndex);
|
|
360
|
-
|
|
363
|
+
const matchedTool = tools.find((tool) => normalizeToolName(tool.name) === normalizeToolName(toolName));
|
|
364
|
+
if (!matchedTool) {
|
|
361
365
|
throw new Error(`Tool '${toolName}' not found in server '${serverName}'. ` +
|
|
362
|
-
`Use
|
|
366
|
+
`Use list_tools(serverName: "${serverName}") to see available tools.`);
|
|
363
367
|
}
|
|
368
|
+
actualToolName = matchedTool.name;
|
|
364
369
|
}
|
|
365
370
|
const serverInfo = selectBestInstance(serverName, requestOptions, true);
|
|
366
371
|
const requestId = `tool-call-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
@@ -374,27 +379,38 @@ export class HubToolsService {
|
|
|
374
379
|
throw new Error(`Server not found: ${serverName}`);
|
|
375
380
|
}
|
|
376
381
|
const instanceIndex = fallbackServerInfo.instance.index;
|
|
382
|
+
// If actualToolName not set yet, find it now
|
|
383
|
+
if (!actualToolName) {
|
|
384
|
+
const fallbackTools = mcpConnectionManager.getTools(serverName, instanceIndex);
|
|
385
|
+
const matchedTool = fallbackTools.find((tool) => normalizeToolName(tool.name) === normalizeToolName(toolName));
|
|
386
|
+
if (!matchedTool) {
|
|
387
|
+
throw new Error(`Tool '${toolName}' not found in server '${serverName}'. ` +
|
|
388
|
+
`Use list_tools(serverName: "${serverName}") to see available tools.`);
|
|
389
|
+
}
|
|
390
|
+
actualToolName = matchedTool.name;
|
|
391
|
+
}
|
|
392
|
+
const toolNameToUse = actualToolName || toolName;
|
|
377
393
|
// Publish tool call started event with the resolved serverIndex
|
|
378
394
|
eventBus.publish(EventTypes.TOOL_CALL_STARTED, {
|
|
379
395
|
requestId,
|
|
380
396
|
serverName,
|
|
381
397
|
serverIndex: instanceIndex,
|
|
382
|
-
toolName,
|
|
398
|
+
toolName: toolNameToUse,
|
|
383
399
|
timestamp: Date.now(),
|
|
384
400
|
args: toolArgs
|
|
385
401
|
});
|
|
386
402
|
try {
|
|
387
|
-
const result = await mcpConnectionManager.callTool(serverName, instanceIndex,
|
|
403
|
+
const result = await mcpConnectionManager.callTool(serverName, instanceIndex, toolNameToUse, toolArgs);
|
|
388
404
|
// Publish tool call completed event
|
|
389
405
|
eventBus.publish(EventTypes.TOOL_CALL_COMPLETED, {
|
|
390
406
|
requestId,
|
|
391
407
|
serverName,
|
|
392
408
|
serverIndex: instanceIndex,
|
|
393
|
-
toolName,
|
|
409
|
+
toolName: toolNameToUse,
|
|
394
410
|
timestamp: Date.now(),
|
|
395
411
|
result
|
|
396
412
|
});
|
|
397
|
-
logger.debug(`Tool call SUCCESS: serverName=${serverName}, toolName=${
|
|
413
|
+
logger.debug(`Tool call SUCCESS: serverName=${serverName}, toolName=${toolNameToUse}`, LOG_MODULES.HUB_TOOLS);
|
|
398
414
|
return result;
|
|
399
415
|
}
|
|
400
416
|
catch (error) {
|
|
@@ -403,37 +419,38 @@ export class HubToolsService {
|
|
|
403
419
|
requestId,
|
|
404
420
|
serverName,
|
|
405
421
|
serverIndex: instanceIndex,
|
|
406
|
-
toolName,
|
|
422
|
+
toolName: toolNameToUse,
|
|
407
423
|
timestamp: Date.now(),
|
|
408
424
|
error: error instanceof Error ? error.message : String(error),
|
|
409
425
|
stack: error instanceof Error ? error.stack : undefined
|
|
410
426
|
});
|
|
411
|
-
logger.error(`Tool call FAILED: serverName=${serverName}, toolName=${
|
|
427
|
+
logger.error(`Tool call FAILED: serverName=${serverName}, toolName=${toolNameToUse}, error=${error instanceof Error ? error.message : String(error)}`, error, LOG_MODULES.HUB_TOOLS);
|
|
412
428
|
throw error;
|
|
413
429
|
}
|
|
414
430
|
}
|
|
415
431
|
const instanceIndex = serverInfo.instance.index;
|
|
432
|
+
const toolNameToUse = actualToolName || toolName;
|
|
416
433
|
// Publish tool call started event
|
|
417
434
|
eventBus.publish(EventTypes.TOOL_CALL_STARTED, {
|
|
418
435
|
requestId,
|
|
419
436
|
serverName,
|
|
420
437
|
serverIndex: instanceIndex,
|
|
421
|
-
toolName,
|
|
438
|
+
toolName: toolNameToUse,
|
|
422
439
|
timestamp: Date.now(),
|
|
423
440
|
args: toolArgs
|
|
424
441
|
});
|
|
425
442
|
try {
|
|
426
|
-
const result = await mcpConnectionManager.callTool(serverName, instanceIndex,
|
|
443
|
+
const result = await mcpConnectionManager.callTool(serverName, instanceIndex, toolNameToUse, toolArgs);
|
|
427
444
|
// Publish tool call completed event
|
|
428
445
|
eventBus.publish(EventTypes.TOOL_CALL_COMPLETED, {
|
|
429
446
|
requestId,
|
|
430
447
|
serverName,
|
|
431
448
|
serverIndex: instanceIndex,
|
|
432
|
-
toolName,
|
|
449
|
+
toolName: toolNameToUse,
|
|
433
450
|
timestamp: Date.now(),
|
|
434
451
|
result
|
|
435
452
|
});
|
|
436
|
-
logger.debug(`Tool call SUCCESS: serverName=${serverName}, toolName=${
|
|
453
|
+
logger.debug(`Tool call SUCCESS: serverName=${serverName}, toolName=${toolNameToUse}`, LOG_MODULES.HUB_TOOLS);
|
|
437
454
|
return result;
|
|
438
455
|
}
|
|
439
456
|
catch (error) {
|
|
@@ -442,12 +459,12 @@ export class HubToolsService {
|
|
|
442
459
|
requestId,
|
|
443
460
|
serverName,
|
|
444
461
|
serverIndex: instanceIndex,
|
|
445
|
-
toolName,
|
|
462
|
+
toolName: toolNameToUse,
|
|
446
463
|
timestamp: Date.now(),
|
|
447
464
|
error: error instanceof Error ? error.message : String(error),
|
|
448
465
|
stack: error instanceof Error ? error.stack : undefined
|
|
449
466
|
});
|
|
450
|
-
logger.error(`Tool call FAILED: serverName=${serverName}, toolName=${
|
|
467
|
+
logger.error(`Tool call FAILED: serverName=${serverName}, toolName=${toolNameToUse}, error=${error instanceof Error ? error.message : String(error)}`, error, LOG_MODULES.HUB_TOOLS);
|
|
451
468
|
throw error;
|
|
452
469
|
}
|
|
453
470
|
}
|
|
@@ -60,16 +60,16 @@ export declare class SearchCoreService {
|
|
|
60
60
|
*
|
|
61
61
|
* This method first checks if tools are available in the cache. If cached data exists,
|
|
62
62
|
* it returns the cached tools immediately. Otherwise, it fetches tools from all connected
|
|
63
|
-
* MCP servers, applies server-level filtering based on
|
|
63
|
+
* MCP servers, applies server-level filtering based on allowedTools configuration,
|
|
64
64
|
* caches the result, and returns the filtered tools.
|
|
65
65
|
*
|
|
66
66
|
* @returns A promise that resolves to an array of Tool objects from all connected servers.
|
|
67
67
|
*
|
|
68
68
|
* @remarks
|
|
69
|
-
* - Tools are filtered based on each server's
|
|
70
|
-
* - If
|
|
71
|
-
* - If
|
|
72
|
-
* - Tools are filtered using strict name matching against the
|
|
69
|
+
* - Tools are filtered based on each server's allowedTools configuration
|
|
70
|
+
* - If allowedTools is null or undefined, all tools from that server are included
|
|
71
|
+
* - If allowedTools is an empty array, no tools from that server are included
|
|
72
|
+
* - Tools are filtered using strict name matching against the allowedTools list
|
|
73
73
|
*/
|
|
74
74
|
private getToolsWithCache;
|
|
75
75
|
/**
|
|
@@ -101,16 +101,16 @@ export class SearchCoreService {
|
|
|
101
101
|
*
|
|
102
102
|
* This method first checks if tools are available in the cache. If cached data exists,
|
|
103
103
|
* it returns the cached tools immediately. Otherwise, it fetches tools from all connected
|
|
104
|
-
* MCP servers, applies server-level filtering based on
|
|
104
|
+
* MCP servers, applies server-level filtering based on allowedTools configuration,
|
|
105
105
|
* caches the result, and returns the filtered tools.
|
|
106
106
|
*
|
|
107
107
|
* @returns A promise that resolves to an array of Tool objects from all connected servers.
|
|
108
108
|
*
|
|
109
109
|
* @remarks
|
|
110
|
-
* - Tools are filtered based on each server's
|
|
111
|
-
* - If
|
|
112
|
-
* - If
|
|
113
|
-
* - Tools are filtered using strict name matching against the
|
|
110
|
+
* - Tools are filtered based on each server's allowedTools configuration
|
|
111
|
+
* - If allowedTools is null or undefined, all tools from that server are included
|
|
112
|
+
* - If allowedTools is an empty array, no tools from that server are included
|
|
113
|
+
* - Tools are filtered using strict name matching against the allowedTools list
|
|
114
114
|
*/
|
|
115
115
|
async getToolsWithCache() {
|
|
116
116
|
const cached = this.cacheService.get();
|
|
@@ -119,17 +119,17 @@ export class SearchCoreService {
|
|
|
119
119
|
}
|
|
120
120
|
// Use new server name-level cache to get all tools
|
|
121
121
|
const tools = mcpConnectionManager.getAllToolsByServerName();
|
|
122
|
-
// Get configuration based on server name and apply
|
|
122
|
+
// Get configuration based on server name and apply allowedTools filtering
|
|
123
123
|
const filteredTools = tools.filter((tool) => {
|
|
124
124
|
const serverConfig = hubManager.getServerByName(tool.serverName);
|
|
125
125
|
if (!serverConfig)
|
|
126
126
|
return true;
|
|
127
|
-
const
|
|
128
|
-
if (
|
|
129
|
-
return
|
|
130
|
-
if (
|
|
127
|
+
const allowed = serverConfig.allowedTools;
|
|
128
|
+
if (allowed == null)
|
|
129
|
+
return true; // No allowedTools configured, show all tools
|
|
130
|
+
if (allowed.length === 0)
|
|
131
131
|
return false; // Empty array, don't show any tools
|
|
132
|
-
return
|
|
132
|
+
return allowed.includes(tool.name); // Strict filtering
|
|
133
133
|
});
|
|
134
134
|
this.cacheService.set(filteredTools);
|
|
135
135
|
return filteredTools;
|