#3560·x402

[Bug]: Go MCP timeout cap differs between initial paid call and recovery retry

Author: viviviviviidCreated Sep 23, 2026Updated Sep 23, 2026
Labelsbug

What happened?

On main 6fe0d4bfd104e8c61ae0b6aeaefe9da506d502ff, Go's initial paid MCP call applies MaxRequestTimeout, but a corrective recovery retry can exceed it when the caller context has no deadline.

For an accepted MaxTimeoutSeconds: 3600 and MaxRequestTimeout: 90 * time.Second, the initial paid call gets a deadline about 90 seconds away; the recovery retry gets about 3600 seconds.

In callToolWithPayload, the initial paid call uses c.paidTimeout(...). The recovery branch instead converts the accepted timeout directly to a duration, with a 300-second fallback.

The corresponding TypeScript recovery path passes the configured cap to paidTimeoutMs. The MCP guide describes capping derived timeouts, though I could not find an explicit Go corrective-recovery exception or rule.

Should Go recovery retries honor the same cap as TypeScript, or is bypassing it intentional? My expected behavior is the same per-call cap on both paid calls, while preserving an explicit caller deadline. This is not a request for a total timeout budget across attempts.

If this is confirmed as a bug and Go should follow the TypeScript behavior, would it be okay for me to take the Go fix and submit a PR with a focused regression test?

Related: #3508 is an open Python PR adding paid-response recovery. Its x402MCPSession and x402MCPClientSync paths calculate the capped timeout on each attempt. It does not change Go or the separate client_async.py wrapper, so I am not assuming it covers this discrepancy.

Steps to reproduce

  1. Configure the Go MCP client with Options{MaxRequestTimeout: 90 * time.Second} and a payment payload whose accepted requirement has MaxTimeoutSeconds: 3600.
  2. Call CallToolWithPayment with context.Background() (no caller deadline).
  3. Have the MCP caller return a corrective PaymentRequired on the first paid call, and have the payment-response hook return Recovered: true. Allow fresh payload creation to succeed.
  4. Inspect the context deadline received by the MCP caller on each call.

Observed in a local regression test: initial paid call ≈90s; recovery retry ≈3600s. A separate cancellation check with a 1-second cap and a 3-second accepted timeout canceled the recovery call after ≈3 seconds. An explicit parent deadline was preserved.

Environment

  • Repository main: 6fe0d4bfd104e8c61ae0b6aeaefe9da506d502ff, checked September 23, 2026.
  • Go 1.25.0, macOS arm64; go/mcp client.
  • Local tests inspect actual context deadlines/cancellation with test doubles for the MCP caller and payment scheme; no external MCP server or real payments.
  • AI assistance was used for code inspection and local reproduction preparation.