The short answer
Do not treat an MCP tool timeout as proof that the tool failed. At the point the client times out, the request may have failed before execution, may still be running, or may have completed successfully while the response was lost. The safe client therefore separates three questions:
- Is the connection still usable? If not, reconnect and re-establish the session.
- What is the state of the operation? Query it using a stable operation or request identifier.
- Can the operation be retried safely? Retry only when the operation is idempotent or the server can deduplicate the retry.
For long-running MCP tool calls, the best architecture is usually not “wait longer.” It is a two-part workflow: make the operation durable, give it a caller-provided idempotency key, and expose a separate status or result lookup. Reconnect the transport without blindly repeating the write.
This distinction matters commercially. A dropped connection that causes a duplicate invoice, a second customer notification, or another API purchase consumes support time and damages trust. A client that gives up too early leaves useful work incomplete. The goal is controlled recovery—not aggressive retries.
Understand what actually broke
MCP separates protocol semantics from the transport that carries its JSON-RPC messages. A transport defines message framing and delivery, connection lifecycle, cancellation, and termination. It does not decide what a tool means.
For MCP clients, the practical failure categories are:
- Session timeout: the client stops waiting for a response, but the transport may still be connected.
- Transport disconnect: the connection is gone, so a response cannot arrive on that connection.
- Server or tool failure: the server explicitly returns an error.
- Unknown outcome: the request was sent, but its result cannot be established.
The last category is the dangerous one. A JSON-RPC error is not equivalent to an absent response. A missing response leaves the client uncertain whether a side effect occurred.
The MCP lifecycle also distinguishes initialization, normal operation, and shutdown. A reconnect normally means repeating the required initialization sequence before new operations. Do not assume that a new TCP connection inherits the old session’s negotiated state.
Transport choice changes recovery mechanics:
- With stdio, the client launches the server as a subprocess. A process exit is a transport failure and may also terminate in-process work.
- With Streamable HTTP, the client sends messages to an HTTP endpoint, and replies may arrive as a JSON response or an SSE stream. A closed response stream can look like a disconnect even while the server is still processing work.
The recovery principles remain the same: reconnect, restore required session state, and determine the operation’s outcome before retrying.
Use a state machine, not a retry loop
A simple try/catch around a tool call encourages the wrong behavior. “Any error, then call again” duplicates side effects whenever the first request succeeded but its response was lost.
Instead, model each tool call as a small state machine:
created: the client has generated a stable request ID.dispatched: the request has been sent, but no reliable outcome is known.running: the server confirms that the operation is executing.succeeded: the result is available.failed: the server confirms a terminal failure.cancelled: the operation was explicitly cancelled.unknown: the client cannot yet determine the outcome.
Persist the operation ID, tool name, normalized arguments, idempotency key, timestamps, and last known state. On restart, the client should be able to resume from dispatched or unknown rather than creating a brand-new operation automatically.
This design also makes logs useful. A support engineer should be able to answer: Which operation was dispatched? Which server received it? Was a status check made? Was a retry sent with the same key or a new one?
The recovery sequence
1. Give every consequential call a stable operation ID
Generate an ID before the first attempt and retain it across reconnects. Do not regenerate it merely because the transport failed.
If the server supports idempotency, send the same idempotency key on retries. The key should identify one logical business operation. A random key generated for each network attempt is not idempotency; it permits the server to treat every retry as new work.
Do not use only the JSON-RPC request ID for this purpose. JSON-RPC correlates protocol messages within an exchange. Your durable business-operation identifier should survive process restarts, changed clients, and application-level retries.
A useful representation might look like this:
{
"operation_id": "op_01JZ7Y8Q8K2M4N6P0R",
"idempotency_key": "invoice:acct_123:2026-03-01",
"tool": "create_invoice",
"arguments": {
"account_id": "acct_123",
"amount_cents": 4900
}
}
Do not expose secrets or unnecessary personal data in this record. The operation ID is a recovery handle, not permission to retain every argument.
2. Distinguish timeout from failure
When a deadline expires, record the outcome as unknown, not failed, unless the server supplied a definitive failure response.
Then decide whether to:
- ask the server for the operation’s status;
- wait for a notification or reconnect to receive the result;
- retry with the same idempotency key;
- return a pending state to the caller.
For an inexpensive read, retrying after reconnection may be acceptable. For a write, duplicate prevention must be server-enforced or provided by the downstream API. A client cannot guarantee exactly-once effects across an uncertain network boundary by itself.
3. Cancel deliberately when possible
MCP supports cancellation for in-progress requests. The protocol-level intent is to stop processing the cancelled request and release associated resources. Depending on the transport and implementation, abandonment or a closed response stream may also be used to cancel the request.
Cancellation is best effort. Network latency means a cancellation notification can arrive after processing has completed. The receiver may also be unable to undo an already committed side effect.
Therefore, send cancellation when the user genuinely wants the work stopped, not merely because a response is slow. If the operation is already durable, cancellation should change its desired state to “cancel requested”; the server must then reconcile that request with any work already completed.
4. Reconnect and restore the session
After a transport disconnect:
- Stop sending requests on the broken connection.
- Preserve unresolved operation records.
- Re-establish the transport with bounded backoff and jitter.
- Repeat the MCP initialization and capability-negotiation sequence required by your server version.
- Resolve unresolved operations before creating new ones where ordering matters.
Use exponential backoff with jitter for repeated connection attempts. Cap the attempts and the total recovery window so one unavailable server cannot hold an agent turn indefinitely. During the backoff period, report a clear “reconnecting” or “operation pending” state to the user.
For stdio, restarting the subprocess may be necessary. For remote HTTP, reconnection does not necessarily require restarting the server process, but it does require a new transport session and any initialization required by the negotiated protocol lifecycle.
5. Look up unresolved work before retrying
The ideal long-running tool exposes three operations:
start_operation: creates durable work and returns an operation ID.get_operation: returnsrunning,succeeded,failed, orcancelled, plus the result when available.cancel_operation: requests cancellation using the same operation ID.
This API shape gives the MCP client a recovery path that does not require repeating the original side effect. The agent can start work, persist the operation ID, and poll or receive status later.
If the tool exposes only one blocking call, keep the server-side operation record anyway. The client can then use a separate status tool owned by the same server to recover the outcome.
6. Retry only with an explicit safety rule
Use one of these policies:
| Operation type | Default recovery policy |
|---|---|
| Read-only query | Reconnect and retry, with bounded backoff |
| Idempotent write | Retry with the same idempotency key |
| Non-idempotent write | Query status first; retry only with server-supported deduplication |
| Expensive or externally charged action | Require explicit user approval before another attempt |
“Non-idempotent” means repeating the call may create an additional effect even if the first attempt committed it. Sending a payment, creating a ticket, or provisioning a resource are common examples.
7. Return a truthful result to the agent
A recovering client should not translate uncertainty into success or failure. The host or downstream agent needs three clear outcomes:
- Completed: the server returned a final result.
- Failed: the server returned a terminal error.
- Pending: the outcome is not yet known or the operation continues in the background.
For a pending outcome, include the operation ID and the next recovery action. This lets the agent inform the user rather than inventing a successful completion.
How to make long-running MCP calls resumable
There are two useful architectural patterns.
Pattern A: Durable operation plus status tool
The client sends start_operation and receives an operation ID immediately. The server performs the work asynchronously and stores its state. A later get_operation call returns the state and result.
This pattern is usually the best fit for long jobs because it separates command acceptance from execution. It also scales across disconnects and process restarts. Its cost is additional server-side storage, a status API, and work to define state transitions.
Pattern B: Idempotent command with reconciliation
The client sends a synchronous command with a stable idempotency key. On timeout, it reconnects and retries. The server returns the original result when it sees the key again, even if the first attempt already committed.
This is simpler for the client, but the server must retain the key-to-result mapping for a meaningful period. If the server does not provide that guarantee, retrying is unsafe.
A hybrid often works best: use an idempotency key for immediate protection and a status lookup for operations that may outlive the original connection.
Idempotency is a contract, not a timeout setting
Increasing the client timeout does not make a side effect safe to repeat. Neither does adding a generic retry count.
An idempotent contract should define:
- which fields form the idempotency key;
- how long the key is retained;
- what response is returned for a repeated key;
- whether the key is scoped per tenant, tool, or account;
- what happens if the same key is reused with different arguments;
- how concurrent duplicates are handled.
The server must reject or flag a reused key with materially different arguments. Otherwise, “same key, changed payload” can create confusing results.
For tools that compose several downstream APIs, define the idempotency boundary carefully. If the tool creates a local record and then calls a provider, retrying may create another provider-side resource even if the local database prevents a duplicate row. Store and reuse each provider’s idempotency key across attempts.
Make resource cleanup part of the protocol
Timeouts can leave temporary resources behind: open browser sessions, cloud shells, file handles, database transactions, worker leases, or pending uploads.
Every long-running tool should have an explicit lifecycle:
- allocate resources;
- attach them to the operation record;
- renew a lease or heartbeat while work continues;
- release them on success, failure, or confirmed cancellation;
- reconcile abandoned operations after the client disappears.
Do not rely on the transport closing to clean up business resources. A TCP or HTTP disconnect may occur after the work has moved to another process or queue.
A server-side expiry policy is still necessary. It should be longer than the expected client recovery window, but finite. Expiry cleanup should be idempotent so repeated cleanup attempts are harmless.
A practical reliability checklist
Before shipping an MCP tool that can run for more than a few seconds, verify:
- The client distinguishes timeout, transport disconnect, explicit tool error, and unknown outcome.
- Every logical operation has a durable ID generated before dispatch.
- Consequential retries reuse the same idempotency key.
- The server deduplicates repeated keys or the downstream API supports idempotency.
- The client can reconnect and repeat initialization safely.
- Unresolved operations survive client process restarts.
- Long-running tools expose status and cancellation where practical.
- The agent receives a truthful pending state when completion is unknown.
- Expensive retries require explicit approval.
- Temporary resources have server-side expiry and cleanup.
- Logs correlate the business operation, MCP request, transport session, and downstream provider request.
- Metrics distinguish retries, duplicate suppressions, unknown outcomes, cancellations, and terminal failures.
Where founders should spend effort first
For an indie developer shipping an MCP product, start with the tools that create the most expensive ambiguity. A reliable read-only integration is not the same as a dependable invoice, refund, deployment, email, or customer-record write.
A reasonable order is:
- Make consequential operations idempotent.
- Add durable operation status.
- Implement reconnect and initialization recovery.
- Add cancellation and cleanup.
- Instrument unknown outcomes and duplicate suppression.
This work may feel less visible than adding another tool, but it directly protects delivery quality and support costs. It also makes your product easier to commercialize because customers can trust it with work that matters.
If your MCP server exposes tools with broad permissions, pair this reliability design with the MCP server permission scope audit checklist for founders. Recovery should not give a failed or duplicated action extra opportunities to affect the system.
FAQ
Should an MCP client always reconnect after a timeout?\n
Not automatically. First determine whether the transport is still usable and whether the server offers a status lookup. Reconnect when the transport is broken, but query unresolved work before repeating a consequential operation.
Does closing an SSE stream cancel the tool?\n
It can signal abandonment depending on the transport and server implementation, but it is not a guarantee that the side effect was prevented. Durable cancellation and idempotency are still required.
Can exactly-once execution be guaranteed over MCP?\n
No client-side mechanism can guarantee exactly-once effects across a network failure by itself. The practical goal is effectively-once business behavior: durable operation IDs, server-enforced idempotency, reconciliation, and truthful status reporting.
Should long-running tool calls use notifications or polling?\n
Choose what the server and transport can support reliably. Notifications avoid polling overhead but need a durable delivery path or status fallback. Polling is simpler and easier to recover after disconnects, but it creates repeated requests. A status operation should exist even when notifications are the preferred progress channel.
How long should idempotency records be retained?\n
Retain them for longer than the maximum client retry and recovery window, including delayed network retries and offline clients. The appropriate period depends on how long the operation can remain ambiguous; define it explicitly rather than relying on an arbitrary client setting.
Final design principle
A resilient MCP client does not equate “no response received” with “not executed.” It tracks the operation, reconnects the session, reconciles uncertain state, and retries only when the side effect is protected.
That design costs persistence, idempotency support, and some additional tool definitions. It also prevents the failure mode that quietly becomes a business incident: an agent paying twice, notifying twice, or telling the customer an operation completed when the server never ran it.
For a commercial MCP product, that is the difference between an impressive demo and infrastructure a customer can safely depend on.







