Skip to content

Conversation

pablotp
Copy link
Contributor

@pablotp pablotp commented Sep 22, 2025

Description

Adds configurable request timeout support to prevent timeouts with slow MCP servers.
Some MCP servers like Perplexity's often require more than 60 seconds to respond, especially for research operations that need to search and analyze multiple sources.

Changes

  • Added --requestTimeout CLI option (default: 300000ms / 5 minutes)

Implementation Details

  • Uses existing MCP SDK's RequestOptions.timeout parameter
  • Default increased from SDK's 60s to 5 minutes to accommodate research-heavy operations (@punkpeye let me know if you prefer having a different default).

Testing

  • Created slow server test fixture with configurable delays
  • Tests use reduced timeouts (300-1000ms) to keep CI fast

Run timeout tests

npm test -- proxyServer.test.ts

Manual testing

Default 5-minute timeout

npx mcp-proxy --port 8080 -- your-mcp-server

Custom 10-minute timeout for very slow operations

npx mcp-proxy --port 8080 --requestTimeout 600000 -- your-mcp-server

Using environment variable

MCP_PROXY_REQUEST_TIMEOUT=120000 npx mcp-proxy --port 8080 -- your-mcp-server

Test with slow fixture (2-second delay)

RESPONSE_DELAY=2000 npx tsx src/bin/mcp-proxy.ts --requestTimeout 3000 tsx src/fixtures/slow-stdio-server.ts

Breaking Changes

  • None. Timeout configuration is optional and defaults to a longer timeout for better compatibility.

@pablotp pablotp marked this pull request as ready for review September 22, 2025 14:02
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

Successfully merging this pull request may close these issues.

1 participant