Skip to content

fix(mcp): bound capture comparison input schema depth - #1005

Merged
N0zoM1z0 merged 7 commits into
morluto:mainfrom
sx4im:fix/mcp-wire-schema-model-limits
Oct 8, 2026
Merged

N0zoM1z0 merged 7 commits into
morluto:mainfrom
sx4im:fix/mcp-wire-schema-model-limits

Conversation

@sx4im

@sx4im sx4im commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #919.

compare_web_captures embedded full inspection and scenario result schemas, reaching 13 structural levels and blocking clients that reject an entire catalog when one input exceeds ten. Describe these inputs as complete producer-result objects to pass back unchanged, while retaining every nested runtime constraint. Together with merged #995, all 134 tools have cycle-free input/output schemas and inputs within the documented structural depth profile.

Problem and expected behavior

The deepest passive path includes WebSocket JSON shapes; recorded scenario history has another depth-13 path. Agents should be able to discover every tool and compare results already returned by REA. Both comparison groups now identify their exact producer; scenario authoring and normalization options remain fully described.

Change and scope

  • Add a contracts-layer projection for complete passive and scenario capture inputs, with cloned canonical validators.
  • Preserve the strict comparison root, paired-input refinement, defaults, full capture validation, and complete observation output schemas.
  • Check every live and generated input after SDK conversion against a stated ten-level profile, following local references per path. Property maps, definitions, and literal examples/defaults are not nesting levels.
  • Regenerate tracked product/skill metadata. The build-generated MCP catalog remains ignored.

Given earlier and later inspect_web_page responses:

await client.callTool({
  name: "compare_web_captures",
  arguments: {
    before: { inspection: earlier.structuredContent.result },
    after: { inspection: later.structuredContent.result },
  },
});

Scenario comparison similarly takes complete capture_browser_scenario results in before_scenario and after_scenario.

Contract and boundary impact

  • Semantic owner and earliest changed stage: contracts-layer input schema projection.
  • CLI and MCP/tool-catalog contract: same input groups and full runtime validation; clearer producer guidance and bounded advertised nesting.
  • Provider, bridge, target-format, or platform compatibility: no provider protocol changes; catalog compatibility is checked across the complete inventory.
  • Evidence, artifact, provenance, or reconstruction contract: capture contents, identity, completeness, and comparison results remain intact.
  • Process execution, authorization, cleanup, or containment impact: none.
  • Generated metadata, package, or installation impact: canonical catalog digests and dependent generated documents refreshed through the repository generators.

Evidence and regression coverage

  • Full live/generated inventory, root and escaped references, shared acyclic definitions, dialect validity, examples, authority hints, strict inputs, and handler binding with original/reversed catalog ordering.

  • Incomplete payloads accepted by the advertised object envelope are rejected by the full server parser before the handler runs. A malformed deep WebSocket types entry is also rejected through MCP.

  • Actual stdio discovery reports 134 tools, zero reachable input/output cycles, and maximum structural input depth ten.

  • Real Chrome capture round trips passed for passive inspections and scenario history, with exact CLI/MCP comparison parity and preserved external-browser lifecycle.

  • Remaining proof gap: Muse Spark/opencode itself was unavailable. The documented profile counts schema structure; the model API's exact undocumented depth rule and any additional limits remain unverified.

  • Observed, derived, and inferred claims remain distinguishable.

  • Artifact identity, source provenance, and failed attempts remain preserved.

  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm run build:cached — passed with bounded local resource settings.
  • Nine focused Vitest files — 36 tests passed; three main documentation/catalog/release test files — 30 tests passed.
  • npm run check:fast -- --concurrency=1 --env-mode=loose — passed.
  • npm run docs:check -- --env-mode=loose — passed after synchronizing with merged main.
  • npm run verify:package — passed, including actual packed installation, CLI/MCP discovery, setup/update, skill, Evidence, and lifecycle checks.
  • Local real Chrome + stdio MCP round-trip harness — passed, including malformed deep input and CLI/MCP parity.

Compatibility, safety, and release

  • Breaking changes or migration steps: none; pass complete existing results in the same fields.
  • Real Hopper/Ghidra coverage: not performed; no provider behavior changed. Real Chrome verification ran on Linux x64. Platform package CI is required before merge.
  • Package or release metadata impact: generated catalog identity changes; package version unchanged.
  • Security, privacy, process, or containment review: no new authority or data flow. Tests used isolated profiles/workspaces, two CPUs, and a 2 GiB family memory budget. Public examples omit host paths.

