Repository navigation
fix(mcp): fit every advertised input schema within the 64 KiB client limit - #7119
Merged
Merged
Conversation
…limit Claude Desktop drops a local connector tool whose compact-JSON input schema exceeds 64 KiB. The full input profile advertised compare_web_captures at 171,867 bytes and inspect_analysis_view at 71,632 bytes, because the self-contained projection inlines the complete producer capture schemas once per side. The full advertisement now fits the limit at its producing boundary. A property whose schema repeats an earlier sibling's points at it, and schemas below the deepest instance level that fits are summarized as their types, size constraints and descriptions. Every rewrite widens the advertisement through the existing relaxation rules for oneOf, not, if/then/else, contains and unevaluated keywords, so canonical inputs stay accepted and the canonical contract still validates every call. Schemas within the limit are unchanged, and the compact profile is still presented from the complete projection. Numeric const and enum literals are also relaxed in the advertisement, like boolean literals, since Gemini accepts only string enum members. Fixes #4081 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
[Medium impact] The PR appears safe to merge; both previous findings are fixed and no new blocking issue was found. SummaryThe PR fits oversized advertised input schemas within 65,536 bytes while keeping canonical call checks separate.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Canonical input contract] --> B[Complete advertised projection]
B --> C[Fit full schema to 64 KiB]
B --> D[Create compact profile]
C --> E[Full tools/list schema]
D --> F[Compact tools/list schema]
A --> G[Validate incoming calls]
Reviews (2) · Last reviewed commit: "fix(mcp): keep fitted input summaries wi..." · Reviewed by Greptile |
…ting level
Array summaries took item types only from `items`, so a tuple such as
`{prefixItems: [{type: string}], items: {type: number}}` was advertised
as a number array that rejected `["a", 1]`. Item types now include tuple
positions from `prefixItems`, a draft-07 `items` array, and
`additionalItems`, and stay unconstrained when later elements are open.
A summary can also be longer than the schema it replaces (a nullable
array becomes an anyOf), so candidate size is not monotone in the
retained depth and stopping at the first overflow could skip a deeper
candidate that fits. A schema is now kept whole when its summary is not
smaller, and fitting searches from the deepest level down.
Property tests check that every summary accepts what its schema accepts
over every catalog input subschema and synthetic tuples, and that the
fitted schema is the deepest fitting candidate. The browser comparison
boundary test now expects a malformed `after` capture to be rejected
canonically, since `after` is advertised as the same schema as `before`;
the same malformation on `before` stays advertised-invalid.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
4 of 12 tasks
3 tasks done
This was referenced Oct 25, 2026
morluto
pushed a commit
that referenced
this pull request
Oct 25, 2026
This reverts commit 7336a56 (#7119). After #7120 and the other merges of 2026-10-25 grew inspect_analysis_view's complete input schema (71,762 bytes plus 3,003 bytes of examples), the 64 KiB fitting from #7119 could no longer keep instance level 3 and fell back to level 2. That summarized the inline Evidence source and the view selector collections, so main CI failed in toolInputReferences, toolSchemaValidity, analysisViewMcp, absoluteLocalPathSchema, javascriptFactsViewMcp and godotPckMcp. #7119's own CI ran against bc14312, before that growth. Reverting restores the complete full-profile advertisement while the size limit is redesigned against these contracts (#4081 stays open). Co-Authored-By: Claude Opus 5.5 <[email protected]> Refs: #7135
7 of 14 tasks
kaoru0822-kitauji
added a commit
that referenced
this pull request
Oct 26, 2026
This reverts commit 7336a56 (#7119). After #7120 and the other merges of 2026-10-25 grew inspect_analysis_view's complete input schema (71,762 bytes plus 3,003 bytes of examples), the 64 KiB fitting from #7119 could no longer keep instance level 3 and fell back to level 2. That summarized the inline Evidence source and the view selector collections, so main CI failed in toolInputReferences, toolSchemaValidity, analysisViewMcp, absoluteLocalPathSchema, javascriptFactsViewMcp and godotPckMcp. #7119's own CI ran against bc14312, before that growth. Reverting restores the complete full-profile advertisement while the size limit is redesigned against these contracts (#4081 stays open). Co-authored-by: Claude Opus 5.5 <[email protected]>
2 tasks done
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 broke: Claude Desktop drops a local connector tool whose
inputSchema, as compact JSON, is over 65,536 bytes, and shows "problem with that connector". On latest main, the opt-infullinput profile still advertisedcompare_web_capturesat 171,867 bytes andinspect_analysis_viewat 71,632 bytes.Fix: The full advertisement is now fitted to 64 KiB where it is produced (
toolInputSchemaWithMetadata). A property that repeats an earlier sibling's schema points at that sibling. Below the deepest level that still fits, schemas are summarized as their types, size constraints and descriptions. Schemas that already fit are unchanged.Risk: Only the advertised JSON of the two oversized tools changes. Nested detail below the cut is no longer advertised, but every rewrite only widens the schema, and the canonical contract still validates every call. The compact profile is byte-identical. Claude Desktop itself was not run.
Summary
Fixes #4081
The reporter and later commenters confirmed that the compact profile removes the warning. On main the compact profile is now the default, so this affects users who explicitly select
REA_MCP_INPUT_SCHEMA_PROFILE=full. A commenter on #4081 traced the toast to a per-toolschema_too_largecheck in Claude Desktop (over 65,536 bytes of compact JSON). Nesting depth and$refplay no part in that check. This PR makes every advertised input schema fit that limit in both profiles. A catalog-wide regression test enforces it.#4973 is not claimed. It also reports arguments that arrive as strings, which belongs to #3408 (#3486 / #3525).
Problem and expected behavior
compare_web_capturesis a root union of two groups. Each side inlines a complete producer result schema:before/aftereach carryinspect_web_page+discover_webmcp_tools(31.7 KB each), andbefore_scenario/after_scenarioeach carrycapture_browser_scenario(50.5 KB each). So the same 31.7 KB and 50.5 KB subtrees are each serialized twice, plus a 6.1 KB example.inspect_analysis_viewhas no duplication: itsviewunion of every view kind is 59.9 KB by itself.$defs/$refis ruled out. Input schemas must stay free of references (toolSchemaValidityasserts this, and Array and object tool parameters rejected when REA runs as a local MCP server in Claude Desktop (Windows) #3408/[Bug] compare_web_screenshots fails in Claude Desktop: $ref params passed as strings #4058 show that Claude Desktop sends$ref'd arguments as strings). Without references, JSON Schema has no way to share a subtree, so a size bound is needed.Change and scope
src/contracts/inputSchemaPresentation.ts(the owner of advertised input presentation):fitAdvertisedInputSchemareturns a schema that fits unchanged. For a larger schema, it reruns the existing advertisement normalizer in a summary mode:{type, description: "… Same schema as \before`."}`. This applies only when that is smaller.{type, items?, min/max size keywords, description}, where N is the deepest level that fits. A schema stays whole when its summary would not be smaller. Because of that, size is not monotone in N, so the search runs from the deepest level down. Array item types include tuple positions (prefixItems, draft-07itemsarrays,additionalItems). Combinator and conditional branches count as the level of the instance they describe, so a union keeps every branch and their property names.oneOfbecomesanyOf, and a changednot,if(withthen/else) orcontainswithmaxContainsis dropped. New:unevaluatedProperties/unevaluatedItemsare dropped when anything under them changes. Without that, a droppedthencould narrow the schema; a module test covers this.itemsis only advertised beside the singlearraytype, never beside a type list (the Gemini/fix(mcp): advertise reduced array elements with Gemini-compatible item types #7107 constraint). Required-name lists are not kept in summaries, because Gemini rejectsrequiredentries that are not declared properties.presentAdvertisedInputProfileis the single place that picks the profile. Compact is still presented from the complete projection, not from the fitted one, so its output is unchanged. The server registration, catalog identity, the Copilot verifier and the profile digest test now use it.compactInputSchema.tsis not edited (fix(mcp): advertise reduced array elements with Gemini-compatible item types #7107 changes it).relaxUnsupportedLiterals. It now also relaxes numericconst/enumthe same way as boolean literals. Main had 6 integerconst: 2values in the fullcompare_web_capturesschema (projection_version,fingerprint_version). Gemini accepts only string enum members, and transports turnconstintoenum. That Gemini behavior is source-derived; it was not observed live.compare_web_capturesinputs (a contract change), and any change to the compact projection.Contract and boundary impact
Semantic owner and earliest changed stage:
toolInputSchemaWithMetadata→fitAdvertisedInputSchema(full advertisement). The profile choice moves intopresentAdvertisedInputProfile. Consumers:EvidenceMcpServerCore,catalogIdentity,scripts/verify-copilot-client.mjs.Contribution scope fit and linked maintainer decision: not applicable (fix inside the existing advertisement boundary).
CLI and MCP/tool-catalog contract: the advertised full input schemas of
compare_web_capturesandinspect_analysis_viewchange, so the full-profile catalog digest changes. All other tools, output schemas and the compact profile are byte-identical. Canonical server-side validation is unchanged.Provider, bridge, target-format, or platform compatibility: none.
Evidence, artifact, provenance, or reconstruction contract: none.
Target selection, authority, upstream behavior, and cleanup details: not applicable.
Generated metadata, package, or installation impact: the recorded catalog digests are regenerated at build. No committed generated files change.
Documentation or usability only; no target interaction.
Evidence and regression coverage
Tests added or updated:
tests/boundary/mcp/compactInputSchemaMcp.test.ts: new catalog-wide check that every input schema in both profiles (realEvidenceMcpServer,tools/listover a transport) is ≤ 65,536 bytes. It also checks thatcompare_web_capturespointsafter→beforeandafter_scenario→before_scenario. The profile digest test usespresentAdvertisedInputProfile.tests/boundary/mcp/toolSchemaValidity.test.ts: the same limit on the generated catalog. Numeric-literal fixture cases. The existing relaxedscripts.items.sourceunion assertion now runs on the complete projection, because the fitted advertisement summarizes that depth.tests/boundary/mcp/browserScenarioMcp.test.ts: the fitted advertisement no longer rejects{before_scenario, after: <scenario>}, sinceafteris summarized. The server still rejects it canonically; the test still asserts that rejection.tests/boundary/mcp/browserComparisonInput.test.tschanges for the same reason. A malformedafter.webmcp: {}moves to the runtime-only invalid cases, becauseafteris advertised as "Same schema asbefore" to fit the limit, and the canonical parser and server still reject it. The same malformation onbefore, which is retained in full, is now an advertised-invalid case, so the advertisement's coverage of a malformed WebMCP capture is kept.src/contracts/inputSchemaFitInvariants.test.ts(new) has property-style checks:summary(x)accepts every valuexaccepts, for every input subschema in the catalog (probed with generic values and every value nested in canonical examples) and for synthetic tuple, union and conditional schemas, including draft-07 tuples;Both synthetic cases fail with the first push's logic (Greptile P2s).
tests/fixtures/mcpClientSchemaConstraints.ts: also rejects numericconst/enumin input schemas.src/contracts/inputSchemaPresentation.test.ts(new), with counterexamples a reviewer would try:oneOf/not/if/contains+maxContainsrelaxed instead of narroweditemsonly besidearray,[array, null]asanyOf, arrays of arrays)$ref/$defsfall back with no referenceunevaluatedPropertiescase, which fails without the new rule (checked by removing the rule)Every widening case checks with Ajv that inputs accepted by the original are also accepted by the advertisement.
Base reproduction: a stdio
tools/listscan of the built server,node scripts/rea.mjs mcp.bc143125ecompare_web_capturesinput schemainspect_analysis_viewinput schematools/listframeconst/enumSizes are UTF-8 bytes, not tokens. Projection cost, measured once per process because projections are memoized: all 229 input projections took 54 ms → 74 ms in one cold run each. Fitting takes about 21 ms for
compare_web_capturesand 11 ms forinspect_analysis_view, with the search running from the deepest level down. Peak memory was not measured separately; it is bounded by about seven ≤ 172 KB candidate trees per oversized tool.User-visible MCP output: the full
compare_web_capturesschema keepsbefore→inspection/webmcpand their fields, the scenario's top-level fields and steps,normalization.rules[]and the tool example.afterreads"The later or right-hand observation to compare. Same schema as \before`."`Remaining proof gaps:
scripts/verify-gemini-client.mjsstill checks only boolean and empty-string literals; it was not changed or run.schemaTypespartly duplicatesdetectedTypesincompactInputSchema.ts, which is off-limits while fix(mcp): advertise reduced array elements with Gemini-compatible item types #7107 is open. They could be merged later.Validation performed
tools/listscans ofdefault,compactandfullbefore and after (the table above): 0 tools over 64 KiB in each profile after; compact bytes identical.npm run test:focused --on 17 files:inputSchemaPresentation,toolInputReferences,toolSchemaValidity,compactInputSchemaMcp,browserScenarioMcp,compactInputSchema,tupleSchemaParity,javascriptFactsViewMcp,analysisViewMcp,browserMcp,applicationEvidenceMcp,environmentServeWritesMcp,advertisedInputExamples,canonicalBase64Metadata,workflowInputContracts,browserToolContracts,accessibilityCaptureComparison. Result: 210 passed.npm run test:focused --onserverIdentity,outputSchemaProfile,mcpDoctor,cliStartupImports: 45 passed.npm run test:focused --on every test file that reads the advertised schema ofcompare_web_capturesorinspect_analysis_view(36 files, found by grep), plus the fitting, compact and identity suites: 45 files, 459 passed, 1 skipped. This includesbrowserComparisonInput, which failed on CI for f366d6b.npm run check:fast: passed.npm run format:check: passed.npm run docs:check: passed.npm run metadata:check: passed.Compatibility, safety, and release
invalid_inputrejection instead.Author readiness
Human owner: @kaoru0822-kitauji
Before merge
type(scope): outcome.🤖 Generated with Claude Code