[Bug]: Go MCP timeout cap differs between initial paid call and recovery retry
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
- Configure the Go MCP client with
Options{MaxRequestTimeout: 90 * time.Second}and a payment payload whose accepted requirement hasMaxTimeoutSeconds: 3600. - Call
CallToolWithPaymentwithcontext.Background()(no caller deadline). - Have the MCP caller return a corrective
PaymentRequiredon the first paid call, and have the payment-response hook returnRecovered: true. Allow fresh payload creation to succeed. - 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/mcpclient. - 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.
Source: x402-foundation/x402