A Model Context Protocol (MCP) server that will create an x402 header using the provided private key.
x402 is an open protocol for internet-native payments
This project provides a is a minimal mcp server that can be run on a local machine to create x402 X-PAYMENT headers
It exposes two mcp tools:
- CreateX402PaymentHeader which will create the payment headers for a given payment request, using the wallet for the tool
- LookupAddress which will lookup the address for account that is used to sign the payment header. Lazily create the account if it does not exist.
yarn install
yarn buildYou can test the MCP server using the MCP Inspector:
npx @modelcontextprotocol/inspector node build/index.jsA nice move when doing this is to do a yarn build first:
yarn build && npx @modelcontextprotocol/inspector node build/index.jsThere is a simple helper simple shell script for creating requests using curl:
- x402-helper.sh
This depends on curl and jq
A test scenario that can work well is:
- start the server
npx @modelcontextprotocol/inspector node build/index.js - lookup the payment details for a x402 protected resource
./x402-helper.sh https://x402.smoyer.dev/premium-joke - past the array into the web page for the inspector, connecting to the server, Listing Tools, then running the CreateX402PaymentHeader
- Copy the tool result and paste it into the terminal as a 2nd arg to the x402-helper command:
./x402-helper.sh https://x402.smoyer.dev/premium-joke {base-64-encoded-string}
- Testing
- Configurable key management and signing
- Integration with the Delegation Toolkit https://docs.metamask.io/delegation-toolkit