claude-code - 💡(How to fix) Fix Deferred MCP tools cause silent InputValidationError on first call — ToolSearch required but not enforced

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

When MCP tools are registered as deferred (only the tool name is known at session start, schema is lazy-loaded), calling one of these tools directly causes an InputValidationError because the parameter schema is not yet available. The workaround — calling ToolSearch("select:<tool_name>") first — is undocumented and non-obvious.

Error Message

From the user's perspective this looks like a random transient error on every new session. Reported via Claude Code session — user-facing symptom: "Warum gibts beim ersten bash und toolsearch immer einen Fehler?" (Why does the first bash/toolsearch always produce an error?)

Root Cause

When MCP tools are registered as deferred (only the tool name is known at session start, schema is lazy-loaded), calling one of these tools directly causes an InputValidationError because the parameter schema is not yet available. The workaround — calling ToolSearch("select:<tool_name>") first — is undocumented and non-obvious.

Fix Action

Fix / Workaround

When MCP tools are registered as deferred (only the tool name is known at session start, schema is lazy-loaded), calling one of these tools directly causes an InputValidationError because the parameter schema is not yet available. The workaround — calling ToolSearch("select:<tool_name>") first — is undocumented and non-obvious.

RAW_BUFFERClick to expand / collapse

Summary

When MCP tools are registered as deferred (only the tool name is known at session start, schema is lazy-loaded), calling one of these tools directly causes an InputValidationError because the parameter schema is not yet available. The workaround — calling ToolSearch("select:<tool_name>") first — is undocumented and non-obvious.

Steps to reproduce

  1. Configure an MCP server whose tools are registered as deferred (e.g. a remote HTTP MCP server such as a custom Vercel-deployed MCP).
  2. In a new Claude Code session, attempt to call one of those tools directly (e.g. mcp__my_server__wiki_list).
  3. The call fails with InputValidationError — no schema available.
  4. Call ToolSearch("select:mcp__my_server__wiki_list") to hydrate the schema.
  5. Call the same tool again — now it succeeds.

Expected behavior

Either:

  • Option A: Claude Code automatically hydrates deferred tool schemas on first use (transparent to the model and user), OR
  • Option B: The system prompt / tool documentation clearly states that ToolSearch must be called before any deferred tool.

Currently neither is the case. The model sometimes skips the ToolSearch step (because it "knows" the tool name from context), which causes a first-call failure followed by a retry — wasting a round trip and confusing the user.

Actual behavior

  • First call → InputValidationError (schema not loaded)
  • Model calls ToolSearch to load schema
  • Second call → success

From the user's perspective this looks like a random transient error on every new session.

Environment

  • Claude Code (Claude Agent SDK, CLI / web)
  • MCP tools registered as deferred (lazy-loaded schemas)
  • Observed consistently across multiple sessions with HTTP MCP servers

Suggested fix

Auto-hydrate deferred tool schemas when a model attempts to call them, rather than requiring an explicit ToolSearch preflight. If lazy-loading is intentional for performance, emit a clear system-level warning when a deferred tool is called without its schema loaded, and auto-insert the ToolSearch step transparently.


Reported via Claude Code session — user-facing symptom: "Warum gibts beim ersten bash und toolsearch immer einen Fehler?" (Why does the first bash/toolsearch always produce an error?)

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Either:

  • Option A: Claude Code automatically hydrates deferred tool schemas on first use (transparent to the model and user), OR
  • Option B: The system prompt / tool documentation clearly states that ToolSearch must be called before any deferred tool.

Currently neither is the case. The model sometimes skips the ToolSearch step (because it "knows" the tool name from context), which causes a first-call failure followed by a retry — wasting a round trip and confusing the user.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Deferred MCP tools cause silent InputValidationError on first call — ToolSearch required but not enforced