Skip to content

fix(mcp): dedicated timeout for initialize handshake - #102

Merged
Svagtlys merged 5 commits into
developfrom
fix/mcp-initialize-timeout
Sep 25, 2026
Merged

Svagtlys merged 5 commits into
developfrom
fix/mcp-initialize-timeout

Conversation

@Svagtlys

@Svagtlys Svagtlys commented Sep 23, 2026 •

Copy link
Copy Markdown
Owner

Closes #101

Summary

The MCP initialize handshake previously borrowed the steady-state per-request timeout (request_timeout_seconds) as its start-up budget, so callers who tightened that knob strangled slow-to-boot servers (and flaked tests). This PR gives the handshake its own budget:

  • New setting: McpSettings.initialize_timeout_seconds (default 30.0, env OCTAVE_MCP_INITIALIZE_TIMEOUT_SECONDS) in octave/mcp/config.py.
  • Client swap: _await_initialize()'s fail_after and connect()'s timeout error message now read the dedicated knob; _run() and the steady-state budget are untouched. Zero-impact for default settings (both default to 30 s).
  • Docs: OCTAVE_MCP_INITIALIZE_TIMEOUT_SECONDS row added to the MCP env-var table in docs/DEVELOPMENT.md.

Commits

  • feat(mcp): add initialize_timeout_seconds setting
  • fix(mcp): run initialize handshake under its own timeout budget
  • docs(mcp): document OCTAVE_MCP_INITIALIZE_TIMEOUT_SECONDS
  • docs(specs): design and plan for dedicated initialize handshake timeout

Test evidence

4 new tests (TDD: verified failing before implementation, passing after):

  • test_settings_default_initialize_timeout / test_settings_env_override_initialize_timeout — config default + env override
  • test_initialize_timeout_uses_dedicated_budget — silent peer; error cites 0.05 (dedicated budget), not 1.0 (request budget)
  • test_slow_initialize_survives_tight_request_timeout — regression: peer boots in 0.2 s under request_timeout=0.05; connect still succeeds on the 30 s initialize budget

Gates:

  • uv run pytest — 281 passed
  • uv run ruff check . — All checks passed
  • uv run mypy src — Success: no issues found in 48 source files

Checklist

  • Implementation complete
  • Tests passing
  • Documentation updated

@Svagtlys Svagtlys added this to the 1.0 — Initial Release milestone Sep 23, 2026
@Svagtlys Svagtlys added bug Something isn't working area:mcp MCP Connector labels Sep 23, 2026
@Svagtlys Svagtlys self-assigned this Sep 23, 2026
@Svagtlys
Svagtlys marked this pull request as ready for review September 25, 2026 07:43
@Svagtlys
Svagtlys merged commit c90ed05 into develop Sep 25, 2026
4 checks passed
@Svagtlys
Svagtlys deleted the fix/mcp-initialize-timeout branch September 25, 2026 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:mcp MCP Connector bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(mcp): dedicated timeout for initialize handshake

1 participant