Repository navigation
fix(quickstart): resolve host-qualified tool names in callServerTool - #807
Open
annatchijova wants to merge 1 commit into
Open
annatchijova wants to merge 1 commit into
annatchijova wants to merge 1 commit into
Conversation
The quickstart example's callServerTool call hardcodes the literal tool name "get-time" instead of recovering it from getHostContext().toolInfo, so the widget's own follow-up tool calls break under any host that qualifies tool names to avoid collisions across multiple aggregated servers (e.g. "pdf-server-get-time"). Apply the resolveToolName pattern @jcollas proposed in modelcontextprotocol#753 to this example specifically, since docs/quickstart.md embeds it verbatim and it's the template most third-party app authors fork first. The other 14 affected examples listed in modelcontextprotocol#753 share the same root cause and fix shape and are left for a follow-up. docs/quickstart.md is regenerated from the source file via `npm run sync:snippets`, not hand-edited. Closes part of modelcontextprotocol#753
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
examples/quickstart'scallServerToolcall hardcodes the literal tool name"get-time"instead of recovering it fromgetHostContext().toolInfo. That works when the client connects 1:1 to a single server, but breaks under any host that qualifies tool names to avoid collisions across aggregated servers (e.g.pdf-server-get-time) — the widget still renders (the entry call that invoked it went out qualified, correctly, by the host), but its own follow-upcallServerToolcalls go out under the bare name and fail to resolve.Why this file
@jcollas's #753 already diagnosed the root cause and proposed the fix pattern (
resolveToolName, recovering the host-applied prefix fromgetHostContext().toolInfo.tool.name), and listed 15 affected examples. This PR applies that pattern toquickstartspecifically, sincedocs/quickstart.mdembeds it verbatim and it's the example most third-party app authors fork first. The other 14 examples (basic-server-*,pdf-server,debug-server,wiki-explorer-server,lazy-auth-server,cohort-heatmap-server,customer-segmentation-server,system-monitor-server,integration-server) share the identical shape and are left for a follow-up rather than bundled here.Changes
examples/quickstart/src/mcp-app.ts: addresolveToolName()and use it for thecallServerToolcall, falling back to the bare name on hosts that don't rewrite names.docs/quickstart.md: regenerated vianpm run sync:snippets— no hand edits, stays byte-identical to the source file.Testing
tsc --noEmitinexamples/quickstart— clean.npm run build(the example's real build) — succeeds, output unchanged in size (211.83 kB/54.23 kBgzip) from before the fix.prettier --checkon both changed files — passes.tests/e2e/servers.spec.tschecks the DOM result, not the call payload), so this is a behavior addition rather than a change to covered behavior; happy to add a regression test if there's a preferred place for one.Closes part of #753