Skip to content

Scope the reused x402 payment signature to tools the server charges for - #368

Merged
jancurn merged 1 commit into
mainfrom
claude/pr-365-review-hykqt9
Aug 12, 2026
Merged

Scope the reused x402 payment signature to tools the server charges for#368
jancurn merged 1 commit into
mainfrom
claude/pr-365-review-hykqt9

Conversation

@jancurn

@jancurn jancurn commented Aug 11, 2026

Copy link
Copy Markdown
Member

Follow-up to #365 (thanks @epistemedeus — the diagnosis there was right and the fix is correct). Checking the cache before the tool-metadata gate also means the session's payment signature is now attached to every tools/call, including free tools, handing a live authorization to calls that never asked for one. The cache now records which tools the server actually charged for, and reuses the signature only for those.

Refs #365, #343, #247

https://claude.ai/code/session_01YFNAoYc88jVSqaj86VdTUJ


Generated by Claude Code

Follow-up to #365, which made the challenge-signed payment reach the retry by
checking the cache before the tool metadata gate. That also attached the session
signature to every tools/call, including free tools, handing a live
authorization to calls that never asked for one.

The cache now records which tools the server actually charged for (a
payment-required tool result, or an HTTP 402 on a tools/call), and the signature
is reused only for those. Session-level reuse across paid calls is unchanged —
mcp.apify.com treats the signature as a prepaid token (#247). Also adds the
CHANGELOG entry the fix was missing.

Refs #365, #343, #247

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YFNAoYc88jVSqaj86VdTUJ

@epistemedeus epistemedeus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the result-challenge and HTTP 402 paths. The paymentRequiredTools scope closes cached-authorization spillover to free and unknown tools without reintroducing the retry failure from #365. The new tests cover those boundaries and preserve the documented prepaid-session reuse behavior. Looks good.

@jancurn
jancurn requested a review from MQ37 August 12, 2026 15:44
@jancurn
jancurn merged commit a2b4772 into main Aug 12, 2026
7 checks passed
@jancurn
jancurn deleted the claude/pr-365-review-hykqt9 branch August 12, 2026 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants