feat: MCP App validator (library + CLI) — reference implementation for #673#722
Open
RyanAlberts wants to merge 2 commits into
Open
feat: MCP App validator (library + CLI) — reference implementation for #673#722RyanAlberts wants to merge 2 commits into
RyanAlberts wants to merge 2 commits into
Conversation
…talogue Adds @modelcontextprotocol/ext-apps/validator and a mcp-app-validator bin implementing the official app validator proposed in modelcontextprotocol#673: - rules.ts: machine-readable catalogue of app-side spec requirements (stable APP-NNN ids, MUST->error / SHOULD->warning severity, spec section + normative sentence per rule; direction field reserved for host-side rules per modelcontextprotocol#674) - static.ts: no-render checks over tools/list, resources/list, and resources/read (ui:// scheme, mcp-app mimeType, text-or-blob content, HTML sanity, resource existence, _meta.ui shapes via the generated Zod schemas, CSP origin well-formedness, visibility values, deprecated flat-key usage) - harness.ts: behavioral checks under a minimal Playwright mock host speaking the postMessage JSON-RPC protocol (initialize handshake, appCapabilities, initialized notification, JSON-RPC well-formedness, size-changed emission, tools/list answer when the tools capability is declared, display-mode discipline); playwright resolved lazily so static validation runs without it - CLI: streamable-HTTP / --stdio / --html targets, pretty and --json reporters, exit codes 0/1/2 Validated against the in-repo examples: all Node example servers pass; pdf-server correctly draws the APP-104 (size-changed) warning. Refs modelcontextprotocol#673 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Add src/validator/index.ts to typedoc entryPoints; export the option and result types it references so the JSDoc validation check passes clean - Add a "Validate against the specification" section to testing-mcp-apps.md Refs modelcontextprotocol#673 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
RyanAlberts
marked this pull request as ready for review
July 21, 2026 04:06
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
A working reference implementation of the official MCP App validator proposed in #673, opened as a draft to make that discussion concrete. Happy to restructure any part of it to maintainer preference (naming, location, scope).
New export
@modelcontextprotocol/ext-apps/validator+mcp-app-validatorbin:src/validator/rules.ts): every check is backed by a rule with a stable id (APP-001…), the normative MUST/SHOULD sentence it enforces, and the spec section — MUST → error, SHOULD → warning. Thedirectionfield (app/server/host) reserves the same id space for host-side rules, so the platform-conformance work in Set up public MCP Apps platform tests #674 and this validator can share one catalogue instead of drifting apart.io.modelcontextprotocol/uiextension capability advertised, then validatestools/list/resources/list/resources/read:ui://scheme,text/html;profile=mcp-appmimeType, text-or-blob content, HTML sanity, tool-referenced resources resolving,_meta.uishapes via the SDK's generated Zod schemas, CSP origin well-formedness, visibility values, deprecated flat-key usage.ui/initializehandshake,appCapabilitiespresence,initializednotification, JSON-RPC well-formedness / known methods,size-changedemission,tools/listanswered when thetoolscapability is declared, and display-mode discipline. Playwright is resolved lazily — static validation runs without it, and behavioral rules report themselves as skipped when it's absent.mcp-app-validator <url>/--stdio <cmd…>/--html <file>,--jsonfor CI, exit codes 0 (clean) / 1 (errors) / 2 (usage or connection failure).Validation
bun test src: 298 pass (14 new validator tests using the existingMcpServer+InMemoryTransportpattern)pdf-servercorrectly draws the SHOULD-levelAPP-104warning (noui/notifications/size-changedobserved)APP-100with exit code 1Open questions (mirrored on #673)
create-mcp-appCLI (Add official CLI scaffolding tool for MCP Apps #354)?--toolflag instead of a syntheticui/notifications/tool-input?Aware of the SDK v2 migration (#702/#710) — SDK contact is contained to two small modules, and I'm glad to rebase onto the v2 tree if preferred.
Refs #673
🤖 Generated with Claude Code