Skip to content

fix(server): canonicalize retrieve_tools identity to server:tool - #874

Merged
Dumbris merged 3 commits into
mainfrom
fix/871-canonical-tool-ids
Jul 21, 2026
Merged

Dumbris merged 3 commits into
mainfrom
fix/871-canonical-tool-ids

Conversation

@Dumbris

@Dumbris Dumbris commented Jul 21, 2026 •

Copy link
Copy Markdown
Member

Fixes #871

retrieve_tools returned the bare indexed tool name (echo) while describe_tool/call_tool_* require server:tool — breaking the spec-085 progressive-disclosure round-trip for every live-indexed tool (compact mode was unrecoverable: no server field).

Change

  • Canonicalize identity at the index read seams (SearchTools, GetToolsByServer in internal/index/bleve.go) via canonicalToolName with a double-prefix guard. Stored docs unchanged — works on existing indexes.
  • Companion fix: lookupToolAnnotations now normalizes its input (central fix in mcp_visibility.go), so annotations/call_with derivation keeps working with canonical names — without this, canonicalization would silently regress retrieve_tools: annotations/call_with always defaults to call_tool_read due to tool name parsing bug #306 (annotations dropped, call_with degrading to call_tool_read).
  • Side effects now correct: include_stats usage lookup keys match how usage is recorded; disabled/locked entry names consistent with the quarantine pass.

Verification

  • Live app (rebuilt binary, server-everything upstream): compact id and full name now everything:echo; describe_tool/call_tool_read accept the exact returned id; annotations/call_with verified intact across 6 tools; include_stats populated.
  • New tests: bleve canonicalization + double-prefix guard, retrieve→describe round-trip, annotation live-path regression test. go test -race green, 65/65 API E2E green, golangci-lint v2 clean.

Note: while updating TestE2E_QuarantineConfigApply we noticed a pre-existing gap (not introduced here): /api/v1/index/search applies no quarantine filtering. Will file separately.

Draft: @neylwalecki mentioned having a patch for this — happy to reconcile.

Discovery stores tools with a BARE name (ToolMetadata{ServerName:"github",
Name:"create_issue"}), which bleve persisted verbatim as full_tool_name and
returned unchanged from SearchTools / GetToolsByServer. retrieve_tools then
emitted that bare id, but describe_tool and call_tool_* require the
"<server>:<tool>" form — so the exact id retrieve_tools returned could not be
fed back into either.

Add canonicalToolName(serverName, name) and apply it at the two index READ
seams (SearchTools hit conversion, GetToolsByServer). The write path and stored
docs are untouched. A mandatory double-prefix guard leaves already-prefixed
legacy/fixture names unchanged, and profile rebuilds that re-index a canonical
name round-trip cleanly.

Companion fix: lookupToolAnnotations now normalizes its input via
normalizeServerTool. With Name canonical and ServerName set, the full entry
builder and annotation-filter loop pass a prefixed name into the lookup, whose
live StateView tool names are bare — without normalization the match would miss,
dropping annotations and degrading call_with back to call_tool_read (#306).

Tests: index read-seam canonicalization + double-prefix guard; live-path
annotation resolution through a real StateView; retrieve_tools -> describe_tool
round-trip on the bare-index bug path. Updated the quarantine config-apply E2E
to the canonical-id contract (its bare-name checks passed only vacuously).
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

Deploying mcpproxy-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 68abe59
Status: ✅  Deploy successful!
Preview URL: https://561a29e3.mcpproxy-docs.pages.dev
Branch Preview URL: https://fix-871-canonical-tool-ids.mcpproxy-docs.pages.dev

View logs

@codecov-commenter

codecov-commenter commented Jul 21, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 89.47368% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/httpapi/server.go 66.66% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@github-actions

github-actions Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

📦 Build Artifacts

Workflow Run: View Run
Branch: fix/871-canonical-tool-ids

Available Artifacts

  • archive-darwin-amd64 (28 MB)
  • archive-darwin-arm64 (25 MB)
  • archive-linux-amd64 (16 MB)
  • archive-linux-arm64 (15 MB)
  • archive-windows-amd64 (28 MB)
  • archive-windows-arm64 (25 MB)
  • frontend-dist-pr (0 MB)
  • installer-dmg-darwin-amd64 (22 MB)
  • installer-dmg-darwin-arm64 (20 MB)

How to Download

Option 1: GitHub Web UI (easiest)

  1. Go to the workflow run page linked above
  2. Scroll to the bottom "Artifacts" section
  3. Click on the artifact you want to download

Option 2: GitHub CLI

gh run download 29824535453 --repo smart-mcp-proxy/mcpproxy-go

Note: Artifacts expire in 14 days.

The #871 canonicalization of tool identity to "server:tool" at the index
read seams is correct for the MCP discovery surface, but it leaked into the
REST GET /api/v1/index/search response, whose name field has always been the
bare tool name with server_name reported separately. External consumers (the
D1 retrieval-regression scorer) assemble the id themselves, so a prefixed name
double-prefixes (git:git:git_log) and drops recall@5 to 0.

Strip the server prefix at the httpapi conversion seam only; the MCP surface
stays canonical. Add a regression test pinning the REST bare-name contract and
revert the E2E expectations that were flipped to canonical on this branch.
@Dumbris

Dumbris commented Jul 21, 2026

Copy link
Copy Markdown
Member Author

Cross-model review (Codex 0.144.6 / gpt-5.6-sol): ACCEPT in round 1, no findings. CI: all checks green except Analyze (go) — the CodeQL 4.37.0/4.37.1 infra mismatch that's failing on main itself (not a required check). Extra hardening while getting CI green: the REST /api/v1/index/search response keeps its bare-name contract (name + server_name) since the external mcp-eval D1 gate assembles ids itself — canonical server:tool ids are an MCP-surface contract only. D1 retrieval gate back to baseline recall.

@Dumbris
Dumbris marked this pull request as ready for review July 21, 2026 13:32
@Dumbris
Dumbris merged commit ffaa712 into main Jul 21, 2026
44 of 46 checks passed
@Dumbris
Dumbris deleted the fix/871-canonical-tool-ids branch July 21, 2026 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

retrieve_tools can return bare tool ids that describe_tool/call_tool_* cannot use

2 participants