Skip to content

Commit 83ab8a7

Browse files
committed
test(mcp): assert the exact recorded spelling for an underscore-mangled long name
1 parent 17f2d11 commit 83ab8a7

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎src/core/assistant-message/__tests__/NativeToolCallParser-mcp-long-name.spec.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ describe("NativeToolCallParser.parseDynamicMcpTool name for API history", () =>
2323

2424
expect(result).not.toBeNull()
2525
expect(result!.name.length).toBeLessThanOrEqual(64)
26-
// The recorded name is the declared one, up to the hyphen/underscore spelling.
27-
expect(toolNamesMatch(result!.name, buildMcpToolName(SERVER, TOOL))).toBe(true)
26+
// The parser has no registry to restore the hyphens: it records the declared name (same hash)
27+
// in the model's underscore spelling, with the mcp-- prefix and separator restored.
28+
const declared = buildMcpToolName(SERVER, TOOL)
29+
const [, , declaredServer, declaredTool] = declared.match(/^(mcp--)(.+?)--(.+)$/)!
30+
expect(result!.name).toBe(`mcp--${declaredServer.replace(/-/g, "_")}--${declaredTool.replace(/-/g, "_")}`)
31+
expect(toolNamesMatch(result!.name, declared)).toBe(true)
2832
expect(resolveMcpToolByName([{ name: SERVER, tools: [{ name: TOOL }] }], result!.name)).toEqual({
2933
serverName: SERVER,
3034
toolName: TOOL,

0 commit comments

Comments
 (0)