Skip to content

mcp client times out after 60 seconds (ignoring timeout option) #245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
emsi opened this issue Mar 31, 2025 · 7 comments
Open

mcp client times out after 60 seconds (ignoring timeout option) #245

emsi opened this issue Mar 31, 2025 · 7 comments
Labels
bug Something isn't working

Comments

@emsi
Copy link

emsi commented Mar 31, 2025

Describe the bug
The JS/TS client sdk has 60 seconds timeout that is not affected by server sending progress update.
On the same mcp server tool, the python client sdk works as expected but the js/ts sdk times out with:

file:///.../@modelcontextprotocol/sdk/dist/esm/shared/protocol.js:282
            const timeoutHandler = () => cancel(new McpError(ErrorCode.RequestTimeout, "Request timed out", { timeout }));
                                                ^

McpError: MCP error -32001: Request timed out
    at Timeout.timeoutHandler (file:///.../@modelcontextprotocol/sdk/dist/esm/shared/protocol.js:282:49)
    at listOnTimeout (node:internal/timers:611:17)
    at process.processTimers (node:internal/timers:546:7) {
  code: -32001,
  data: { timeout: 60000 }
}

Node.js v23.10.0

I have created an mcp server that is doing some "heavy" task that takes more than 60 seconds, though this server sends progress updates every 5 seconds to keep the connection alive.

You can run the server like this:
uvx --quiet --refresh git+https://github.com/emsi/slow-mcp --transport sse
(requires uvx! https://docs.astral.sh/uv/getting-started/installation/)

I've created two clients. Python and Typescript:

https://github.com/emsi/slow-mcp/blob/master/src/client.py
https://github.com/emsi/slow-mcp/blob/master/src/client.mjs

When I run the tests with python client it works as expected:

$ python3 ./src/client.py 
[03/31/25 22:05:22] INFO     Processing request of type ListResourcesRequest                                                                                                                 server.py:534
                    INFO     Processing request of type ListToolsRequest                                                                                                                     server.py:534
Tools: meta=None nextCursor=None tools=[Tool(name='run_command', description='Run command and report progress.', inputSchema={'properties': {'timeout': {'default': 300, 'title': 'Timeout', 'type': 'integer'}}, 'title': 'run_commandArguments', 'type': 'object'})]
                    INFO     Processing request of type CallToolRequest                                                                                                                      server.py:534
Result: meta=None content=[TextContent(type='text', text='1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59\n60\n61\n62\n63\n64\n65\n66\n67\n68\n69\n70\n71\n72\n73\n74\n75\n76\n77\n78\n79\n80\n81\n82\n83\n84\n85\n86\n87\n88\n89\n90\n91\n92\n93\n94\n95\n96\n97\n98\n99\n100\n101\n102\n103\n104\n105\n106\n107\n108\n109\n110\n111\n112\n113\n114\n115\n116\n117\n118\n119\n120\n121\n122\n123\n124\n125\n', annotations=None)] isError=False

The server just calls the following script that prints number of seconds lapsed:

#!/bin/sh

for sec in $(seq 1 125); do
    sleep 1
    echo "$sec"
done

However the Typescript/JS client times out after 60000 milliseconds!

To Reproduce

  1. Make sure to install uv: curl -LsSf https://astral.sh/uv/install.sh | sh (my slow_mcp server requires it)
  2. Download example client: https://github.com/emsi/slow-mcp/blob/master/src/client.mjs
  3. Install sdk npm install @modelcontextprotocol/sdk :)
  4. Run the client: node src/client.mjs

Expected behavior
The timeout should be longer. Some tasks might easily take more than few minutes and if the server is sending updates or pings the timeout should reset.
At the very least both python and js/ts sdk should have identical, longer, timeouts.

@emsi emsi added the bug Something isn't working label Mar 31, 2025
@emsi emsi changed the title mcp client times out after 60 seconds mcp client times out after 60 seconds (ignoring timeout option) Apr 3, 2025
@jrubins
Copy link

jrubins commented Apr 4, 2025

@emsi I'm an MCP newbie, but the following seemed to extend the timeout for me:

await client.callTool(
  {
    name: ...,
    arguments: ...,
  },
  undefined,
  { timeout: 300000 },
);

@emsi
Copy link
Author

emsi commented Apr 4, 2025

@emsi I'm an MCP newbie, but the following seemed to extend the timeout for me:

Not with the test server that I provided. That's why I provided reproducible examples.

Clearly both python and js/ts SDK diverge here.

@AbhishekkGautam
Copy link

Any update on this issue? I’m also getting the same timeout issue. Tried passing the timeout value in connect & callTool but it’s not overriding the default value.

@SivasankarMathiyazhagan

I’m facing the same issue. Has anyone fixed it? It would be helpful if someone could share their solution.

@knightswatch3
Copy link

I am not doing any heavy task. Just the connect is giving me this error. And yea, I am using my client TypescriptSDK and server with PythonSDK over SSE.
I get no connection errors when I connect my client via SSEClientTransport class but I face this issue with Streams.

@pit-heqiang
Copy link

I am connected via SSE, and the server execution speed is <1, so the tool results are returned. However, the client still times out after waiting for 60 seconds. Moreover, I am connected locally without any proxy. Has anyone encountered any good solutions? {"code":-32001,"data":{"timeout":60000},"name":"McpError"}

@LostInBrittany
Copy link

Same problem here with stdio server. Anybody has a solution or simply a clue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants