Repository navigation
feat: configurable per-server MCP initialize/handshake timeout (#760) - #762
Conversation
Deploying mcpproxy-docs with
|
| Latest commit: |
a0084a2
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://41913ed8.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://feat-mcp-760-configurable-in.mcpproxy-docs.pages.dev |
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 28120836717 --repo smart-mcp-proxy/mcpproxy-go
|
Dumbris
left a comment
There was a problem hiding this comment.
ACCEPT — CEO review covering CodexReviewer's failed run (usage-limit fallback, MCP-3361).
Summary
PR #762 adds a configurable per-server / global MCP initialize handshake timeout (init_timeout), fixing the silent 30-second hardcode that killed slow-starting stdio upstreams (GH #760 / MCP-3322).
What was checked
- Config layer (
internal/config/config.go,merge.go): tri-state*Durationwith correct per-server → global → 30s default resolution.ResolveInitTimeoutmaps ≤0 back to the default (never a hang-forever deadline). Validation enforces {0s} ∪ [1s, 30m]. - Connect path (
internal/upstream/manager.go):resolveConnectTimeoutwires the resolved timeout into the actualinitializehandshake; Docker-isolated servers keep a 3-minute floor. No regression on existing Docker grace period. - CLI (
cmd/mcpproxy/upstream_cmd.go):--init-timeoutflag onupstream patchwith client-side duration parse (fast-fail before hitting the daemon). - HTTP API / contracts: GET surfaces the per-server override; generic-map converter round-trips the duration string back to
*config.Duration. - Tests: all config/contracts/upstream packages pass locally.
No correctness issues. ACCEPT.
Dumbris
left a comment
There was a problem hiding this comment.
ACCEPT (code-review verdict — MCP-3365) — MCP-3322 configurable init/handshake timeout
All 11 affected packages build and test clean at head 29f05614:
internal/config, internal/upstream, internal/contracts, internal/management, internal/httpapi, internal/storage — all pass.
What the PR does:
- Adds
init_timeoutas a tri-state*Durationon bothConfig(global) andServerConfig(per-server override), validated to{0} ∪ [1s, 30m]. Config.ResolveInitTimeoutapplies per-server → global → 30s default precedence; zero/negative always maps to 30s (never a hang-forever deadline).upstream.Manager.resolveConnectTimeoutreplaces the hard-coded 30s (and Docker-only 3min) inAddServerandConnectAllwith the resolved timeout, keeping the 3min floor for Docker isolation.- Exposed through: REST PATCH/GET, MCP
upstream_serverstool, CLImcpproxy upstream patch --init-timeout, storage round-trip, docs.
No issues found. Implementation is conservative (defaults preserved), tests are comprehensive, nil-preserve tri-state semantics are consistent with existing HealthCheckInterval/ToolDiscoveryInterval fields.
Verdict: ACCEPT — ready to merge.
CEO Review (auto-review gate, MCP-3369)VERDICT: ACCEPT Correctness is sound — Minor notes (non-blocking)
None of these block merge. |
Add init_timeout (global default + per-server override) controlling the deadline for an upstream's MCP initialize handshake. Un-isolated stdio servers previously inherited the caller's ~30s context and were killed mid-startup during legitimate first-run warmup (cache/index build); with docker run --rm the partial work was discarded and retries looped forever (GH #760). - config: InitTimeout *Duration on Config and ServerConfig; ResolveInitTimeout (per-server > global > 30s default; <=0 maps to default, never disabled); bounds {0} u [1s,30m] in Validate(). - upstream/manager: resolveConnectTimeout applied at AddServer, ConnectAll (wrap ALL connects, not just Docker), and the post-OAuth retry; Docker isolation keeps a 3m floor, a larger override still wins. - Plumb init_timeout through the upstream_servers MCP tool (add/patch), REST AddServerRequest allowlist + GET serialization, config merge/copy, storage UpstreamRecord, contracts.Server, and mcpproxy upstream patch --init-timeout. - Docs (configuration.md) + regenerated oas/swagger.yaml. Related #760
29f0561 to
a0084a2
Compare
There was a problem hiding this comment.
✅ Gatekeeper approval — review verdict: ACCEPT (by ClaudeReviewer+KimiReviewer, model-diverse fallback).
This approval is posted automatically by the MCPProxy Gatekeeper App on behalf of ClaudeReviewer+KimiReviewer — the model-diverse reviewer-fallback reviewer of record (verdict lives in the Paperclip review thread). Author≠approver satisfied; QA + CI gates enforced separately.
Auto-approved per Model B (MCP-1249) + reviewer-fallback (MCP-3066).
Summary
Adds a configurable
init_timeout(global default + per-server override) controlling the deadline for an upstream's MCPinitializehandshake. Closes the bite in GH #760.Problem (from #760): a stdio upstream's
initializedeadline was effectively hardcoded ~30s. Servers doing legitimate first-run warmup (cache build, index, prefetch) before answeringinitializewere killed mid-startup (did not respond to MCP initialize within 27.2s). Withdocker run --rmthe partial work was discarded → retries loop forever. Real case:ghcr.io/korotovsky/slack-mcp-servercaching ~970 channels / 3740 users.Root cause: only
IsDockerIsolated()servers got a 3-minute connect context inConnectAll; un-isolated stdio servers inherited the caller's ~30s context.AddServerhad a hardcoded 30s. The post-OAuth retry inherited its ctx too.What changed
InitTimeout *DurationonConfig(global) andServerConfig(per-server).ResolveInitTimeoutapplies per-server → global → 30s default; a resolved value<= 0maps to the default (never "no deadline" — avoids hang-forever). Bounds{0} ∪ [1s, 30m]validated inValidate(), mirroring the discovery-interval bounds.resolveConnectTimeoutapplied atAddServer,ConnectAll(now wraps all connects, not just Docker), and the post-OAuth retry. Docker-isolated servers keep a 3-minute floor; a larger override still wins. The OAuth retry keeps a 2-minute floor.auto_approve_tool_changes, MCP-2930/2940):upstream_serversMCP tool (add/patch), RESTAddServerRequestallowlist + GET serialization (contracts.Server, the managementListServersprojection, and the runtimeserverMap), config merge/copy, storageUpstreamRecord(+ reflection-coverage test), and a newmcpproxy upstream patch --init-timeoutflag.docs/configuration.md(global + per-server, alongsidecall_tool_timeout); regeneratedoas/swagger.yaml.Acceptance (#760)
init_timeout: 120sserver gets up to 120s to completeinitialize.upstream_serverstool, andmcpproxy upstream patch.call_tool_timeout.Tests & verification
TDD throughout (failing test → implement → green):
internal/config: resolver precedence + bounds validation.internal/upstream:resolveConnectTimeout— unset→30s, per-server honored on un-isolated stdio (the feat: configurable per-server MCP initialize/handshake timeout #760 bite), Docker 3m floor, larger override wins.internal/config/merge: patch sets/replaces/preservesinit_timeout.internal/contracts+internal/httpapi+internal/management: GET/PATCH round-trip projections.Local verification:
go test -race ./internal/config/... ./internal/contracts/... ./internal/storage/... ./internal/upstream/... ./internal/httpapi/... ./internal/management/... ./internal/runtime/... ./cmd/mcpproxy/...— green.golangci-lint run --config .github/.golangci.ymlon all touched packages — 0 issues.upstream patch warmup --init-timeout 120s→upstream list -o jsonreads backinit_timeout: "2m0s"; invalid value rejected fail-fast; unset omitted.Related #760