Skip to content
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

Tool timeout within 10 seconds causing MCP server disconnect #212

Open
dino-su opened this issue Feb 17, 2025 · 0 comments
Open

Tool timeout within 10 seconds causing MCP server disconnect #212

dino-su opened this issue Feb 17, 2025 · 0 comments

Comments

@dino-su
Copy link

dino-su commented Feb 17, 2025

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."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant