Skip to content

fix(go): update MCP hook test mock for PaymentPayloadContext - #23

Closed
PhilBot402 wants to merge 22 commits into
mainfrom
philbotfix-mcp-hook-payload-context-41d7
Closed

PhilBot402 wants to merge 22 commits into
mainfrom
philbotfix-mcp-hook-payload-context-41d7

Conversation

@PhilBot402

Copy link
Copy Markdown
Owner

Description

Fixes Go CI on main after x402-foundation#3410 (Go port of x402-foundation#3372 extra.minDeposit / unified PaymentPayloadContext).

x402-foundation#3410 changed SchemeNetworkClient.CreatePaymentPayload to accept x402.PaymentPayloadContext and updated most test mocks, but hookSchemeMCPClient in go/mcp/client_test.go (added in x402-foundation#3482 for MCP OnPaymentResponse hook tests) still used the old two-argument signature. That makes github.com/x402-foundation/x402/go/v2/mcp fail to compile under make test / Check Go.

Root cause: hookSchemeMCPClient.CreatePaymentPayload at go/mcp/client_test.go line 1356 did not match interfaces.go SchemeNetworkClient.

Tests

From go/:

  • make fmt && make lint && make test — all packages pass, including go/v2/mcp.

Checklist

  • I have formatted and linted my code
  • All new and existing tests pass
  • My commits are signed (required for merge)
  • I added a changelog fragment for user-facing changes (test-only; skipped)

Related

AI assistance: implementation and verification were performed with Cursor Cloud Agent assistance.

Open in Web Open in Cursor 

viviviviviid and others added 22 commits September 15, 2026 08:06
…tion#3456)

Preserve query values exposed to HTTP payment hooks. Include regression tests and a changeset.

AI-assisted implementation and testing; awaiting human review in a draft PR.
…3455)

Preserve query values exposed to HTTP payment hooks. Include regression tests and a changeset.

AI-assisted implementation and testing; awaiting human review in a draft PR.
…-foundation#3454)

Use the calling Axios instance to resolve fallback request URLs. Add loopback regression tests for the fetch adapter and an HTTP adapter control.

AI-assisted implementation and testing; awaiting human review in a draft PR.
…2-foundation#3480)

* feat(python): forward resolved spend cap on PaymentPayloadContext

Pass the already-resolved atomic spendControls cap to scheme
create_payment_payload via PaymentPayloadContext.max_amount_per_payment
(omitted when uncapped) so capital-locking schemes can reuse client
policy without re-resolving it.

Co-authored-by: phdargen <phdargen@users.noreply.github.com>

* feat(python): add extra.minDeposit hint for EVM batch-settlement

Servers always announce extra.minDeposit on 402 responses (SDK default
10 × amount). Clients size deposits from a valid hint, else
amount × deposit_multiplier, clamped to spend_cap × deposit_multiplier.
Servers may opt in to enforce_min_deposit (default off).

Co-authored-by: phdargen <phdargen@users.noreply.github.com>

* docs(python): document batch-settlement minDeposit in examples

Show the client spend-cap deposit ceiling and the optional server
extra.minDeposit override in the Python batch-settlement examples.

Co-authored-by: phdargen <phdargen@users.noreply.github.com>

---------

Co-authored-by: phdargen <phdargen@users.noreply.github.com>
x402-foundation#3443)

* fix(python): size MCP tool-call timeouts from accept maxTimeoutSeconds

Paid MCP tool calls wait for the accept's maxTimeoutSeconds (default 300s).
The initial 402 probe uses a 300s ceiling unless the caller sets
read_timeout_seconds.

Co-authored-by: phdargen <phdargen@users.noreply.github.com>

* chore(python): add towncrier fragment for MCP tool-call timeout

Co-authored-by: phdargen <phdargen@users.noreply.github.com>

---------

Co-authored-by: phdargen <phdargen@users.noreply.github.com>
…402-foundation#3442)

Paid MCP tool calls were forwarding the parent context unchanged, so
slow-finality settlements could abort while TypeScript waits through
the accept window. Probe with a 300s ceiling when the caller sets no
deadline, and size paid retries from accepted.maxTimeoutSeconds.

Co-authored-by: phdargen <phdargen@users.noreply.github.com>
* feat(evm): cache positive asset-contract checks

EVM facilitators issued a fresh eth_getCode for the payment token on every
verify. Positive results are now cached for 15 minutes, keyed by network
and asset, matching Go x402-foundation#3355.

Co-authored-by: phdargen <phdargen@users.noreply.github.com>

* fix(evm): defer asset-contract check await until after pre-checks

Permit2 and upto verify started and awaited the asset getCode in one
expression, so a cheap spender or recipient failure still hit RPC and
could populate the positive cache. Start early and await after
signature work, matching Go x402-foundation#3355.

Co-authored-by: phdargen <phdargen@users.noreply.github.com>

---------

Co-authored-by: phdargen <phdargen@users.noreply.github.com>
…on#3362)

* feat(python): cache positive EVM asset-contract checks

Go facilitators already reuse a 15-minute positive eth_getCode result
for the payment token. Python still issued a fresh RPC on every verify,
so facilitator load and mid-deployment recovery diverged.

Co-authored-by: phdargen <phdargen@users.noreply.github.com>