Review checklist

  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated.
  • User-visible CLI/MCP changes include a representative example.
  • Final diff checked for secrets, unrelated cleanup, and unsupported claims.

kaoru0822-kitauji and others added 4 commits October 7, 2026 15:58
`z.json()` projects a self-referential `$defs/__schema0` entry. Twenty
tool input schemas and 123 output schemas carried it, and clients or
model APIs that reject recursive JSON Schemas refuse the whole tool
list. Every JSON value satisfies `{}`, so the shared JSON value schema
now advertises that. Runtime parsing still admits only JSON values.

Refs morluto#919

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…n-schemas

# Conflicts:
#	docs/product-catalog.json
#	docs/verification/managed-conformance-manifest.json
#	skills/reverse-engineer-anything/SKILL.md
#	src/generatedMcpToolCatalog.ts
…n-schemas

# Conflicts:
#	src/generatedMcpToolCatalog.ts
… limits

Some model providers reject the whole tool list when any input schema
contains a recursive $ref or nests deeper than 10 levels (fixes morluto#919).
Sanitize the advertised wire projection: break cyclic $refs, bound nesting
depth, and drop unreachable $defs. Canonical Zod contracts are untouched.
@morluto

morluto commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Thanks, @sx4im, for your work on “fix(mcp): keep advertised input schemas within model function-calling limits.” I appreciate your contribution to REA.

@N0zoM1z0 N0zoM1z0 changed the title fix(mcp): keep advertised input schemas within model function-calling limits fix(mcp): bound capture comparison input schema depth Oct 8, 2026
@N0zoM1z0

N0zoM1z0 commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

Reviewed the complete sanitizer, SDK schema conversion, runtime validators, generated-catalog handling, and the previous CI failures. I pushed follow-up commits preserving this PR's ancestry and synchronized it with merged #995.

The final change replaces generic depth truncation with an explicit producer-result boundary for both passive and recorded scenario captures. Scenario authoring and comparison normalization remain fully advertised; cloned validators retain the complete capture constraints and paired-input refinement. The build-generated catalog is no longer tracked.

Verification passed: 66 local tests across 12 files, static checks, generated-document checks, actual packed-package verification, actual stdio discovery of all 134 tools, and real Chrome capture/comparison round trips with exact CLI/MCP parity. Inputs and outputs have zero reachable recursive references, and every input fits the documented structural depth profile. Malformed deep capture data still fails runtime validation.

The branch push starts fresh CI for the final head. Muse Spark/opencode was unavailable, so the verification establishes the stated local compatibility profile and actual REA workflows, rather than a model-specific end-to-end claim.

@N0zoM1z0 N0zoM1z0 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.

Final review completed at 82dd85e35af579c1f9739482752395b69397ee70. The targeted producer-result projections retain full runtime validation and complete output evidence; the generic sanitizer and tracked build-generated catalog have been removed. All live/generated inputs satisfy the documented structural profile, and input/output cycle guards cover the entire inventory.

Local verification includes 66 focused tests, static/docs gates, complete packaged-install verification, and actual Chrome capture round trips with CLI/MCP parity and malformed deep-input rejection. All exact-head CI checks are now complete and green, including Windows and both macOS architectures. Muse Spark/opencode itself remains unavailable and unverified, as stated in the PR.

@N0zoM1z0
N0zoM1z0 merged commit 6b55de0 into morluto:main Oct 8, 2026
23 checks passed
darsrc pushed a commit to darsrc/rea that referenced this pull request Oct 10, 2026
* fix(mcp): advertise JSON values without recursive schemas

`z.json()` projects a self-referential `$defs/__schema0` entry. Twenty
tool input schemas and 123 output schemas carried it, and clients or
model APIs that reject recursive JSON Schemas refuse the whole tool
list. Every JSON value satisfies `{}`, so the shared JSON value schema
now advertises that. Runtime parsing still admits only JSON values.

Refs morluto#919


* fix(mcp): keep advertised input schemas within model function-calling limits

Some model providers reject the whole tool list when any input schema
contains a recursive $ref or nests deeper than 10 levels (fixes morluto#919).
Sanitize the advertised wire projection: break cyclic $refs, bound nesting
depth, and drop unreachable $defs. Canonical Zod contracts are untouched.

---------

Co-authored-by: Kaoru0822 <[email protected]>
Co-authored-by: sx4im <[email protected]>
Co-authored-by: N0zoM1z0 <[email protected]>
@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.

MCP tool input schemas exceed Muse Spark 1.3 function-calling limits (recursive $ref, nesting depth > 10); no REA tool is usable with that model

4 participants