Skip to content

fix(mcp): emit valid schemas for empty arrays - #535

Merged
N0zoM1z0 merged 1 commit into
mainfrom
fix/mcp-empty-array-schemas-528
Oct 5, 2026
Merged

N0zoM1z0 merged 1 commit into
mainfrom
fix/mcp-empty-array-schemas-528

Conversation

@N0zoM1z0

@N0zoM1z0 N0zoM1z0 commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Replace every empty Zod tuple used by tool contracts with a shared empty-array schema. This fixes the invalid input schema for compare_web_captures and the invalid output schemas of seven tools, while preserving rejection of nonempty arrays.
  • Validate every advertised input and output schema against the JSON Schema Draft 2020-12 meta-schema during catalog generation and packaged MCP verification. Ajv is a pinned development dependency.
  • Add regression coverage for SDK tools/list, the generated catalog, and empty-array semantics. Regenerate the catalog and dependent identity metadata through the normal generators.

Closes #528.

MCP schema example

The affected tools/list fields now use this valid empty-array representation:

{
  "missing_sections": {
    "type": "array",
    "items": { "not": {} },
    "minItems": 0,
    "maxItems": 0
  }
}

Regression evidence

  • Before the fix, the live registration and generated-catalog tests rejected eight schemas across seven tools. Reintroducing the empty tuple after the fix also makes the regression tests fail.
  • After the fix, the focused tests pass repeatedly. A separate stdio MCP process advertises 122 tools; all 244 input/output schemas pass an independent Python Draft 2020-12 check.
  • Comparing the actual pre/post tools/list responses confirms that only the empty-array schema representation changes.

Verification

Commands were run with the isolated Node 24 toolchain:

npm run docs:generate
npm run check:pr
env -u GHIDRA_INSTALL_DIR -u JAVA_HOME -u REA_ANALYSIS_PROVIDER TMPDIR=/tmp npm run verify:package
npm pack --dry-run

check:pr: 363 test files passed; 1,911 tests passed and two existing platform-dependent tests skipped, plus typecheck, lint, format, dependency-use, metadata, and generated-document checks.

For the package lane, a temporary directory outside the checkout prevents Node from resolving omitted optional dependencies from the checkout's node_modules. Ghidra variables are removed only for that command so the fixture provider is selected without interference from the local bring-your-own installation. No host defaults were changed.

Provider verification

Real Hopper/Ghidra verification was not run for this schema-only change. The package lane uses fixture providers; the separate stdio MCP schema check uses the actual server without opening a target. No live Anthropic API request was made.

Replace empty tuples with a shared empty-array schema. Validate all input
and output schemas against Draft 2020-12 during catalog generation and
packaged MCP verification, with runtime and catalog regression coverage.

Closes #528

Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing)
@N0zoM1z0

N0zoM1z0 commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator Author

LGTM!

@N0zoM1z0
N0zoM1z0 merged commit 4007b20 into main Oct 5, 2026
20 checks passed
@N0zoM1z0
N0zoM1z0 deleted the fix/mcp-empty-array-schemas-528 branch October 5, 2026 07:33
darsrc pushed a commit to darsrc/rea that referenced this pull request Oct 10, 2026
Replace empty tuples with a shared empty-array schema. Validate all input
and output schemas against Draft 2020-12 during catalog generation and
packaged MCP verification, with runtime and catalog regression coverage.

Closes morluto#528

Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing)
@morluto morluto added bug Something isn't working area: mcp MCP server, transport, and tool registration labels Oct 14, 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

compare_web_captures input schema rejected by Anthropic API: z.tuple([]) emits empty prefixItems

2 participants