When an MCP Tool Call Fails: A Four-Stage Decision Tree Across Transport, Auth, Schema, and Timeout
The most common first misstep when an MCP tool call fails is suspecting the model: "maybe the model did not call the tool correctly." That direction is not always wrong, but it pushes the problem to the least observable end of the chain, where troubleshooting is most expensive.
I split an MCP call chain into four stages: transport handshake, authentication, JSON Schema argument validation, and timeout. I confirm each stage one at a time with curl-level commands. In most "tool call failure" incidents, the first two stages already settle it, and you never reach schema or timeout. The core principle is the same as in the RAG piece: confirm top to bottom, stage by stage, and do not guess across stages. There is one extra prerequisite here — first align "what did the model actually generate," separating the AI layer from the engineering layer. Otherwise you cannot even tell whether you are troubleshooting a hallucination or a real fault.
Prerequisite: Split the AI Layer from the Engineering Layer
Before touching transport, print two things on the client side:
# Force these two lines in the MCP client's tools/call wrapper
logger.info("MODEL_TOOL_CALL", name=call.name, arguments=call.arguments)
logger.info("SENT_TO_SERVER", request=json.dumps(outgoing_request))
Aligning these two lines immediately shrinks the problem domain:
Prerequisite check: a tool call is failing
|
+- MODEL_TOOL_CALL has no matching tool / arguments look fabricated
| +-- model-layer problem: parameter hallucination, format drift, tool not in the system prompt
| (go fix prompt assembly and schema injection — that is not this chain)
|
+- MODEL_TOOL_CALL is correct, SENT_TO_SERVER is correct, and the server side fails
+-- engineering-chain problem -> walk the four stages below (transport/auth/schema/timeout)
This one step saves a large amount of wasted troubleshooting. One scenario I postmortemed (built from a typical production pattern): users reported that "the ticket-lookup tool keeps failing," and the on-call engineer suspected a model-capability problem, upgrading the model from 7B to 32B. It did not help. Printing those two lines revealed it: in the model's arguments, ticket_id was always a string, while the server's schema expected a number — it was a model-layer format problem, but the root was that the tool schema's type field was dropped when serialized into the prompt, so the model never knew it had to send a number. A bigger model could not fix it, because the schema the model received was itself broken.
Stage 1: Transport Handshake — "Did the process start, did the channel open"
Transport is the foundation of MCP. In stdio mode it spawns a child process and talks over standard input and output; in HTTP/SSE mode it talks to a reachable server. A failure at this stage has the signature that even initialize never comes back, not "initialize succeeds but tools/call fails."
# stdio mode: start the server process by hand, feed it an initialize, see if it answers
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{
"protocolVersion":"2024-11-05","capabilities":{},
"clientInfo":{"name":"triage","version":"1.0"}}}' \
| timeout 5 npx -y @modelcontextprotocol/server-everything --stdio
# HTTP/SSE mode: can it connect within the handshake window
curl -s -m 5 -X POST http://localhost:8808/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{
"protocolVersion":"2024-11-05","capabilities":{},
"clientInfo":{"name":"triage","version":"1.0"}}}'
Branching:
- stdio process will not start / exits immediately -> check whether
npxactually pulled the package (in an offline environment, npx fetching a package hangs until timeout, and it looks exactly like a "handshake timeout").npm config get cacheto see if the package is present; if offline, switch tonode server.jsdirectly. - stdio starts but no initialize within
timeout 5-> slow server cold start (loading heavy dependencies, connecting to a remote resource) eating the handshake window. Set a separate short timeout for the transport layer (say 3s); do not share it with the long timeout for tool execution. - HTTP unreachable / no response within 5s -> network or port problem.
ss -ltnp | grep 8808to confirm the port is listening;curl -vto see which segment breaks — DNS, TCP, or TLS.
One key realization: the transport-layer timeout and the tool-execution timeout are two different things and must be configured separately. A tool may be a slow database query that legitimately takes 20 seconds; but a handshake should return in under a second. Many "random timeout" incidents come from setting these two timeouts to the same value, so a slightly slow handshake gets killed.
Stage 2: Authentication — "Is the 401 'no credentials' or 'expired'?"
By this stage transport is up and initialize returns, and it is tools/call that starts returning 401. A 401 has only two sources, and one command confirms which:
# Manually attach a known-valid Authorization header and hit tools/call once (bypassing the client's credential injection)
curl -s -X POST http://localhost:8808/mcp \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <a-token-you-confirmed-is-valid>" \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/call",
"params":{"name":"query_ticket","arguments":{"ticket_id":12345}}}'
Branching:
- With a valid token the 401 disappears -> the credential itself is fine; the client is not forwarding the token to every tool call. This is the sneakiest class in MCP: the token is configured at the "connection established" step (initialize succeeds), but
tools/callis a subsequent independent request, and the client did not attach the same header. Check whether your client only authenticates at connect and does not reuse the credential on later calls. - With a token it is still 401 -> the token itself is invalid. Check its issued-at timestamp and expiry; swap in a freshly issued token and try again to separate "expired" from "the token is right but lacks permission" (the latter usually returns 403, though some gateways return 401 for both).
One scenario I postmortemed (built from a typical production pattern): an internal MCP gateway where every ops tool returned 401, but initialize was flaky. After three days of investigation it turned out that the gateway issued each client a token valid for only one minute, while the client kept reusing the token it had obtained at connection time — the first call succeeded inside the validity window, and everything after returned 401. This was not "the token was not forwarded" (it was), and not "insufficient permission" (permission was fine); it was the token's lifecycle and the connection's lifecycle not being aligned. The fix was to hook token refresh to connection keep-alive rather than re-signing on every call. A 401 has more than the two root causes of "not sent" and "expired"; there is also "the token you are sending has already expired, but you believe it is still live."
Stage 3: JSON Schema Argument Validation — "The Argument Is Right, but the Structure or Type Is Not"
A schema validation failure usually reports something like invalid arguments: ticket_id must be number or missing required property. The signature of this stage: transport is up, auth passes, and the server explicitly rejects the arguments.
The most common misconception is "my argument looks correct." Schema validation looks only at structure and type, never at semantics:
// The inputSchema returned by the server's tools/list (excerpt)
{
"name": "query_ticket",
"inputSchema": {
"type": "object",
"properties": {
"ticket_id": {"type": "number"},
"fields": {"type": "array", "items": {"type": "string"}}
},
"required": ["ticket_id"]
}
}
# Print side by side what the server expects and what you actually sent, and diff
# 1. What the server expects
curl -s -X POST http://localhost:8808/mcp -H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":3,"method":"tools/list"}' | python3 -m json.tool
# 2. What you sent (copied from the SENT_TO_SERVER line in the client log)
echo '{"ticket_id":"12345","fields":"status"}' # <- string + string, both wrong
At a glance, two errors are visible: ticket_id should be a number but got "12345" (a string), and fields should be an array but got "status" (a string, not an array). Both of these make schema validation reject outright. The fix is on the client side: align argument types to the schema before serializing; do not count on the server being lenient.
One subtle trap: the schema is injected into the prompt for the model, and the serialization method at injection time determines the schema the model "believes in." The ticket_id string case from the previous section is exactly this — the schema's type was dropped when serialized into the prompt, so the model saw a field with no type and naturally sent a string. So after troubleshooting this stage, go back and confirm that the schema injected into the prompt and the schema the server actually validates are the same copy. If the two disagree, fixing the type on the client side will not help, because the model still generates from the broken schema.
Stage 4: Timeout — "Slow Handshake or Slow Execution: Tell Them Apart First"
By this stage the first three are clean, and tools/call is sent but gets no response for a long time and finally times out. The root cause here splits into two classes, confirmed by one command:
# Time a full tools/call and see where it stalls
time curl -s -m 60 -X POST http://localhost:8808/mcp \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <valid-token>" \
-d '{"jsonrpc":"2.0","id":4,"method":"tools/call",
"params":{"name":"slow_query","arguments":{"range":"30d"}}}'
# Meanwhile, on the server side, look at the start/stop times of this tool's execution log
Branching:
- The client times out within seconds, and the server-side log has no record of this tool at all -> the request never reached the server; this is a transport-stage or network-stage timeout (back to stage 1), not a slow tool.
- The server-side log has the tool, and the execution itself took 40 seconds, while the client timed out at 30 -> the tool genuinely runs slowly, a legitimate slow query. In that case, do not change the client timeout to accommodate it; either give this tool its own long timeout, or make the tool async (return a job id first, then poll for the result).
- The server-side log has a record and the tool returned quickly, yet the client still times out -> the response is not coming back. Check the server-to-client return channel (an SSE stream left open, an oversized response body truncated by an intermediate gateway, proxy buffering).
One scenario I postmortemed (built from a typical production pattern): a "look up tickets over the last 30 days" tool timed out intermittently. Ops assumed network flakiness and raised the client timeout from 30s to 120s — "fixed" — but the cost was that on the slow path users waited for two full minutes. The real root cause was that the tool ran a synchronous full aggregation over 30 days, so it is slow when the data is large and fast when the data is small, which is why it looked "intermittent." Raising the timeout only masked it. The correct fix was to make the tool async: tools/call returns a job_id immediately, the client polls /result/{job_id}, and the timeout semantics shift from "can this call finish" to "is the polling window long enough." On the user side it changes from a two-minute wait to "submitted, collect the result shortly." For an intermittent timeout, the first suspect is an unstable tool execution time, not network flakiness.
Four Failure Postmortems (built from typical production scenarios)
Case 1: Token lifecycle not aligned with connection lifecycle. An internal MCP gateway issued each client a token valid for one minute; the client kept reusing the token from connection time. The first call succeeded, and everything after returned 401. The flaky initialize was exactly what a nearly expired token looks like. Fix: hook token refresh to connection keep-alive, not per-call re-signing. Lesson: when troubleshooting a 401, beyond "not sent / expired / insufficient permission," also check "token lifecycle vs. connection lifecycle." Misalignment between the two produces a flaky 401.
Case 2: Schema lost its type when serialized into the prompt. The tool query_ticket's ticket_id is a number, but the schema's type field was dropped when serialized into the prompt, so the model always sent a string and the server's schema validation rejected everything. A bigger model did not help — the schema the model received was broken. Fix: before serializing the schema into the prompt, assert it against "the same copy the server validates with," and error on any diff. Lesson: whether the model generates correct arguments is half determined by the schema you feed it. The schema-injection step needs validation like an API contract test.
Case 3: Handshake timeout and tool timeout set to the same value. The stdio server's cold start takes 6 seconds (loading dependencies); the transport handshake window and the tool-execution timeout were both set to 5 seconds, so the cold-start handshakes were all killed, looking like "a flaky connection failure." Fix: give the transport stage its own short timeout (no initialize within 3s = handshake failure) and the tool stage a long timeout. Lesson: "timeout" in MCP is not one value. Handshake, connection keep-alive, and tool execution are three independent timeouts, and misconfiguring any of them disguises itself as "random failure."
Case 4: A synchronous slow query disguised as network flakiness. The "last 30 days of tickets" tool ran a synchronous full aggregation: slow on large data, fast on small, hence intermittent timeouts. Raising the client timeout only masked it, transferring the slow tool's cost into user wait time. Fix: make the tool async — return a job id and poll. Lesson: the first suspect for an intermittent timeout is an unstable tool execution time, not the network. Measure the server-side execution-time distribution of that tool first, then decide whether to change the timeout or to change the tool.
Turning the Triage into a Standing Check: Do Not Guess, Split the Chain
The four stages are independent, and each has a confirmation command cheap enough to run in seconds. Two habits make this repeatable. First, the two-line log from the prerequisite step should be always on in staging and sampled in production; without it, every MCP incident starts by re-litigating "is it the model," which burns the first hour. Second, the three independent timeouts (handshake, keep-alive, execution) should be explicit named values in configuration, never one shared constant, because a shared value is precisely what turns a slow cold start into a "random failure" that takes days to find.
Closing: One Independent Judgment
Walking all four stages, my judgment is: in MCP tool-call failures, transport and auth (the first two stages) are the large majority, while schema and timeout are the minority. The reason is that the first two are infrastructure problems — "the channel and the credential" — that you will almost certainly hit when first integrating a tool, whereas schema and timeout are "detail problems after you are using the channel correctly," lower frequency but sneakier. So a top-down triage order is, again, not a preference; it is a hit-rate question.
One specific tradeoff on timeout: when a client-side timeout is flaky, the first reaction should not be "make the timeout bigger." Raising the timeout converts the problem from "failure" into "slowness," shifting the cost from an error into user wait time. The correct move is to measure the server-side execution-time distribution of that tool first: if the execution time is stable and short, the timeout that should change is the transport/network stage; if the execution time is itself unstable (a synchronous slow query), what should change is the tool (make it async), not the timeout value. A timeout is a symptom, not a cure; before changing it, find out what the server was actually doing during that window.
Related Articles
- The MCP Protocol and Tool Calling — MCP architecture, the Server/Client/Host roles, protocol message formats; the protocol foundation for the four stages here
- When RAG Retrieval Returns Nothing — the companion piece: troubleshooting the other end of the AI call chain, the same top-down, layer-by-layer method
- LLM Function Calling — how the model generates a tool_call and where parameter hallucination comes from; the AI-layer counterpart of the "prerequisite split"
- LLM Observability and Tracing — how to put spans on the LLM + tool-call chain; the full version of the two log lines above
Originality statement: All curl commands, the decision tree, and the cases in this article are organized by the author from hands-on integration of an in-house MCP deployment. Cases are built from typical production scenarios and contain no real company names, IP addresses, or specific timelines.