Skip to content

feat(core): allow mcp.json to override connect/discover timeouts#136

Merged
bug-ops merged 1 commit into
masterfrom
serverconfig-connect-discover
Jul 9, 2026
Merged

feat(core): allow mcp.json to override connect/discover timeouts#136
bug-ops merged 1 commit into
masterfrom
serverconfig-connect-discover

Conversation

@bug-ops

@bug-ops bug-ops commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds optional connectTimeoutSecs/discoverTimeoutSecs fields to McpServerEntry (mcp.json, camelCase) and IntrospectServerParams (MCP tool params), wired into the existing ServerConfigBuilder setters only when present so omitting them preserves the current 30s defaults.
  • Bounds (0 < timeout <= 600s) are enforced once inside validate_server_config, the single security gate both the CLI (--from-config) and mcp-execution-server paths already funnel through via discover_server — the check cannot be bypassed.
  • Maps timeout validation failures on the MCP introspect_server path to invalid_params instead of internal_error, matching the existing validate_server_id error handling.
  • Fully additive/backward compatible: existing mcp.json files without the new keys are unaffected.

Context

ServerConfig gained connect_timeout/discover_timeout (30s defaults) in #120 to bound Introspector::discover_server's awaits, but there was no path from ~/.claude/mcp.json to those fields. This closes that gap per #128.

Developed via architect -> critic -> developer -> (tester, perf, security, impl-critic) -> reviewer pipeline; see .local/handoff/ for the full design rationale, adversarial critique, and validation reports.

Test plan

  • cargo +nightly fmt --check
  • cargo +stable clippy --all-targets --all-features --workspace -- -D warnings
  • cargo nextest run --all-features --workspace --no-fail-fast (707 passed, 2 pre-existing unrelated leaky tests)
  • cargo test --doc --all-features --workspace
  • RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links" cargo doc --no-deps
  • New unit tests: backward-compat defaults, values reaching ServerConfig, zero/above-MAX_TIMEOUT rejection, in-bounds acceptance, S1 error-mapping end-to-end

Closes #128

@github-actions github-actions Bot added area: cli CLI commands and interface area: bridge MCP bridge and integration area: core Core types and infrastructure crate: mcp-core Changes to mcp-core crate (foundation types, traits, errors) crate: mcp-cli Changes to mcp-cli crate (command-line interface) type: documentation Documentation changes (*.md, docs/, comments) breaking change Contains breaking API changes (requires major version bump) release Release preparation (changelog, version bumps) labels Jul 9, 2026
@bug-ops
bug-ops enabled auto-merge (squash) July 9, 2026 15:38
ServerConfig's connect_timeout/discover_timeout (added in #120) were
only reachable through the builder, so every server configured via
mcp.json or the mcp-server MCP tool was locked to the 30s defaults.

Add optional connectTimeoutSecs/discoverTimeoutSecs to McpServerEntry
and IntrospectServerParams, wired into the existing builder setters
only when present so omitting them preserves the current defaults.
Bounds (0 < timeout <= 600s) are enforced once in validate_server_config,
the single gate both the CLI and mcp-server paths already funnel
through via discover_server, so the check can't be bypassed. Map
validation failures on the MCP introspect_server path to invalid_params
instead of internal_error, matching the sibling validate_server_id
error handling.

Closes #128
@bug-ops
bug-ops force-pushed the serverconfig-connect-discover branch from 259ddd4 to bffd0e9 Compare July 9, 2026 15:39
@bug-ops
bug-ops merged commit dc581ba into master Jul 9, 2026
17 checks passed
@bug-ops
bug-ops deleted the serverconfig-connect-discover branch July 9, 2026 15:44
bug-ops added a commit that referenced this pull request Jul 9, 2026
Replace the two untracked TODO(critic) markers left by #136 with
TODO(#N) references to newly filed issues #144 and #145, matching the
project's convention of linking deferred design decisions to a
tracked issue.

Closes #138
bug-ops added a commit that referenced this pull request Jul 9, 2026
…rospect

Expose --connect-timeout-secs and --discover-timeout-secs on the manual
(non-from-config) introspect and generate commands, routed through the
same validate_server_config chokepoint used by mcp.json's
connectTimeoutSecs/discoverTimeoutSecs, so both paths accept and reject
identical values.

Also documents the decision to permanently reject a zero timeout rather
than treat it as "no timeout": an unbounded wait would let a hung or
malicious server block this tool's non-interactive CLI/MCP-server
invocations forever, reopening the DoS exposure these timeouts were
introduced to close.

Resolves the two TODO(critic) markers left by #136.

Closes #144, #145
bug-ops added a commit that referenced this pull request Jul 9, 2026
…rospect (#150)

Expose --connect-timeout-secs and --discover-timeout-secs on the manual
(non-from-config) introspect and generate commands, routed through the
same validate_server_config chokepoint used by mcp.json's
connectTimeoutSecs/discoverTimeoutSecs, so both paths accept and reject
identical values.

Also documents the decision to permanently reject a zero timeout rather
than treat it as "no timeout": an unbounded wait would let a hung or
malicious server block this tool's non-interactive CLI/MCP-server
invocations forever, reopening the DoS exposure these timeouts were
introduced to close.

Resolves the two TODO(critic) markers left by #136.

Closes #144, #145
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: bridge MCP bridge and integration area: cli CLI commands and interface area: core Core types and infrastructure breaking change Contains breaking API changes (requires major version bump) crate: mcp-cli Changes to mcp-cli crate (command-line interface) crate: mcp-core Changes to mcp-core crate (foundation types, traits, errors) release Release preparation (changelog, version bumps) type: documentation Documentation changes (*.md, docs/, comments)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ServerConfig connect/discover timeouts are not configurable via mcp.json

1 participant