Skip to content

fix: preserve inputSchema $defs/definitions when converting preloaded MCP tools - #1046

Closed
chiragjn wants to merge 3 commits into
mainfrom
cursor/fix-945-mcp-inputschema-defs-d2a1
Closed

chiragjn wants to merge 3 commits into
mainfrom
cursor/fix-945-mcp-inputschema-defs-d2a1

Conversation

@chiragjn

Copy link
Copy Markdown
Member

Summary

convertMCPServersToTools rebuilt the function-tool parameters from only inputSchema.properties/required, dropping top-level $defs / legacy definitions while keeping the $refs that point into them. FastMCP-style servers hoist nested models to $defs, so preloaded tools reached the LLM with dangling refs.

This branch carries the fix from #1030 and adds the missing patch changeset for @truefoundry/trueforge-core.

Fixes #945

Changes

  • packages/trueforge-core/src/core/mcp/convertMCPServers.ts: pass inputSchema.$defs and draft-04 inputSchema.definitions through into function-tool parameters when present.
  • Regression and vendor-compatibility tests under packages/trueforge-core/tests/core/mcp/.
  • .changeset/mcp-inputschema-defs.md: patch bump for @truefoundry/trueforge-core.

How was this tested?

Checklist

  • I have read the contributing guidelines
  • Tests added/updated where it makes sense
  • No hand-edits to generated code
  • Changeset added for @truefoundry/trueforge-core (patch)
Open in Web Open in Cursor 

akushonkamen and others added 3 commits October 10, 2026 16:40
…d MCP tools

convertMCPServersToTools rebuilt function-tool parameters from only
inputSchema.properties/required, dropping top-level $defs/definitions while
keeping the $refs that point into them. FastMCP-style servers (official MCP
Python SDK) hoist every nested pydantic model to top-level $defs, so any
preloaded tool with structured args reached the LLM with dangling
#/defs-style refs — failing provider schema validation or hiding the
argument shape from the model.

Carry both containers over only when present, so schemas without them are
emitted byte-identically to before.

Fixes #945
Review ask on #1030: check model-vendor compatibility before merging. The
converted parameters flow convertTools() -> jsonSchema() -> the configured
@ai-sdk provider package. Against the pinned provider sources: @ai-sdk/anthropic
preserves both $defs and legacy definitions recursively; @ai-sdk/google passes
unknown keywords (and $defs explicitly) through unstripped; @ai-sdk/openai and
the OpenAI-compatible vendors ship the parameters JSON Schema verbatim. The
tests pin what the converter itself controls: emitted parameters stay on the
vendor-accepted top-level surface (type/properties/required plus the two
container spellings and nothing else), every local $ref resolves inside the
emitted document for both spellings, and container-less schemas are emitted
byte-identically so vendor behavior for them is unchanged.
Record a patch bump for @truefoundry/trueforge-core so the preloaded
MCP tool schema fix ships in the next release.

Co-authored-by: Chirag Jain <jain.chirag925@gmail.com>
@changeset-bot

changeset-bot Bot commented Oct 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0907422

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@truefoundry/trueforge-core Patch
@truefoundry/trueforge Patch

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

@chiragjn

Copy link
Copy Markdown
Member Author

closing as duplicate of #1030

@chiragjn chiragjn closed this Oct 15, 2026
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.

Preloaded MCP tools drop inputSchema.$defs, so tool schemas sent to the LLM contain dangling $refs

3 participants