Repository navigation
pdf-server: default to a single interact app tool (per-action tools behind --split-app-tools) - #830
Merged
Merged
Conversation
Thirteen per-action app tools meant thirteen approval cards on hosts that ask the user to approve each app tool separately. Fold them into one interact app tool mirroring the server-side interact: an action enum plus flat parameters, an optional commands batch with the same contract (content[i] per commands[i], a failed step's slot starts with ERROR, no isError on multi-step batches since some host SDKs collapse isError results to content[0].text), and per-action validation from the same zod schemas the split tools used. The per-action tools stay available behind a new --split-app-tools CLI flag: the server injects a one-line config script into the served view HTML (cached alongside the base bundle), which the view reads before connect(). get-document-info becomes get_document_info so the action enum is uniformly snake_case. Tests: unit coverage for the config injection (skipped when the view bundle is not built, as in the publish workflow's test job), a new e2e spec driving the app-side interact end to end (listing, dispatch, validation, batch, mid-batch failure), and pdf-page-restore.spec.ts migrated to the interact surface with the frame/JSON-RPC helpers extracted to tests/e2e/pdf-app-helpers.ts instead of a third copy. Co-authored-by: ochafik <ochafik@anthropic.com>
@modelcontextprotocol/ext-apps
@modelcontextprotocol/server-basic-preact
@modelcontextprotocol/server-basic-react
@modelcontextprotocol/server-basic-solid
@modelcontextprotocol/server-basic-svelte
@modelcontextprotocol/server-basic-vanillajs
@modelcontextprotocol/server-basic-vue
@modelcontextprotocol/server-budget-allocator
@modelcontextprotocol/server-cohort-heatmap
@modelcontextprotocol/server-customer-segmentation
@modelcontextprotocol/server-debug
@modelcontextprotocol/server-lazy-auth
@modelcontextprotocol/server-map
@modelcontextprotocol/server-pdf
@modelcontextprotocol/server-scenario-modeler
@modelcontextprotocol/server-shadertoy
@modelcontextprotocol/server-sheet-music
@modelcontextprotocol/server-system-monitor
@modelcontextprotocol/server-threejs
@modelcontextprotocol/server-transcript
@modelcontextprotocol/server-video-resource
@modelcontextprotocol/server-wiki-explorer
commit: |
Merged
ochafik
added a commit
that referenced
this pull request
Oct 27, 2026
Patch release: the pdf-server example defaults to a single interact app tool with the per-action tools behind --split-app-tools (#830), the map-server example gains a get-screenshot app tool (#821), the pdf-server viewer restores the saved page on tool-result re-delivery (#828), and the dependency refresh clears the open npm audit findings (solid-js 1.9.17, sharp ^0.35.5 and in-range transitive updates, #827). Co-authored-by: Claude <noreply@anthropic.com>
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.
Summary
The pdf-server view registered thirteen app tools (
navigate,search,add_annotations, ...). On hosts that ask the user to approve each app tool separately, that is thirteen approval cards for one PDF viewer. This folds them into a singleinteractapp tool by default, mirroring the server-sideinteractthe example already ships for hosts without app-tool support:interactapp tool with anactionenum plus flat optional parameters, and an optionalcommandsbatch with the same contract as the server-side tool:content[i]is the result ofcommands[i], a failed step's slot is text starting withERROR at step i/n (action)and the batch stops there, andisErroris not set on multi-step batches (some host SDKs collapseisErrorresults tocontent[0].text, which would drop images from earlier successful steps). Single-action calls return the handler's result verbatim —structuredContent, image content andisErrorincluded.APP_TOOL_DEFS): same handlers, same zod schemas. The schemas now double as per-action validation insideinteract, so{action: "navigate"}withoutpagefails with a per-action message.--split-app-toolsCLI flag restores the per-action tools for hosts that pick tools by name or do not charge an approval per tool. The tool surface is declared at theui/initializehandshake, so the choice has to reach the view beforeconnect(): the server injects a one-linePDF_APP_CONFIGscript into the served view HTML (cached alongside the base bundle; logged fallback if no<head>tag is found).get-document-infois renamedget_document_infoso the action enum is uniformly snake_case.The app tool and the server tool deliberately share the
interactname and schema shape: a model that has learned one surface can use the other, and hosts expose only one of them per context.Test plan
bun test examples/pdf-server, 197 pass): existing suite plus new tests for the split-mode HTML injection (skipped when the view bundle is not built, as in the publish workflow's test job, which runs the unit suite without building examples).pdf-app-interact.spec.ts(5 tests, driving the view's tools by postingtools/callJSON-RPC from the sandbox frame): the view lists onlyinteract; single-action dispatch reflected in viewer state; per-action required-param validation and the unknown-action fallback; acommandsbatch with 1:1 slots; and mid-batch failure semantics (ERROR slot, stop, noisError).pdf-page-restore.spec.tsmigrated to theinteractsurface (it drove the oldnavigateapp tool); its frame/JSON-RPC helpers are extracted totests/e2e/pdf-app-helpers.tsinstead of a third copy. 7/7 pdf e2e tests pass locally; the onepdf-annotations.spec.tsfailure in my environment reproduces identically on cleanmain.tsc --noEmitfor both the view and server configs; prettier clean.Note: #820 adds
get_current_pdfas a fourteenth app tool and will want a small rebase onto this — the tool becomes a fourteenth action.Generated by Claude Code