@davidmaronio/stellarpay402-mcp
v0.1.1
Published
MCP server that bridges any AI assistant to a StellarPay402 marketplace. AI agents discover paid APIs and pay for them autonomously using x402 on Stellar.
Maintainers
Readme
@davidmaronio/stellarpay402-mcp
A Model Context Protocol (MCP) server. It exposes every endpoint in a running StellarPay402 marketplace as a tool to any MCP-aware AI assistant. When the AI calls a tool, the server signs an x402 payment with its configured Stellar testnet key, sends it to the proxy, and returns the API response.
Install
The package is on the public npm registry. There is nothing to install yourself. npx fetches it on first run:
npx -y @davidmaronio/stellarpay402-mcp@latestIf you want to hack on the source, clone the parent repo and run it directly:
cd StellarPay402/mcp-server
npm install
node index.mjsConfiguration
The server reads everything from environment variables.
| Variable | Required | Default | Description |
| --- | --- | --- | --- |
| STELLAR_SECRET_KEY | yes | none | Stellar testnet secret key (S...). Used to sign x402 payments. |
| MARKETPLACE_URL | no | https://stellar-pay402.vercel.app | Base URL of the StellarPay402 marketplace. Use http://localhost:3000 if you are running the marketplace locally. |
| MAX_USDC_PER_SESSION | no | 0.50 | Spending cap per session, enforced by the client. The server refuses any payment that would push your cumulative spend past this. |
Get a testnet wallet
- Open https://laboratory.stellar.org/#account-creator?network=test.
- Generate a new keypair. Save the secret key.
- Click "Fund account with Friendbot" to credit it with test XLM.
- Add a trustline for USDC. Asset code
USDC, issuerGBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5. - Swap a small amount of XLM for USDC on the testnet DEX.
Claude Desktop
Add this block to ~/Library/Application Support/Claude/claude_desktop_config.json on macOS, or the equivalent path on your platform:
{
"mcpServers": {
"stellarpay402": {
"command": "npx",
"args": ["-y", "@davidmaronio/stellarpay402-mcp@latest"],
"env": {
"STELLAR_SECRET_KEY": "S...",
"MARKETPLACE_URL": "https://stellar-pay402.vercel.app",
"MAX_USDC_PER_SESSION": "0.50"
}
}
}
}Restart Claude Desktop. Every public endpoint in the marketplace shows up as a tool named {userSlug}_{endpointSlug}.
How it behaves
On startup, the server connects over stdio, logs its config to stderr, and waits for MCP requests.
On tools/list:
- It fetches
${MARKETPLACE_URL}/api/marketplace. - It returns one tool per endpoint.
- Tool descriptions include the provider name and the USDC price per call.
On tools/call:
- The server hits the endpoint with no payment header. It expects a 402 response with x402 payment requirements.
- It checks the price against the remaining session budget. If the call would exceed the budget, it fails with a budget error.
- It builds and signs an x402 payment payload with
@x402/stellarand the configured secret key. - It retries the request with the
X-PAYMENTheader. - It returns the response body to the model. The response starts with a summary that includes the USDC amount paid, the cumulative session spend, and a link to the settled transaction on Stellar Expert.
Output format
Paid 0.0100 USDC on Stellar testnet
Payment proof: https://stellar.expert/explorer/testnet/tx/<hash>
Session spend: 0.0100 / 0.5000 USDC
API Response
<body returned by the upstream API>Spending cap
The session budget runs on the client side only. The marketplace proxy has its own per-payer hourly cap on the server side. See the main repository README.
License
MIT
