Skip to content

Commit 0f2cb94

Browse files
committed
include mcp server names in tool names
1 parent 8e37460 commit 0f2cb94

File tree

5 files changed

+75
-6
lines changed

5 files changed

+75
-6
lines changed

core/config/profile/doLoadConfig.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { TeamAnalytics } from "../../control-plane/TeamAnalytics.js";
2727
import ContinueProxy from "../../llm/llms/stubs/ContinueProxy";
2828
import { getConfigDependentToolDefinitions } from "../../tools";
2929
import { encodeMCPToolUri } from "../../tools/callTool";
30+
import { getMCPToolName } from "../../tools/mcpToolName";
3031
import { getConfigJsonPath, getConfigYamlPath } from "../../util/paths";
3132
import { localPathOrUriToPath } from "../../util/pathToUri";
3233
import { Telemetry } from "../../util/posthog";
@@ -156,14 +157,15 @@ export default async function doLoadConfig(options: {
156157
displayTitle: server.name + " " + tool.name,
157158
function: {
158159
description: tool.description,
159-
name: tool.name,
160+
name: getMCPToolName(server, tool),
160161
parameters: tool.inputSchema,
161162
},
162163
faviconUrl: server.faviconUrl,
163164
readonly: false,
164165
type: "function" as const,
165166
uri: encodeMCPToolUri(server.id, tool.name),
166167
group: server.name,
168+
originalFunctionName: tool.name,
167169
}));
168170
newConfig.tools.push(...serverTools);
169171

core/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,7 @@ export interface Tool {
989989
uri?: string;
990990
faviconUrl?: string;
991991
group: string;
992+
originalFunctionName?: string;
992993
}
993994

994995
interface ToolChoice {

core/tools/mcpToolName.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { MCPServerStatus, MCPTool } from "..";
2+
3+
export function getMCPToolName(server: MCPServerStatus, tool: MCPTool) {
4+
const serverPrefix = server.name.split(" ").join("_").toLowerCase();
5+
if (tool.name.startsWith(serverPrefix)) {
6+
return tool.name;
7+
}
8+
return `${serverPrefix}_${tool.name}`;
9+
}

core/tools/mcpToolName.vitest.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { expect, test } from "vitest";
2+
import { MCPServerStatus, MCPTool } from "..";
3+
import { getMCPToolName } from "./mcpToolName";
4+
5+
const createMcpServer = (name: string): MCPServerStatus => ({
6+
name,
7+
errors: [],
8+
prompts: [],
9+
tools: [],
10+
resources: [],
11+
resourceTemplates: [],
12+
status: "connected",
13+
id: "",
14+
transport: {
15+
type: "sse",
16+
url: "",
17+
},
18+
});
19+
20+
const createMCPTool = (name: string): MCPTool => ({
21+
name,
22+
inputSchema: {
23+
type: "object",
24+
},
25+
});
26+
27+
test("getMCPToolName - adds server prefix to tool name when not present", () => {
28+
const server = createMcpServer("Github");
29+
const tool = createMCPTool("create_pull_request");
30+
31+
const result = getMCPToolName(server, tool);
32+
expect(result).toBe("github_create_pull_request");
33+
});
34+
35+
test("getMCPToolName - preserves tool name when it already starts with server prefix", () => {
36+
const server = createMcpServer("Github");
37+
const tool = createMCPTool("github_create_pull_request");
38+
39+
const result = getMCPToolName(server, tool);
40+
expect(result).toBe("github_create_pull_request");
41+
});
42+
43+
test("getMCPToolName - handles server names with spaces", () => {
44+
const server = createMcpServer("Azure DevOps");
45+
const tool = createMCPTool("create_pipeline");
46+
47+
const result = getMCPToolName(server, tool);
48+
expect(result).toBe("azure_devops_create_pipeline");
49+
});
50+
51+
test("getMCPToolName - handles mixed case in server names", () => {
52+
const server = createMcpServer("GitLab");
53+
const tool = createMCPTool("create_merge_request");
54+
55+
const result = getMCPToolName(server, tool);
56+
expect(result).toBe("gitlab_create_merge_request");
57+
});

gui/src/components/mainInput/Lump/sections/tool-policies/ToolPolicyItem.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function ToolPolicyItem(props: ToolDropdownItemProps) {
102102
/>
103103
)}
104104
<span className="line-clamp-1 break-all">
105-
{props.tool.function.name}
105+
{props.tool.originalFunctionName ?? props.tool.function.name}
106106
</span>
107107
</div>
108108
</div>
@@ -124,16 +124,16 @@ function ToolPolicyItem(props: ToolDropdownItemProps) {
124124
</>
125125
) : policy === "allowedWithoutPermission" ? (
126126
<>
127-
<span className="text-green-500 sm:hidden">Auto</span>
128-
<span className="hidden text-green-500 sm:inline-block">
127+
<span className="text-success sm:hidden">Auto</span>
128+
<span className="text-success hidden sm:inline-block">
129129
Automatic
130130
</span>
131131
</>
132132
) : (
133133
// allowedWithPermission
134134
<>
135-
<span className="text-yellow-500 sm:hidden">Ask</span>
136-
<span className="hidden text-yellow-500 sm:inline-block">
135+
<span className="text-warning sm:hidden">Ask</span>
136+
<span className="text-warning hidden sm:inline-block">
137137
Ask First
138138
</span>
139139
</>

0 commit comments

Comments
 (0)