Skip to content

Commit ae54abc

Browse files
committed
feat: namespace MCP tools with server name prefix
Tools are now namespaced as `servername_toolname` (e.g., `memory_create_entities`) to prevent collisions when multiple servers expose tools with the same name.
1 parent 015894f commit ae54abc

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/node/services/mcpServerManager.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,11 @@ export class MCPServerManager {
295295
private collectTools(instances: Map<string, MCPServerInstance>): Record<string, Tool> {
296296
const aggregated: Record<string, Tool> = {};
297297
for (const instance of instances.values()) {
298-
Object.assign(aggregated, instance.tools);
298+
for (const [toolName, tool] of Object.entries(instance.tools)) {
299+
// Namespace tools with server name to prevent collisions
300+
const namespacedName = `${instance.name}_${toolName}`;
301+
aggregated[namespacedName] = tool;
302+
}
299303
}
300304
return aggregated;
301305
}

tests/ipc/mcpConfig.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ describeIntegration("MCP server integration with model", () => {
275275
// Should have at least one tool call
276276
expect(toolCallStarts.length).toBeGreaterThan(0);
277277

278-
// Should have called the MCP memory tool (create_entities)
279-
const mcpToolCall = toolCallStarts.find((e) => e.toolName === "create_entities");
278+
// Should have called the MCP memory tool (namespaced as memory_create_entities)
279+
const mcpToolCall = toolCallStarts.find((e) => e.toolName === "memory_create_entities");
280280
expect(mcpToolCall).toBeDefined();
281281

282282
// Verify response mentions the entity was created

0 commit comments

Comments
 (0)