Repository navigation
Conversation
getMcpTools converted each action schema with z.toJSONSchema's default
"output" mode, which throws on .transform() and z.custom. Any agent with
the pyth, x402, CDP swap, erc8004, wow, sushi, jupiter, flaunch, clanker
or basename providers crashed while listing tools.
Convert with io: "input" (what the caller sends), map unrepresentable
types to {} and keep objects closed with additionalProperties: false, so
every schema that converted before is unchanged.
🟡 Heimdall Review Status
|
This branch has not been deployed
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.
Description
getMcpToolsthrows while building the tool list as soon as one active action has a schema with a.transform()or az.custom()type:It calls
z.toJSONSchema(action.schema), which defaults toio: "output", and zod cannot describe a transform's output (or a custom type) in JSON Schema. On main this affects 28 actions, includingpyth(used by the MCP example server),x402andcdpEvmWallet/cdpSmartWalletswap (both in thecreate-onchain-agentMCP templates), pluserc8004,wow,sushi,jupiter,flaunch,clanker,basenameandtruemarkets. The LangChain and Vercel AI SDK extensions build the same schemas without errors because they convert the input side.Changes in
framework-extensions/model-context-protocol/src/index.ts:io: "input": the tool schema now describes what the caller sends, which is whattoolHandlerparses.unrepresentable: "any": az.customfield becomes{}instead of throwing.toolHandlerstill validates it withaction.schema.parse.overridethat keepsadditionalProperties: falseon objects, as the output conversion did. Without it the input mode leaves objects open.I checked every action provider exported by
@coinbase/agentkit(108 actions on an EVM network): the 80 schemas that converted before come out deep-equal to what main produced, and the 28 that threw now convert.flowchart TD A[Agent with pyth or x402 or CDP swap] --> B{getMcpTools} B -->|Before| C[Throws and no tools are listed] B -->|After| D[Every tool is listed]Narrated recording, before then after (sound on):
evidence.mp4
Tests
Shown in the recording (a Node REPL in
typescript/examples/model-context-protocol-smart-wallet-server, which uses the workspace packages, with a stub wallet provider so no keys or network are needed):On main:
With this change,
tools.map(t => t.name):Edge cases and unchanged behaviour checked:
quoteCurrency/assetType(nullable + transform) are listed asanyOf [string, null]with their descriptions (recording).wowcontractAddress(z.custom) becomes{ description }and the other fields keep their types (recording).ERC20ActionProvider_get_balanceschema is unchanged, stilladditionalProperties: false(recording, and the 108-action deep-equal comparison above).toolHandlerstill validates:{ tokenAddress: "nope" }is rejected withInvalid Ethereum address format(recording).Unit tests, lint and type check in
typescript/framework-extensions/model-context-protocol:The new test fails on main with
Transforms cannot be represented in JSON Schema.pnpm run lint,prettier --checkandtsc --noEmitpass. I did not run a chatbot against a live network or the full monorepo test suite.Checklist
AI assistance (Claude Code) was used to find and fix this and to prepare the PR.
🤖 Generated with Claude Code