fix(mcp): support Codex-compatible input schemas - #500
Open
cameroncooke wants to merge 3 commits into
Open
Conversation
Normalize published MCP schemas for Codex compatibility and add build-first static contract baselines for adaptive and full session-default modes. Fixes #491
commit: |
There was a problem hiding this comment.
Pull request overview
This PR normalizes the published MCP tool input/output JSON schemas at the MCP registration boundary to improve Codex compatibility, and introduces a build-backed “fail-closed” contract-test baseline for the MCP static tool surface.
Changes:
- Normalize MCP input schemas derived from tool Zod shapes to omit
propertyNameswhile keeping Zod parsing constraints intact. - Normalize MCP output registration schemas similarly, and refactor tool registration to centralize the registration config.
- Add a dedicated build-dependent contract-test harness + fixtures and isolate it from the default
npm testVitest run.
Reviewed changes
Copilot reviewed 10 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| vitest.contract.config.ts | Adds a dedicated Vitest config for build-backed contract tests. |
| vitest.config.ts | Excludes src/contract-tests/** from the default unit test suite. |
| src/utils/tool-registry.ts | Centralizes MCP tool registration config and normalizes schemas at registration time. |
| src/utils/mcp-input-schema.ts | Implements Codex-focused JSON schema normalization and MCP input-schema wrapping. |
| src/utils/tests/mcp-input-schema.test.ts | Unit tests ensuring schema normalization doesn’t affect parsing behavior. |
| src/core/structured-output-schema.ts | Normalizes output registration JSON schemas for Codex compatibility. |
| src/contract-tests/capture-mcp-tool-contracts.ts | Captures and validates the MCP static tool contract surface via an in-memory MCP client/server. |
| src/contract-tests/tests/mcp-tool-contracts.test.ts | Verifies captured contracts match committed adaptive/full baselines. |
| package.json | Adds test:tool-contracts script to build then run contract tests. |
| CHANGELOG.md | Documents the Codex schema-compatibility fix and new contract baseline gate. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
3
to
6
| import { z, type ZodType } from 'zod'; | ||
| import { getStructuredOutputSchemasDir } from './resource-root.ts'; | ||
| import { normalizeMcpSchemaForCodex } from '../utils/mcp-input-schema.ts'; | ||
|
|
Expose Codex-compatible MCP wire schemas for record-shaped environment inputs and arbitrary Xcode arguments while preserving object-based CLI and domain inputs. Add build-first, fail-closed per-tool contract fixtures for both public schema modes and validate the complete static catalog. Fixes #491
Require valid domain output schemas on Apple hosts while accepting only specific downstream missing-tool signatures on Linux CI. Refs #491
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Codex 0.31 rejects valid MCP input schemas when a record is represented with a
schema-valued
additionalProperties. Seven environment inputs now use readable{ key, value }arrays on the MCP wire, and Xcode IDE tool arguments use a JSONobject string. Each input is decoded once at the tool boundary; CLI and domain
callers keep their existing object-shaped inputs and normal tool behavior is
unchanged.
Regression coverage captures one readable contract per static MCP tool in both
session-default modes (82 tools × 2). The build-first gate reproduces all eight
historical Codex failures per mode, checks the exact Codex 0.31 conversion
boundary, validates structured-output contracts, exercises live handlers, and
now passes the full catalog with zero incompatibilities.
The full non-update snapshot suite remains red on this host because its stored
fixtures predate the installed Xcode/device environment and AXe cannot load the
missing Xcode
SimulatorKit.framework; the changed Xcode IDE snapshot suitepasses. No unrelated snapshots are updated here.
Fixes #491