Skip to content

Agentcore MCP server - Failed to invoke MCP tool: MCP error -32001: Request timed out

0

I have deployed FastMCP servers in the AWS AgentCore runtime following the documentation here: https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-mcp.html

One of my MCP tools requires approximately 125 seconds to complete execution. However, when invoked through the AWS AgentCore runtime, it consistently fails with the following error after about 60 seconds:

Failed to invoke MCP tool: MCP error -32001: Request timed out

On the client side (Amazon Q), the timeout is configured for 15 minutes. I also attempted to configure the environment variables MCP_TIMEOUT and READ_TIMEOUT—both set to 10 minutes—but the issue persists.

Additionally, I tried adding timeout parameters directly in my code (e.g., on mcp.run() and the FastMcp() constructor), but these do not appear to accept or honor timeout arguments at this time.

When testing the same FastMCP service locally using the same client via a localhost endpoint, the request completes successfully without timing out.

Question: Is there an enforced timeout within the AWS AgentCore runtime related to MCP tool execution? If so, how can this timeout be extended or configured to support long-running tasks (e.g., 2–3 minutes)?

asked 10 months ago980 views

1 Answer
0

When working with MCP servers in Amazon Bedrock AgentCore Runtime, long-running tools can get interrupted after a timeout period. For tools that take longer than 60 seconds to complete (like your 125-second tool), you need to implement ping handlers with a HEALTHY_BUSY status for asynchronous tasks.

The issue you're experiencing is likely related to the default timeout behavior in AgentCore Runtime. While you've set MCP_TIMEOUT and READ_TIMEOUT environment variables, these may not be affecting the underlying timeout mechanism in the AgentCore Runtime service.

For long-running tools in AgentCore Runtime, you should:

  1. Implement ping handlers in your FastMCP server that return a HEALTHY_BUSY status for tasks that are still processing
  2. Verify that your MCP server is correctly listening on 0.0.0.0:8000/mcp/, which is the default path expected by AgentCore Runtime
  3. Check that your container is properly exposing the required ports and endpoints

The fact that your tool works locally but times out in AgentCore Runtime suggests there might be a configuration difference between your local environment and the deployed environment. The AgentCore Runtime service may have stricter timeout policies than your local setup.

Consider reviewing your CloudWatch logs for any additional error information and ensure your MCP server implementation follows the stateless streamable-HTTP server requirements of AgentCore Runtime.
Sources
Troubleshoot AgentCore Runtime - Amazon Bedrock AgentCore
Deploy MCP servers in AgentCore Runtime - Amazon Bedrock AgentCore

answered 10 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.