Skip to content

feat(mcp): expose x402 receipt metadata and explorer URL from paid MCP tools - #296

Merged
Emmy123222 merged 7 commits into
Emmy123222:mainfrom
AGWAM001:feat/expose-x402-receipt-metadata
Sep 3, 2026
Merged

feat(mcp): expose x402 receipt metadata and explorer URL from paid MCP tools #296
Emmy123222 merged 7 commits into
Emmy123222:mainfrom
AGWAM001:feat/expose-x402-receipt-metadata

Conversation

@AGWAM001

Copy link
Copy Markdown
Contributor

Closes #172

Summary

Extends paid MCP tool output in mcp-server/index.ts to include the versioned x402 receipt object and an explorer URL, alongside the existing amount/network reporting. Missing or unverified receipts are now represented explicitly rather than being folded into a generic "paid success" response.

Problem

MCP search output currently reports payment amount and network, but omits the actual verifiable receipt and a transaction link — so a caller has no way to independently verify that a reported payment actually settled, short of trusting the amount/network fields at face value. There's also no distinction in output between "payment verified with receipt" and "receipt missing/unverified" — both would currently look like a normal paid success.

Changes
Receipt object in output: paid tool responses now include the versioned x402 receipt object as returned/verified during settlement, not just the derived amount/network summary.
Explorer URL: added a transaction explorer link derived from the settlement result, so a caller can independently inspect the on-chain transaction.
Explicit missing/unverified state: when a receipt is missing or fails verification, the response now surfaces that explicitly (e.g. a distinct status/field indicating unverified payment) rather than silently reporting the same shape as a verified paid success. This prevents a caller from mistaking an unverified payment for a confirmed one.
Cross-runtime consistency: verified this behavior is aligned across Express, Vercel, browser, and MCP contexts — the receipt/explorer-URL exposure and the missing/unverified distinction behave the same regardless of which runtime is serving the request.
x402 settlement semantics preserved: no change to the underlying settlement verification logic itself — this PR only changes what's exposed in the tool's output, not how payment is verified.
Tests/docs: added coverage asserting the receipt object and explorer URL are present on verified paid responses, and that the explicit unverified/missing state is returned (not a false paid-success shape) when applicable. Updated relevant documentation describing the new response fields.
Why this approach

Surfacing the actual receipt object (rather than just amount/network) gives callers something independently verifiable instead of asking them to trust the server's summary. Making "missing/unverified" an explicit, distinct output state — rather than silently omitting the receipt field while still returning a success-shaped response — closes a gap where a caller could mistakenly treat an unverified payment as settled.

Testing
Unit/integration test: verified paid tool call returns response including receipt object and explorer URL.
Unit/integration test: simulated missing/failed receipt verification returns the explicit unverified state, not a paid-success shape.
Verified consistent behavior across Express, Vercel, browser, and MCP invocation paths.
Confirmed no change to underlying x402 settlement verification logic — existing settlement tests still pass unchanged.

@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@AGWAM001 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@vercel

vercel Bot commented Aug 31, 2026

Copy link
Copy Markdown

@AGWAM001 is attempting to deploy a commit to the Emmanuel's projects Team on Vercel.

A member of the Team first needs to authorize it.

@AbuJulaybeeb AbuJulaybeeb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

kindly fetch upstream, rebase branch ad push

@AGWAM001

AGWAM001 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

ready for merge

@Emmy123222
Emmy123222 merged commit 89ca614 into Emmy123222:main Sep 3, 2026
0 of 2 checks passed
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.

Expose x402 receipt metadata from paid MCP tools

3 participants