Skip to content

Hardcoded 120s HTTP WriteTimeout caps every tool call, and the resulting timeout evicts the upstream for all clients #965

Closed

Description

@luutuankiet

Summary

internal/server/server.go hardcodes the HTTP server's WriteTimeout at 120s, with no configuration override anywhere in internal/config/. Any upstream tool call whose response takes longer than 120s has its response destroyed in transit — and, worse, the resulting context deadline exceeded is classified as a connection error, so the upstream server is marked failed and disconnected for every client of that upstream, not just the caller.

Where

v0.53.0, internal/server/server.go:2488-2490:

ReadTimeout:       120 * time.Second, // Full request read timeout
WriteTimeout:      120 * time.Second, // Response write timeout
IdleTimeout:       180 * time.Second, // Keep-alive timeout for persistent connections

These are the same line numbers on main. Grepping internal/config/ for ReadTimeout|WriteTimeout|IdleTimeout returns only WorkspaceIdleTimeout (workspace GC, unrelated) — so there is no way to raise this by configuration in any released version.

Why it matters

Plenty of legitimate upstream tool calls exceed two minutes: container builds, dependency installs, dbt/warehouse runs, database migrations, test suites — anything routed through a filesystem/shell MCP server.

The failure is two-part:

  1. The remote work runs to completion; only the response is destroyed. The caller cannot tell whether the side effects happened.
  2. isConnectionError in internal/upstream/managed/client.go (~line 1334) matches deadline exceeded, so the timeout is treated as a connection-level failure. The upstream transitions to Error and is dropped until reconnect.

Net effect: one long-running call from one client takes an entire upstream server offline for every other client. Observed in practice as Server 'X' is not connected (state: Error) across unrelated sessions immediately after a single slow call.

Note that #470 (consecutive-failure threshold before marking a server errored) addresses the health-check path. The direct call path still evicts on the first timeout, so that fix does not cover this case.

Request

Make the HTTP server timeouts configurable, with 0 meaning "no timeout":

{
  "http_read_timeout": "120s",
  "http_write_timeout": "0s",
  "http_idle_timeout": "180s"
}

Per-listener would be sufficient; per-upstream would be ideal, since "this server runs builds" is a property of the upstream.

There is direct precedent for this shape: #760 / #762 made the MCP initialize/handshake timeout configurable per server for exactly the same reason (a hardcoded constant that was too low for some upstreams).

Secondary, separable ask: consider not treating a call-path deadline as a connection-level failure. A slow tool is not a dead server, and conflating the two turns a single slow call into a multi-client outage.

Environment

  • mcpproxy v0.43.0 deployed; confirmed unchanged in v0.53.0
  • Linux, streamable-http listener, mix of stdio and http upstreams
  • Reproduces reliably with any upstream tool call that takes >120s to return

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions