Skip to content

fix: conservatively retry legacy server initialization#1045

Draft
tsarlandie-oai wants to merge 1 commit into
modelcontextprotocol:mainfrom
tsarlandie-oai:codex/rmcp-1040-safe-legacy-lifecycle
Draft

fix: conservatively retry legacy server initialization#1045
tsarlandie-oai wants to merge 1 commit into
modelcontextprotocol:mainfrom
tsarlandie-oai:codex/rmcp-1040-safe-legacy-lifecycle

Conversation

@tsarlandie-oai

@tsarlandie-oai tsarlandie-oai commented Jul 24, 2026

Copy link
Copy Markdown

Summary

  • classify discovery-probe failures with typed HTTP, JSON-RPC, and protocol-version signals
  • retry legacy initialization only for correlated method-not-found responses, known historical-version evidence, recognized legacy prevalidation responses, and initial HTTP 404/405
  • preserve typed 401/403 authentication failures and avoid fallback for arbitrary, contradictory, unknown, or unrelated errors
  • replace string matching on transport errors with UnexpectedHttpStatus { status, body }
  • keep the HTTP worker alive for eligible initial 404/405 probes so Auto mode can perform the legacy handshake

Why

Automatic fallback is useful only when the failed discovery probe demonstrates that the endpoint is legacy. Broad error matching risks retrying initialization after authentication failures, unrelated responses, or future protocol behavior.

The rework separates failure extraction from the fallback policy and makes each accepted legacy signal explicit and testable.

Validation

  • lifecycle classifier and integration suite: 17 tests passed
  • HTTP discovery/fallback suite: 10 tests passed
  • streamable HTTP error-body suite: 3 tests passed
  • cargo +1.95.0 clippy -p rmcp --all-features --all-targets -- -D warnings
  • formatting and whitespace checks passed

Fixes #1040

@github-actions github-actions Bot added T-test Testing related changes T-core Core library changes T-service Service layer changes T-transport Transport layer changes labels Jul 24, 2026
@tsarlandie-oai
tsarlandie-oai force-pushed the codex/rmcp-1040-safe-legacy-lifecycle branch from f754b75 to d28b11d Compare July 25, 2026 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-core Core library changes T-service Service layer changes T-test Testing related changes T-transport Transport layer changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ClientLifecycleMode::Auto does not fall back for deployed legacy-server responses

1 participant