LearnNewsExamplesServices
Frontmatter
id10043
titleFix MCP OutputSchema Strict JSON-RPC Compliance and Zod Array Type Mapping
stateClosed
labels
bugai
assigneestobiu
createdAtApr 16, 2026, 7:13 PM
updatedAtMay 15, 2026, 2:41 PM
githubUrlhttps://github.com/neomjs/neo/issues/10043
authortobiu
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtApr 16, 2026, 7:40 PM

Fix MCP OutputSchema Strict JSON-RPC Compliance and Zod Array Type Mapping

tobiu
tobiu commented on Apr 16, 2026, 7:13 PM

Architectural Problem

The MCP Client strict validation layer experienced Zod schema mismatches due to parsing bugs in the OS's internal OpenApiValidator which maps OpenAPI payload definitions to runtime .describe() Zod bindings.

Specifically:

  1. Input Schema Arrays: Any array payload properties defined inside the OpenAPI specification were being hardcoded internally into string arrays (z.array(z.string())), fracturing endpoint bindings.
  2. Output Schema Object Rule: The JSON-RPC Model Context Protocol specification demands that outputSchema instances parse strictly as type: "object". Certain endpoints (like get_computed_styles in neural-link) resolved correctly inside the target application, but returned root-level Array mappings via .send(), rendering them non-compliant and failing strict Client connection handshakes.

Solution

  1. Recursive Node Generation: Pruned the hardcoded array switch() cases within buildZodSchema and transitioned map traversal down to buildZodSchemaFromNode directly, fully inheriting native types (numbers, integers, booleans, etc.) inherently resolving Input schema bounds.
  2. Result Wrapper for Primitives & Arrays: The OpenApiValidator mapping was dynamically updated to force any OpenAPI definition whose resolved schema ($ref) does not structurally equate to an object to automatically wrap its structure within { result: value }.
  3. Structured Content Sync: All 5 OS MCP servers (neural-link, memory-core, knowledge-base, file-system, github-workflow) explicitly adjusted their CallToolRequestSchema response returns to encapsulate primitives and arrays natively into mapping payloads so MCP-Client Zod failures bypass organically.
tobiu added the bug label on Apr 16, 2026, 7:13 PM
tobiu added the ai label on Apr 16, 2026, 7:13 PM
tobiu referenced in commit be9d3bc - "Fix MCP OutputSchema Strict JSON-RPC Compliance and Zod Array Type Mapping (fixes #10043)" on Apr 16, 2026, 7:14 PM
tobiu cross-referenced by PR #10044 on Apr 16, 2026, 7:14 PM
tobiu assigned to @tobiu on Apr 16, 2026, 7:17 PM
tobiu closed this issue on Apr 16, 2026, 7:40 PM
tobiu cross-referenced by #10064 on Apr 18, 2026, 7:46 PM
tobiu cross-referenced by PR #10065 on Apr 18, 2026, 7:51 PM
tobiu cross-referenced by #9837 on Apr 18, 2026, 9:08 PM
tobiu cross-referenced by PR #10067 on Apr 18, 2026, 9:14 PM
tobiu cross-referenced by #10068 on Apr 18, 2026, 9:57 PM
tobiu cross-referenced by PR #10069 on Apr 18, 2026, 10:02 PM
tobiu cross-referenced by #10070 on Apr 18, 2026, 10:42 PM
tobiu cross-referenced by PR #10071 on Apr 18, 2026, 10:50 PM
tobiu cross-referenced by #10072 on Apr 18, 2026, 11:38 PM
tobiu cross-referenced by #10074 on Apr 19, 2026, 1:01 AM