Skip to content

Support per-server timeouts for long-running MCP tool calls - #515

Open
praaline wants to merge 1 commit into
MarimerLLC:mainfrom
praaline:feat-timeouts
Open

Support per-server timeouts for long-running MCP tool calls#515
praaline wants to merge 1 commit into
MarimerLLC:mainfrom
praaline:feat-timeouts

Conversation

@praaline

Copy link
Copy Markdown

Summary

Adds support for MCP servers whose tool calls legitimately require a longer
execution budget, while preserving the existing timeout behavior for ordinary
MCP servers.

Closes #514.

Changes

  • adds optional ToolTimeoutMs to McpBridgeServerConfig;
  • keeps the existing default timeout for servers without an override;
  • caps per-server timeouts using MaxTimeoutMs;
  • separates the timeout advertised by McpToolProxy from how long the proxy
    waits for the bridge to respond;
  • raises the bridge maximum to permit calls up to 15 minutes;
  • configures the agent proxy to wait slightly longer than the bridge maximum
    so timeout responses can propagate normally.

Example:

{
  "file-analysis": {
    "toolTimeoutMs": 900000
  }
}

Why

Some analytical MCP operations can legitimately take several minutes. The
previous proxy timeout caused these calls to fail even though the downstream
MCP operation would complete successfully if allowed to continue.

Per-server configuration avoids increasing the normal execution timeout for
all MCP services.

Tests

Added regression coverage for:

  • the proxy waiting longer than the timeout advertised to the bridge;
  • ToolTimeoutMs remaining invocation policy rather than MCP server identity.

dotnet test RockBot.slnx passes.

@rockfordlhotka
rockfordlhotka self-requested a review August 24, 2026 14:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds per-server timeout support for long-running MCP tool calls by introducing toolTimeoutMs in mcp.json, raising the bridge’s maximum allowed timeout to 15 minutes, and decoupling the timeout the agent proxy advertises to the bridge from how long the proxy waits for a response.

Changes:

  • Added ToolTimeoutMs to McpBridgeServerConfig and applied it as an override when determining the bridge’s effective tool-call timeout (capped by MaxTimeoutMs).
  • Increased McpBridgeOptions.MaxTimeoutMs to 900,000 ms (15 minutes) and updated the bridge timeout parsing accordingly.
  • Updated McpToolProxy to support separate requestTimeout (advertised) and responseTimeout (local wait) and added regression tests for the separation.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/RockBot.Tools.Tests/McpToolProxyTests.cs Adds regression test ensuring proxy can wait longer than the timeout it advertises to the bridge.
tests/RockBot.Agent.Tests/McpBridgeServerConfigTests.cs Ensures ToolTimeoutMs does not affect canonical server identity (dedup/registration stability).
src/RockBot.Tools.Mcp/McpToolProxy.cs Splits advertised request timeout from proxy response wait timeout.
src/RockBot.Tools.Mcp/McpServiceCollectionExtensions.cs Updates DI registration to construct McpToolProxy with separate timeouts.
src/RockBot.Agent/Program.cs Configures agent MCP proxy with a short advertised timeout and a longer response wait.
src/RockBot.Agent/McpBridge/McpBridgeService.cs Applies per-server tool timeout override (capped) when executing tool calls.
src/RockBot.Agent/McpBridge/McpBridgeServerConfig.cs Introduces ToolTimeoutMs in the bridge server config model.
src/RockBot.Agent/McpBridge/McpBridgeOptions.cs Raises the bridge’s maximum allowed timeout to 15 minutes.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +41 to +42
_requestTimeout = requestTimeout ?? TimeSpan.FromSeconds(60);
_responseTimeout = responseTimeout ?? _requestTimeout;
Comment on lines +311 to +314
agent.AddToolHandler();
agent.AddMcpToolProxy(
requestTimeout: TimeSpan.FromSeconds(60),
responseTimeout: TimeSpan.FromSeconds(930));
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.

Allow per-server timeouts for long-running MCP tool calls

4 participants