* chore(python): name changelog fragment after PR 3362

Co-authored-by: phdargen <phdargen@users.noreply.github.com>

* fix(python): defer Permit2 asset-check await until after pre-checks

Exact and upto verify started and awaited the asset-contract check
before spender and signature work, so a cheap reject still issued
eth_getCode and could populate the positive cache.

Co-authored-by: phdargen <phdargen@users.noreply.github.com>

* fix(python): count asset get_code via MockFacilitatorSigner

x402-foundation#3366 already records get_code_calls on the mock. The extra subclass
incremented the same map again through super(), so cache tests failed
after the rebase.

Co-authored-by: phdargen <phdargen@users.noreply.github.com>

---------

Co-authored-by: phdargen <phdargen@users.noreply.github.com>
* feat(ts): add Casper TypeScript SDK

* fix: replace `amount` argument with `value` in transfer_with_authorization() entry point as per CEP-3009 standard.
fix: lower payment amount to 2,5 CSPR.

* chore: remove root pnpm lockfile

* removed `feePayer`. ran formatter/linter

* Stopped using PEM files and reading hex values to load private keys.

* fix: handle account and contract key types correctly

* test: add Casper e2e server coverage

* test: different algo for signer and signature prefixes

* refactor: use options for casper facilitator signer

* feat: add casper speculative execution signer hook

* feat: simulate casper transfer authorization in verify

* docs: document casper speculative execution config

* docs: add casper speculative execution plan

* fix: scope casper speculative execution

* fix: setup spec exec in e2e an integration tests

* docs: Add faucet/CSPR.trade links to fund new wallets.

* Casper mechanism updates and e2e fixes

* Casper mechanism updates and e2e fixes

* Update casper-js-sdk to 5.1.0

* Fix casper mechanism unit and integration tests.
Run linters and formatters.

* Add spec-exec config to e2e facilitator. Replaced preflight hooks with spec-exec config on facilitator `all-networks` example.

* Address PR review comments.

* pnpm update after rebase

* fix: compare first byte (2 hex chars) from signature and signer to verify algorithm tag matches

* fix: remove preflight hooks (wip)

* fix: remove preflight hooks (wip)

* fix: remove preflight hooks (wip)

* Add test coverage config (x402-foundation#3393) to casper mechanism

* fix: ran linter

* fix: 'install with frozen-lockfile' error fix

* fix(casper): stricter validation of CAIP-2 namespace

* ci(casper): ran linter
…#3484)

* Update docs/schemes/exact.mdx

Generated-By: mintlify-agent

Mintlify-Source: dashboard-editor

* Update docs/schemes/exact.mdx

Generated-By: mintlify-agent

Mintlify-Source: dashboard-editor

* Update docs/schemes/exact.mdx

Generated-By: mintlify-agent

Mintlify-Source: dashboard-editor

---------

Co-authored-by: mintlify[bot] <109931778+mintlify[bot]@users.noreply.github.com>
* fix(mcp): cap tool-call timeouts (default 10m)

* fix fmt
* Update docs/guides/mcp-server-with-x402.md

Generated-By: mintlify-agent

Mintlify-Source: dashboard-editor

* Update docs/guides/mcp-server-with-x402.mdx

Generated-By: mintlify-agent

Mintlify-Source: dashboard-editor

* Delete docs/guides/mcp-server-with-x402.md

Generated-By: mintlify-agent

Mintlify-Source: dashboard-editor

---------

Co-authored-by: mintlify[bot] <109931778+mintlify[bot]@users.noreply.github.com>
…lls (x402-foundation#3482)

* fix(MCP,Go): client dispatch HandlePaymentResponse after paid tool calls

* fix recovery
…3489)

* Update docs/sdk-features.md

Generated-By: mintlify-agent

Mintlify-Source: dashboard-editor

* Update docs/advanced-concepts/lifecycle-hooks.mdx

Generated-By: mintlify-agent

Mintlify-Source: dashboard-editor

* Update docs/advanced-concepts/lifecycle-hooks.mdx

Generated-By: mintlify-agent

Mintlify-Source: dashboard-editor

---------

Co-authored-by: mintlify[bot] <109931778+mintlify[bot]@users.noreply.github.com>
* chore: version typescript packages 

* fix fmt
…undation#3410)

* feat(go): add extra.minDeposit hint for EVM batch-settlement

Port TypeScript x402-foundation#3372 to the Go SDK. Forward the resolved atomic spend
cap on PaymentPayloadContext.MaxAmountPerPayment, announce extra.minDeposit
on every batch-settlement 402, size client deposits from a valid hint with
depositMultiplier × spendCap clamping, and add optional EnforceMinDeposit.

Co-authored-by: phdargen <phdargen@users.noreply.github.com>

* chore(go): drop restated minDeposit comments

Co-authored-by: phdargen <phdargen@users.noreply.github.com>

* unify payload context

---------

Co-authored-by: phdargen <phdargen@users.noreply.github.com>
Co-authored-by: Philippe d'Argent <pdargent@icloud.com>
PR x402-foundation#3410 unified CreatePaymentPayload to accept PaymentPayloadContext but
missed hookSchemeMCPClient added in x402-foundation#3482, breaking go test ./... on main.

Co-authored-by: phdargen <29732335+phdargen@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants