[PR #3842] [CLOSED] fix(mcp): give the compact any-value schema an item schema #5942

Closed
opened 2026-10-31 01:10:37 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/3842
Author: @kaoru0822-kitauji
Created: 10/15/2026
Status: ❌ Closed

Base: main ← Head: fix/3838-compact-any-value-items


📝 Commits (2)

  • b02e1c2 fix(mcp): give the compact any-value schema an item schema
  • 314c98f test(mcp): force the reduced form when checking array item schemas

📊 Changes

2 files changed (+60 additions, -5 deletions)

View changed files

📝 src/contracts/compactInputSchema.test.ts (+55 -1)
📝 src/contracts/compactInputSchema.ts (+5 -4)

📄 Description

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/3842 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/15/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/3838-compact-any-value-items` --- ### 📝 Commits (2) - [`b02e1c2`](https://github.com/morluto/rea/commit/b02e1c2452abb2f17e4bfc5592b10b7e0ce1ec46) fix(mcp): give the compact any-value schema an item schema - [`314c98f`](https://github.com/morluto/rea/commit/314c98f6ecb7055a4f804f8ab5a11b04322939e7) test(mcp): force the reduced form when checking array item schemas ### 📊 Changes **2 files changed** (+60 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `src/contracts/compactInputSchema.test.ts` (+55 -1) 📝 `src/contracts/compactInputSchema.ts` (+5 -4) </details> ### 📄 Description 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](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:10:37 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#5942
No description provided.