Repository navigation
Conversation
… own tool calls The viewer called its own tools (read_pdf_bytes, save_pdf, poll_pdf_commands and the submit_* helpers) by bare name. When a host qualifies tool names, for example an aggregator that prefixes "<server>-" in a group of two or more servers, those calls fail with "tool not found" and the viewer cannot load the file. resolveToolName() recovers the prefix from the name display_pdf was invoked under (getHostContext().toolInfo.tool.name) and applies it to the other tool names. With no host context, or a host that does not rewrite names, the bare name is used, so behaviour is unchanged there. Refs modelcontextprotocol#753 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Bsgz9fZYV5cHdjRq6PzmmF
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/pdf-server's viewer calls its own tools by bare name (read_pdf_bytes,save_pdf,poll_pdf_commands,submit_viewer_state,submit_page_data,submit_save_data). That works when the host connects to the server directly, but fails under a host that qualifies tool names to avoid collisions across aggregated servers (for example an aggregator that prefixes<server>-in a group of two or more servers). The widget still renders, because the host launched it with the qualifiedpdf-server-display_pdf, but its own follow-up calls go out asread_pdf_bytesand fail to resolve, so the viewer cannot load the file.This applies the pattern proposed in #753 (and used in #807 for
quickstart) topdf-server, which has nine such call sites. #807 leaves the other examples for follow-ups, so this is thepdf-serverone.Changes
examples/pdf-server/src/tool-names.ts(new):resolveToolName(baseName, invokedName)recovers the prefix the host put ondisplay_pdfand applies it to the other tool names. With no host context, or a host that does not rewrite names, it returns the bare name, so behaviour is unchanged there.examples/pdf-server/src/mcp-app.ts: the ninecallServerToolsites use it, viaapp.getHostContext()?.toolInfo?.tool?.name.examples/pdf-server/src/tool-names.test.ts(new): prefix applied, bare name kept for a host that does not rewrite, no host context, and an invoked tool that is not the entry tool.Testing
bun test: the 4 new tests pass (7 expectations), run in anoven/buncontainer.prettier -u --checkon the three changed files (prettier 3.6.2, the repo's version): passes.npm run buildinexamples/pdf-server(tsc --noEmit, the vite build, and the server bundles): succeeds on this branch./mcp/$smart/claude, a group with more than one server, so the entry tool ispdf-server-display_pdf. The MCPHub log shows the viewer's calls going out aspdf-server-read_pdf_bytes, 11 chunked reads of a 561 KB PDF with no errors, and the viewer renders in claude.ai. I have not run this against another host.npm test(bun test src examples) or the e2e tests for the rest of the repo.This is also the information requested in the comment on #753: MCPHub 1.1.3, host claude.ai (also tried through Open WebUI's MCP apps bridge), route
/mcp/$smart/claude, qualified namepdf-server-display_pdf, and the failing calls were the bareread_pdf_bytesand friends before this change.Refs #753
🤖 Generated with Claude Code
https://claude.ai/code/session_01Bsgz9fZYV5cHdjRq6PzmmF