You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: increase HTTP backend connect timeout from 5s to 30s and make configurable (#3782)
## Problem
When an HTTP MCP backend is slow to initialize (e.g. cold-starting
LiteLLM proxy taking 21s), the gateway's hardcoded **5-second
per-transport connect timeout** causes all three SDK transport attempts
to fail. The tool registration silently drops the backend's tools and
the agent starts without them.
From the issue logs:
```
[2026-04-13T16:37:36Z] [DEBUG] GetOrLaunch called for server: opslevel
[2026-04-13T16:37:57Z] [INFO] Successfully registered tools from opslevel (took 21.213743169s)
```
The 21s is consumed by the transport fallback chain: streamable HTTP (5s
timeout) → SSE (5s timeout) → plain JSON (~11s). If the backend only
supports streamable HTTP, all three transports fail and tools are
silently dropped.
## Fix
### 1. Configurable per-transport connect timeout (default 30s → was 5s)
New `connect_timeout` field on server config:
**TOML:**
```toml
[servers.opslevel]
type = "http"
url = "http://opslevel-proxy:8080/mcp"
connect_timeout = 60 # seconds per transport attempt
```
**JSON stdin:**
```json
{
"mcpServers": {
"opslevel": {
"type": "http",
"url": "http://opslevel-proxy:8080/mcp",
"connect_timeout": 60
}
}
}
```
### 2. Better error visibility
- Failed backend tool registration promoted from **WARN → ERROR**
- Summary error log lists which backends failed and impact on agents:
`Tool registration incomplete: 1 of 3 backends failed: [opslevel] —
agents will not see tools from these servers`
### 3. Reconnect uses stored timeout
The connect timeout is stored on the Connection struct so
`reconnectSDKTransport` reuses the same value instead of a hardcoded
10s.
## Changes
| File | Change |
|------|--------|
| `config_core.go` | Add `ConnectTimeout` field, `HTTPConnectTimeout()`
helper, `DefaultConnectTimeout` constant |
| `config_stdin.go` | Add `ConnectTimeout` to `StdinServerConfig`, map
it during conversion |
| `connection.go` | Add `connectTimeout` to `Connection`, apply default
of 30s when ≤ 0 |
| `http_transport.go` | Pass configurable timeout through
`trySDKTransport` and `newHTTPConnection` |
| `launcher.go` | Pass `serverCfg.HTTPConnectTimeout()` to
`NewHTTPConnection` |
| `tool_registry.go` | Promote failed backends to ERROR, add summary log
|
| Tests | Updated all `NewHTTPConnection` call sites with new parameter
|
Fixes#3718
logger.LogWarn("backend", "⚠️ MCP over SSE (2024-11-05 spec) is DEPRECATED for url=%s. Please migrate to streamable HTTP transport (2025-03-26 spec).", url)
247
261
logger.LogInfo("backend", "Configured HTTP MCP server with SSE transport: %s", url)
0 commit comments