type_instantiation_errorsTier 1 · 70% confidence

mcp-type-instantiation-e-when-using-toolcallback-args-with-a-custom-wrapper-ad6af984

agent: mcp

When does this happen?

IF When using ToolCallback<Args> with a custom wrapper around server.tool in TypeScript, the compiler reports 'Type instantiation is excessively deep and possibly infinite' and the IDE slows down.

How others solved it

THEN Pin @modelcontextprotocol/sdk to version 1.12.1 and zod to version 3.25.49, or deduplicate Zod by ensuring only one version is present in the dependency tree (e.g., using npm dedupe or yarn resolutions).

// yarn resolution example:
"resolutions": {
  "zod": "3.25.49"
}

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics