Skip to content

Commit ac462b2

Browse files
committed
docs: correct documentation about server priority order
Update comments to accurately reflect that first occurrence wins based on McpHub.getServers() order, rather than incorrectly claiming project servers take priority. The actual behavior is that global servers are initialized first, so global takes priority when the same server name exists in both configs. The deduplication fix itself is correct - this is purely a documentation fix.
1 parent a8b6ac7 commit ac462b2

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/core/prompts/tools/native-tools/__tests__/mcp_server.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,16 @@ describe("getMcpServerTools", () => {
7878
"project",
7979
)
8080

81-
// Project servers come before global servers (as per McpHub.notifyWebviewOfServerChanges sorting)
82-
const mockHub = createMockMcpHub([projectServer, globalServer])
81+
// First occurrence wins - in this test, global comes first
82+
const mockHub = createMockMcpHub([globalServer, projectServer])
8383

8484
const result = getMcpServerTools(mockHub as McpHub)
8585

8686
// Should only have one tool, not two
8787
expect(result).toHaveLength(1)
8888
expect(getFunction(result[0]).name).toBe("mcp--context7--resolve-library-id")
89-
// Project server takes priority (comes first in the list)
90-
expect(getFunction(result[0]).description).toBe("Project description")
89+
// First occurrence wins (global in this case)
90+
expect(getFunction(result[0]).description).toBe("Global description")
9191
})
9292

9393
it("should allow tools with different names from the same server", () => {

src/core/prompts/tools/native-tools/mcp_server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { buildMcpToolName } from "../../../../utils/mcp-name"
55
/**
66
* Dynamically generates native tool definitions for all enabled tools across connected MCP servers.
77
* Deduplicates tools by name to prevent API errors when the same server is defined in both
8-
* global and project configs. Project servers take priority over global servers.
8+
* global and project configs. First occurrence wins (based on McpHub.getServers() order).
99
*
1010
* @param mcpHub The McpHub instance containing connected servers.
1111
* @returns An array of OpenAI.Chat.ChatCompletionTool definitions.

0 commit comments

Comments
 (0)