Skip to content

fix(mcp): give the compact any-value schema an item schema - #3842

Closed
kaoru0822-kitauji wants to merge 2 commits into
mainfrom
fix/3838-compact-any-value-items
Closed

kaoru0822-kitauji wants to merge 2 commits into
mainfrom
fix/3838-compact-any-value-items

Conversation

@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

Fixes #3838

Root cause

The compact input-schema profile (REA_MCP_INPUT_SCHEMA_PROFILE=compact) writes an unconstrained JSON value as an explicit type union, {"type":["null","boolean","object","array","number","string"]}, so that Kimi doesn't infer string from {}. The union declares an array type with no items. Strict clients reject that. VS Code Copilot fails to load the whole catalog with:

Failed to validate tool mcp_rea_build_call_path: Error: tool parameters array type must have items

I listed tools from the real stdio server on main with the compact profile, and 21 tool input schemas carry this shape. That includes build_call_path at /properties/functions/items, exactly as reported, plus capture_browser_scenario, correlate_static_and_runtime, trace_application_feature, find_changed_behavior and others. The default full profile has none on current main. Setup applies compact automatically only for Kimi, so the reporter most likely set it explicitly, for example as the gateway workaround suggested in #2999.

Change

compactInputSchema.ts now owns a single any-value schema, { type: [...all JSON types], items: {} }. It is used by both producers:

  • the budget-inlined rendering of an empty schema, and
  • the reduced-form items of an array property (which was already added there for the outer array, but its item type union still lacked items).

items: {} accepts every element, so validation is unchanged.

Validation

The public stdio MCP server, tools/list, scanning every advertised input and output schema for an array type without items:

profile main this PR
compact 21 schemas (incl. build_call_path) 0
full (default) 0 0

Size / tokens (compact profile, 207 tools): input schemas go from 85,172 to 85,403 B (+231 B, +0.27%), and the full tools/list payload from 2,547,347 to 2,547,578 B. The same 27 tools are still reduced-form, so no schema crosses its compact budget.

Tests:

  • compactInputSchema.test.ts expectations now include items: {}. Ajv also accepts nested arrays ([[1], "x"]) for the any-value property.
  • New gives every advertised array type an item schema for strict clients walks compacted schemas at both a large and a tiny budget (inline and reduced) and asserts that no array type lacks items. It and the two updated tests fail on main; I checked by restoring main's producer.
  • These pass: compactInputSchemaMcp, toolInputAdmission, serverIdentity, mcpDoctor, kimiClientConfiguration, the mcpInputSchemaProfile conformance tests (6 files, 72 tests), and npm run check:fast.

Not verified: I did not run VS Code Copilot itself. The verification is the structural rule it reports ("array type must have items") checked over the real server's advertised catalog.

🤖 Generated with Claude Code

The compact input-schema profile advertises an unconstrained JSON value
as {type: [null, boolean, object, array, number, string]}. That union
declares an array type without items, which strict clients reject: VS
Code Copilot refused build_call_path with "tool parameters array type
must have items", and 21 tool input schemas carried the same shape.

Use one owned any-value schema that adds items: {} for both the
budget-inlined empty schema and reduced array items.

Fixes #3838

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kaoru0822-kitauji kaoru0822-kitauji added the track:perf Performance track PRs (issues & perf loop) label Oct 15, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-15T04:24:35.635171Z b02e1c2 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with the previous test gap addressed and no new blocking issues found.

Summary

The PR adds items: {} to the shared any-value schema used by both compact schema producers.

  • Compact input schemas give every array an item rule.

Reviews (2) · Last reviewed commit: "test(mcp): force the reduced form when c..." · Reviewed by Greptile

Use a large nested property with a 1 KiB budget so the schema is
reduced while its shallow array property remains, and assert the
presentation and that property before checking for missing items.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sx4im

sx4im commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Flagging one gap in the new test: the 64-byte leg can't fail.

compactAdvertisedInputSchema(input, 64) can't fit the reduced form (shallow properties with items exceed 64 bytes), so it returns the extreme-budget fallback — an object with a description and zero properties. arraysWithoutItems(schema) is 0 there no matter what, so that assertion can't catch a regression in the reduced-array items line this PR adds.

Minimal fix: keep the 64-byte leg but assert the fallback stays honest (declare no arrays at all — count the arrays that do have items too, not just the broken ones), and add a leg with a budget that forces the reduced path while keeping properties, asserting arraysWithoutItems is 0 and that at least one array with items survives. That way the new items line is genuinely covered instead of trivially green.

@baron baron left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Source review: adding items: {} to the explicit any-JSON-value projection is compatible with the declared JSON Schema semantics and preserves nested arbitrary arrays. The inline/reduced tests exercise both producing paths; no blocking source issue found. HOLD, not approval: this exact head currently has failed Test shard (5/5), Portable tests, and CI required in run 38681949546. Logs identify tests/boundary/cli/clientProfileLifecycle.test.ts > selected client profiles lifecycle follows the selected roots timing out after 30000ms. I have not established whether that is pre-existing or flaky, and it must be green before approval. Review together with #3806, which also modifies compactInputSchema, then rerun final integration/current-head CI after any reconciliation. Local execution was unavailable because this environment has no installed repository dependencies.

morluto added a commit that referenced this pull request Oct 16, 2026
Give array unions an unrestricted item schema and validate converted tools/list schemas for both advertised profiles. Keep client constraints separate from JSON Schema validity.

Refs: #3838, #3921, #3842

Co-authored-by: Kaoru0822 <[email protected]>
Co-authored-by: 冰水泡枸杞 <[email protected]>
@morluto morluto added area: mcp MCP server, transport, and tool registration bug Something isn't working labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: mcp MCP server, transport, and tool registration bug Something isn't working track:perf Performance track PRs (issues & perf loop)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] GitHub Copilot + VS Code cannot run

4 participants