Skip to content

fix(mcp): strip null-valued schema types - #713

Merged
code-yeongyu merged 2 commits into
mainfrom
fix/mcp-null-tool-schema
Aug 4, 2026
Merged

fix(mcp): strip null-valued schema types#713
code-yeongyu merged 2 commits into
mainfrom
fix/mcp-null-tool-schema

Conversation

@code-yeongyu

@code-yeongyu code-yeongyu commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Summary

Some MCP servers emit invalid JSON Schema entries with type: null. Senpi
previously copied those entries into TypeBox tool definitions unchanged, so
strict OpenAI-compatible providers rejected the request with HTTP 400 before
the model could answer.

This PR strips only JSON-null type values at the first Senpi-owned MCP schema
conversion boundary. Valid JSON Schema null declarations (type: "null" and
type: ["string", "null"]) remain unchanged, and every provider adapter now
receives the sanitized MCP tool definition.

Changes

  • Omit null-valued type keys during recursive MCP schema conversion.
  • Add regression coverage for root, nested property, and combiner-branch null
    types while pinning both valid null-type forms.
  • Record the fork-specific MCP compatibility behavior and merge-conflict zones.

QA & Evidence

  • Failing-first unit proof
    • Command: npm exec vitest -- --run packages/coding-agent/test/mcp/schema-compat.test.ts -t "strips null-valued type keywords recursively"
    • Before: failed because type: null remained at the root, nested property,
      and anyOf branch.
    • After: passed.
  • Real source CLI + MCP + provider boundary
    • A local MCP stdio server advertised the malformed schema and a local
      OpenAI-compatible endpoint rejected any outbound "type":null.
    • Before: one request, one HTTP 400, null type observed, no final answer.
    • After: two requests, zero rejections, zero null types, MCP result fed into
      turn 2, final marker returned, real auth unchanged.
    • Local sanitized evidence:
      local-ignore/qa-evidence/20260804-mcp-null-schema/.
  • Standard real CLI MCP regression
    • Command: node .agents/skills/senpi-qa/scripts/mock-loop.mjs --with-mcp-tool mcp_fx_tool_1 --tool-args '{"value":"ok"}' --evidence mcp-null-schema-regression
    • Result: exit 0; two model turns; fixture executed and fed back; final marker
      present; real auth unchanged.
  • Automated validation
    • npm exec vitest -- --run packages/coding-agent/test/mcp/schema-compat.test.ts packages/coding-agent/test/mcp/register-call.test.ts — 16/16 passed.
    • npm run check — passed.
    • npm run build — passed across all workspaces.
    • Biome changed-file check and git diff --check — clean.

Cleanup

  • RED/GREEN fake-provider ports closed.
  • MCP fixture processes stopped.
  • QA sandboxes removed.
  • Temporary QA driver and debug journal removed.

Risks & Residuals

  • The sanitizer intentionally handles only the invalid JSON null value. It does
    not alter valid "null" type semantics or other schema keywords.
  • No provider-specific code changed; the fix is centralized at the MCP
    registration boundary.

Report


Summary by cubic

Strip invalid type: null from MCP tool input schemas during conversion to TypeBox so strict OpenAI‑compatible providers stop rejecting requests. Valid null types ("null" and ["string","null"]) are kept.

  • Bug Fixes
    • Recursively omit JSON-null type keys during MCP schema conversion.
    • Preserve valid null-type declarations unchanged.
    • Add tests for root, nested property, and anyOf branch cases.
    • Record the fix in packages/coding-agent/CHANGELOG.md and mcp/changes.md.

Written for commit 32dd776. Summary will update on new commits.

Review in cubic

@code-yeongyu
code-yeongyu enabled auto-merge August 4, 2026 14:30
@code-yeongyu
code-yeongyu merged commit 663b3d4 into main Aug 4, 2026
15 checks passed
@code-yeongyu
code-yeongyu deleted the fix/mcp-null-tool-schema branch August 4, 2026 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant