Skip to content

Tool timeout within 10 seconds causing MCP server disconnect #212

Closed

Description

@dino-su

Description

The FastMCP server tools consistently timeout after 10 seconds of execution, triggering error code -32001 and forcing client disconnections:

2025-02-17T03:13:34.973Z [web-reader] [info] Message from client: {"jsonrpc":"2.0","method":"notifications/cancelled","params":{"requestId":27,"reason":"Error: MCP error -32001: Request timed out"}}

Impact:

  1. All tool operations exceeding 10 seconds are forcefully cancelled
  2. Server generates unhanded exceptions upon timeout
  3. Client connections are terminated unexpectedly

Current Implementation

@mcp.tool(description="long running task") 
async def run(task: str) -> str:
    await asyncio.sleep(10)  # Task running for exactly 10 seconds
    return f"Task {task} completed."

Expected Behavior

  • Configurable timeout thresholds for tool operations
  • Graceful task cancellation with proper resource cleanup

Technical Questions

  1. What is the FastMCP server's default timeout threshold?
  2. How can the timeout threshold be configured per tool or globally?
  3. What is the recommended approach for implementing long-running tools?

Environment

  • FastMCP Server: v1.2.1

Reproduction Code

"""
Minimal reproduction case for FastMCP tool timeout issue.
"""

import asyncio
from mcp.server.fastmcp import FastMCP

mcp = FastMCP("timeout-demo")

@mcp.tool(description="long running task")
async def run(task: str) -> str:
    """
    Simulates a long-running task with 10-second duration.
    
    Args:
        task: Task identifier
    """
    await asyncio.sleep(10)
    return f"Task {task} completed."

Activity

  1. dino-su commented on Mar 7, 2025

    @dino-su
    Author

    Closing this issue as it's no longer reproducible on MCP SDK v1.30 and the Claude Desktop v0.8.0.

  2. epinault commented on Mar 26, 2025

    @epinault

    did you get an answer on the questions though?

    What is the FastMCP server's default timeout threshold?
    How can the timeout threshold be configured per tool or globally?
    What is the recommended approach for implementing long-running tools?

    I don t see how this is working either

  3. stronk7 commented on Mar 28, 2025

    @stronk7
  4. SinOverCos commented on Apr 5, 2025

    @SinOverCos

    @stronk7 thanks for the link to the client-side timeout. Do you also have any links for the server-side limits?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions