longcall
MCP clients give up on a tool call after a fixed time: 60 seconds in many clients built on the
TypeScript SDK (MCP error -32001: Request timed out), 4 minutes in Claude Desktop
(No result received from the Claude Desktop app after waiting 4 minutes), and most of them have
no per-tool setting. Tools that run a long query, a build, a scan or a backup fail every time,
though the server is fine and would have answered.
longcall is a stdio proxy that sits in front of any MCP server and answers a slow call before the
client gives up. The call keeps running on the server; the model gets a job id and fetches the
real result later with a longcall_result tool that the proxy adds. Or, with --mode error, the
call is cancelled and the model gets an error it can read and act on, instead of a broken session.
No change to the server or the client, any language.
pip install longcall
Quick start
Put longcall proxy -- in front of the server command in your client's config:
{
"mcpServers": {
"warehouse": {
"command": "longcall",
"args": ["proxy", "--timeout", "50", "--", "npx", "-y", "@acme/warehouse-mcp"]
}
}
}
Or with uvx, nothing to install first: "command": "uvx", "args": ["longcall", "proxy", "--", ...].
What the model sees when run_report takes three minutes:
> run_report {"quarter": "Q3"}
The tool run_report is still running (over 50s), so its result is not here yet. Get it by
calling the tool longcall_result with job_id "job-5f0c2a91". Each call waits up to 50s for the
result; call it again if the job is still running. Don't start run_report again for the same
request.
> longcall_result {"job_id": "job-5f0c2a91"}
Job job-5f0c2a91 (run_report) is still running (100s so far). Call longcall_result again ...
> longcall_result {"job_id": "job-5f0c2a91"}
<run_report's own result, exactly as the server sent it>
Each step is reported on stderr (most clients show it in their MCP log):
longcall: run_report still running after 50s; answered with job job-5f0c2a91
longcall: run_report finished after 183.2s (job job-5f0c2a91)
Calls that finish within the timeout are passed on unchanged, so fast tools behave exactly as before.
Options
| Option | What it does |
|---|---|
--timeout SECONDS |
Answer a call still running after this long. Default 50, under the 60-second timeout of many clients. Set it a little under your client's limit. |
--tool NAME=SECONDS |
A different timeout for one tool. --tool NAME=off passes that tool's calls through untouched. Repeatable. |
--mode error |
Don't keep the call: tell the server to cancel it (notifications/cancelled) and give the model an error result that says it timed out after N seconds. Use this for per-tool timeouts the model can understand, with no extra tool. |
--cancel-after SECONDS |
Background mode: cancel a call that is still running after this long in all. Default: never. |
--wait SECONDS |
Longest time one longcall_result call waits for the result. Default and maximum: --timeout, so the wait never trips the client's timeout either. |
--keep N |
Finished results kept for the model to fetch. Default 100. Running jobs are always kept. |
--result-tool NAME |
Name of the added tool. Default longcall_result. |
--quiet |
Don't report on stderr. |
--log FILE |
Append reports to a file instead of stderr. |
Example: a database server whose export tool takes minutes, while every other tool should fail
fast with a clear error:
longcall proxy --mode error --timeout 20 --tool export=off -- python -m my_db_server
From Python
from longcall import run
run(["npx", "-y", "@acme/warehouse-mcp"], timeout=50, tools={"export": 600, "ping": None})
longcall.Keeper holds the message logic on its own (to_server, to_client hooks and
send_client, send_server callbacks) if you relay MCP messages yourself.
How it works
- Each
tools/callgoes to the server under an id of the proxy's own, so the proxy can answer the client and still recognise the server's late reply. A deadline starts with it. - Answer in time: the client gets it with its own id. Progress notifications pass through while the client waits.
- Deadline first (background mode): the client gets a "still running" result with a job id
(also in
_meta.longcall), and later progress notifications for that call are dropped. The server's result is stored when it arrives, andlongcall_resultreturns it as the server sent it,structuredContentandisErrorincluded. A JSON-RPC error from the server comes back as an error result with its message. longcall_resultis appended to the last page oftools/list, marked read-only and idempotent. If the server already has a tool by that name, nothing is added and a warning is printed: pick another name with--result-tool.- Deadline first (error mode): the server gets
notifications/cancelledfor the call, the client gets anisErrorresult naming the timeout. - A client that cancels a call it is still waiting for cancels it on the server too.
- Results to clients on the 2026-07-28 protocol carry
resultType: "complete".
Limits
- stdio servers only. For a remote (Streamable HTTP) server, run it through a local stdio bridge first.
- Jobs live in the proxy's memory: when the client restarts the server, running jobs and their results are lost.
- For tools that declare an
outputSchema, the "still running" answer is markedisError, because clients reject a normal result withoutstructuredContent. The text still tells the model to fetch the result. - The model has to follow the instruction to call
longcall_result. A model that ignores it will report the job as pending, so the text is written to be followed. - It does not change a client's own timeout. It only answers before that timeout runs out, so
set
--timeoutbelow it. - Servers built on old releases of the MCP Python SDK (1.10 to 1.12 tested; 1.25 is fine) stop
answering after any cancelled request, so with those use background mode without
--cancel-after. - A call answered with a job id keeps running on the server. Tools with side effects still take
effect, even if the model never fetches the result. Use
--mode erroror--cancel-afterwhen that is not what you want.
Why this exists
Long tool calls failing on a client timeout is one of the most reported MCP problems, and most clients have one global timeout or none you can set:
- anthropics/claude-code#65643: Claude Desktop ends any call after 4 minutes, and the bridge wedges after a few timeouts.
- modelcontextprotocol/typescript-sdk#245: the client times out after 60 seconds whatever the timeout option says.
- anthropics/claude-code#16837:
MCP_TIMEOUTover 60 seconds is ignored. - kirodotdev/Kiro#126: MCP request timeouts.
- livekit/agents#8523 and QwenLM/qwen-code#18323: per-tool timeouts, and timeouts the model and the caller can tell apart from other failures.
- infiniflow/ragflow#23003: a tool timeout should reach the model as a result, not fail the whole run.
The MCP Tasks extension solves this properly for clients and servers that support it. longcall is for the many that don't yet.
License
MIT
Metadata
Release files for longcall 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| longcall-0.1.0.tar.gz | 22.5 kB | Without provenance | Details for longcall-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| longcall-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for longcall-0.1.0-py3-none-any.whl |
Total release size: 39.6 kB
Release files / longcall-0.1.0.tar.gz
| Download URL | longcall-0.1.0.tar.gz |
|---|---|
| Size | 22.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c642c32103fe6356fcbd21dcfa38cd080058530fa20b2f50e6299c281cd42ea3
|
|
BLAKE2b-256 checksum How to use checksums |
6600e1f225654810c541567eca18cb9bd8f59a186f398101bc184343af8e2eeb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / longcall-0.1.0-py3-none-any.whl
| Download URL | longcall-0.1.0-py3-none-any.whl |
|---|---|
| Size | 17.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6451ee1ae53442a07ccf25cd8b56ce9fc8a1478d9b3abd04436a0579634f6989
|
|
BLAKE2b-256 checksum How to use checksums |
5ca83512b86ba865d722a247ed303f21186bee93858b25d63980b4b5dc829381
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for longcall 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.