Skip to content

Add timeout configuration for HTTP request #47

@osushinekotan

Description

@osushinekotan

Is your feature request related to a problem? Please describe.
When using FastAPI-MCP to create tools for API endpoints that take longer than 5 seconds to respond, the requests timeout. Currently, the library uses httpx for making HTTP requests, which has a default timeout of 5 seconds, but there is no way to customize this timeout setting at the library user level.

This becomes problematic in production environments where some endpoints might perform complex operations that legitimately take longer than 5 seconds to complete.

Describe the solution you'd like
Add a timeout parameter to the relevant functions in the FastAPI-MCP library:

  • create_mcp_tools_from_openapi
  • create_http_tool
  • mount_mcp_server
  • add_mcp_server

This parameter would then be passed to the httpx client when making requests:

async with httpx.AsyncClient(timeout=timeout) as client:
    # existing code

This would allow users to customize timeout settings according to their specific API requirements.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions