fix(agent-core/mcp): sanitize MCP JSON Schemas for Moonshot MFJS validator#830
fix(agent-core/mcp): sanitize MCP JSON Schemas for Moonshot MFJS validator#830creatiVision wants to merge 3 commits into
Conversation
🦋 Changeset detectedLatest commit: 90653c4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6f20830c5c
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Cherry-pick PR MoonshotAI#830's changes onto current upstream main, resolving the merge conflict in transformModelData (toml.ts) introduced by main's overrides-transform refactor: - schema.ts: add incompatible 'disabled' -> 'enabled' preprocess mapping - toml.ts: keep the overrides transform and add the max_tokens / max_output_tokens -> maxOutputSize alias fallback - Add sanitizeMcpSchema (MFJS emitter) + cycle detector + root-pointer comment addressing Codex review feedback on PR MoonshotAI#830 - Integrate the sanitizer into connectAndDiscoverTools - Update schema-sanitize export in index.ts - Add tests + changeset
6fc34e7 to
c359747
Compare
ca113cd to
03873ad
Compare
…dator Resolve local $ref (with RFC 6901 pointer unescaping and circular-safe inlining), fill missing property types, normalize tuple items arrays, and split mixed-type enums into typed anyOf branches. Also map common config aliases (disabled→enabled, max_tokens→maxOutputSize).
dd82ba7 to
a0fc9fe
Compare
- Keep draft-07 tuple `items` as positional `prefixItems` (+ min/max) instead of a homogeneous anyOf union - Resolve RFC 6901 numeric array segments in local JSON Pointers - Traverse $ref sibling keywords so nested local refs are inlined before $defs are stripped
|
Addressed the three Codex review notes on
Tests: |
Related Issue
Continues / supersedes the earlier drafts in #1605 and #2216.
Problem
MCP servers often advertise standard JSON Schema tool parameters. Moonshot’s stricter MFJS validator (and Kimi’s discovery path) reject or crash on several common shapes:
$ref→ stack overflow during processingtypeon properties (enum/structure-only schemas) →type is not defineditemsarrays →items must be an object[1, "auto"]) must not be collapsed to a single forcedtypeWhat changed
sanitizeMcpSchemaand run it after MCP tool discovery inMcpConnectionManager$refinlining with RFC 6901 pointer unescaping (~1/~0) and circular-safe placeholderstypefilling from enum/const/structureitems→{ anyOf: items }anyOfbranches (preserves all members)disabled→enabled,max_tokens/max_output_tokens→maxOutputSizeOut of scope
engine-strictprompt_cache_key400s (see fix(agent-core): only send prompt_cache_key to official OpenAI endpoints #2203)Checklist
schema-sanitize, config-loader, configs)