fix(mcp): normalize Codex tool schemas - #500
Open
cameroncooke wants to merge 1 commit 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'; | ||
|
|
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.
Summary
Fixes #491
Validation
npm testnpm run typechecknpm run lint(107 existing warnings, no errors)npm run format:checknpm run buildnpm run test:tool-contracts~/Librarypaths are unavailable; logs were preserved locally.