Repository navigation
Named project schemas shared by HTTP bodies and MCP tools, loadable from files offline (#845) - #907
Merged
Merged
Conversation
…tools, loaded from files offline (#845) A top-level `schemas:` map in the entry urlcode.yaml declares JSON Schema 2020-12 documents in the request body profile, inline or `{file: <path>}`. `request.body.<METHOD>.schema: <name>` and an mcp tool's `inputSchema` / `outputSchema: <name>` name one; a string is never a JSON Schema, so the reference cannot be confused with one and `$ref` keeps its standard local meaning. Unknown names fail at load (route, method, did-you-mean) or at mcp activation. - Schema files (JSON, or YAML through the inert-document profile) are read by the bounded artifact-inspect resolver rooted at the project: relative $refs to project files are followed and bundled into one self-contained schema ($defs/<stem>, $defs/<stem>.<name>); remote refs, escapes, symlinks, missing targets, cycles and size limits refuse the load without echoing the reference. The result is admitted against the body profile. - Every named schema compiles once; routes share it, the Cloudflare build writes one standalone validator per named schema, extensions receive the map as ExtensionActivation.schemas, and tools/list advertises it resolved. - Schema content and each schema file's sha256 enter `version` and projectSha256, so an edited schema file needs re-review. - The OpenAPI export writes each used named schema once as components.schemas.<name> and references it from every operation. - A shared schema carries value shape only: authorization, parameter coercion, display metadata and stored defaults stay where they are. Store collections cannot name a project schema yet. Docs: HTTP "Named schemas", SPECIFICATION, TOOLING OpenAPI, EXTENSIONS, mcp README, RIM-SCHEMA-001, llms.txt, YAML reference; the body-validation example gains a schema file with relative $refs shared by two routes, and the workerd parity run covers it. Package budget raised with measurements (main was already over). Co-Authored-By: Claude Opus 5.5 <[email protected]>
jimhoyd
enabled auto-merge (squash)
September 29, 2026 12:45
This was referenced Sep 29, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…de 24 margin Co-Authored-By: Claude Opus 5.5 <[email protected]>
…easure core budget Co-Authored-By: Claude Opus 5.5 <[email protected]>
jimhoyd
added a commit
that referenced
this pull request
Sep 29, 2026
… budget Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Sep 29, 2026
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.
Closes #845's remaining acceptance items: "one source schema supplies HTTP and a declared MCP operation", and "consume one independently authored standard schema with local refs".
schemas:map in the entryurlcode.yaml. Each entry is a 2020-12 schema in the body profile, inline or{file: <path>}.Urlcodeare reserved, and includes can't declare schemas.request.body.POST.schema: contact, or an mcp tool'sinputSchema/outputSchema.$refkeeps its standard meaning (local#/$defsonly).$anchor. Messages never echo ref text.versionandprojectSha256, so editing a schema needs re-review.tools/listadvertises the resolved schema.default/readOnly, which the body profile refuses. Follow-up filed.Evidence (macOS, Node 26)
test/named-schemas.test.ts(7 tests):$defsbundles exactly;projectSha256changes on an edit to a referenced file;packages/mcp/test/named-schemas.test.ts: one schema shared by a POST route and an MCP tool gives the same diagnostic pointers for three invalid inputs.examples/body-validationaddsschemas/lead.json→contact-point.yaml, shared by/leadsand/referrals.npm test1181,npm run verifyandtest:packagepass.npm run test:workerdis identical on all 43 responses.🤖 Generated with Claude Code