Skip to content

fix(mcp): separate OAuth browser login from bounded handshake timeouts #1623

Closed

Description

@jhrozek

Problem

mecated mcp login SERVER can fail against a working OAuth-protected MCP server when the authenticated resource handshake takes more than the hardened client's 10-second response-header timeout. The MCP SDK later surfaces only context deadline exceeded, losing the actionable net/http: timeout awaiting response headers cause.

The same 30-second machine deadline currently encloses the interactive browser/callback flow because the SDK invokes OAuth authorization during Client.Connect. A user completing browser consent should not be cancelled by the handshake deadline, while the pre-authorization exchange, authenticated retry, initialize, and initial listing must remain bounded.

Intended behavior

  • Keep the initial MCP exchange bounded at 30 seconds.
  • Pause that deadline only while an explicit local OAuth browser/callback interaction is pending; after successful authorization, start a fresh 30-second deadline for the SDK retry, initialize, and initial listing.
  • Increase only the direct OAuth MCP resource client's response-header timeout from 10 seconds to 30 seconds. Keep its 30-second whole-request timeout and five-second dial/TLS limits; do not change the MCP broker token client.
  • Emit one redacted warning for each failed OAuth transport RoundTrip, before the SDK collapses the error. Include method, duration, safely redacted URL, and safely redacted cause; never log query values, headers, bodies, codes, tokens, or credentials.
  • Route the existing mecated mcp login stderr writer through the injected diagnostics sink without adding a CLI flag or configuration key.

Evidence

A live direct-DCR login to a working OAuth-fronted MCP gateway produced two identical POST attempts that each waited approximately 10.25 seconds for response headers, then ended as a generic context deadline exceeded. The same request later succeeded in approximately 2 seconds. DCR discovery, registration, and token issuance were not implicated.

Acceptance evidence

The implementation should use offline test-owned servers and diagnostic recorders to prove:

  1. Browser/callback wait is separate from the bounded pre- and post-authorization MCP exchanges.
  2. A delayed direct resource response succeeds under the revised policy and fails under a scaled equivalent of the old policy.
  3. Failure diagnostics are emitted per failed HTTP attempt and redact sensitive canaries.
  4. Reconnects retain their ordinary bounded establishment timeout.
  5. A timer callback racing with the browser-wait pause cannot cancel the newly armed post-authorization deadline.

No DCR registration lifecycle, broker transport timeout, YAML configuration, CLI grammar, persistence, or MCP wire-contract changes are in scope.

Activity

  1. self-assigned this
    on Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions