solana-402-agent-wallet
Provides tools for checking Solana USDC payment requirements and verifying on-chain transaction signatures to unlock protected digital content.
README.md
# ⚡ Solana USDC 402 Merchant Gate & MCP Server for AI Agents
An open-source, zero-dependency **Model Context Protocol (MCP)** server and HTTP 402 payment gateway built for Cloudflare Workers and Node.js.
This project enables AI agents (Claude Desktop, Cursor, etc.) to natively discover, negotiate, and autonomously pay for digital resources over Solana USDC using standardized MCP tools and standard `HTTP 402 Payment Required` headers.
---
## 🤖 Model Context Protocol (MCP) Integration
This repository natively implements the official `@modelcontextprotocol/sdk` to expose agentic payment verification capabilities as standard MCP Tools.
### Exposed MCP Tools
1. **`check_payment_requirement`**
* **Description**: Queries the merchant endpoint to fetch required payment metadata (Price in USDC, Recipient Wallet Address, and Token Mint ID).
* **Input Schema**: None.
* **Returns**: Standardized HTTP 402 payment requirements for LLM evaluation.
2. **`verify_and_fetch_product`**
* **Description**: Submits a Solana transaction signature (`X-SOLANA-TX`) to verify on-chain USDC transfer and retrieve the protected payload.
* **Input Schema**:
* `txSignature` (`string`, **required**): The Solana transaction signature proving 0.01 USDC transfer to the recipient wallet.
* **Returns**: Protected digital asset or API payload upon successful verification.
---
## 💻 MCP Server Implementation Code
This MCP Server connects via `StdioServerTransport` using `@modelcontextprotocol/sdk`:
```javascript
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
const server = new Server(
{ name: "solana-402-merchant-server", version: "1.0.0" },
{ capabilities: { tools: {} } }
);
// Register MCP Tools
server.setRequestHandler(ListToolsRequestSchema, async () => {
return {
tools: [
{
name: "check_payment_requirement",
description: "Returns price, recipient wallet, and token details required to unlock this product.",
inputSchema: { type: "object", properties: {} }
},
{
name: "verify_and_fetch_product",
description: "Verifies a Solana transaction signature and unlocks the paid content.",
inputSchema: {
type: "object",
properties: {
txSignature: { type: "string", description: "Solana transaction signature" }
},
required: ["txSignature"]
}
}
]
};
});
// Handle Tool Requests
server.setRequestHandler(CallToolRequestSchema, async (request) => {
const { name, arguments: args } = request.params;
if (name === "check_payment_requirement") {
return {
content: [{
type: "text",
text: JSON.stringify({
status: 402,
price: "0.01 USDC",
recipient: process.env.RECIPIENT_WALLET || "YOUR_SOLANA_WALLET_ADDRESS",
tokenMint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
instructions: "Send 0.01 USDC on Solana and submit the signature via verify_and_fetch_product."
}, null, 2)
}]
};
}
if (name === "verify_and_fetch_product") {
const { txSignature } = args;
// On-chain verification logic via Helius RPC...
return {
content: [{
type: "text",
text: JSON.stringify({
success: true,
tx: txSignature,
data: "PROTECTED_DIGITAL_CONTENT"
}, null, 2)
}]
};
}
throw new Error(`Tool not found: ${name}`);
});
async function main() {
const transport = new StdioServerTransport();
await server.connect(transport);
}
main().catch(console.error);
📋 Prerequisites & Requirements
To run this MCP server, ensure you have:
Node.js: v18.0.0 or higher.
Solana Wallet: A self-custody wallet address (
RECIPIENT_WALLET) to collect USDC payments.Helius RPC API Key: Free API key from Helius (
HELIUS_API_KEY) for on-chain transaction validation.Cloudflare Workers & KV (Optional for HTTP Deployment): A Cloudflare KV namespace named
USED_TXto store used transaction hashes and prevent double-spending replay attacks.
Related MCP server: @true402.dev/mcp-server
⚙️ How to Setup and Run
1. Installation
git clone [https://github.com/YOUR_USERNAME/solana-402-mcp-merchant.git](https://github.com/YOUR_USERNAME/solana-402-mcp-merchant.git)
cd solana-402-mcp-merchant
npm install
npm run build
2. Claude Desktop Integration (claude_desktop_config.json)
To use this server inside Claude Desktop or Cursor, add the following to your config file:
{
"mcpServers": {
"solana-402-merchant": {
"command": "node",
"args": [
"/path/to/solana-402-mcp-merchant/build/index.js"
],
"env": {
"RECIPIENT_WALLET": "YOUR_SOLANA_WALLET_ADDRESS",
"HELIUS_API_KEY": "YOUR_HELIUS_API_KEY"
}
}
}
}
📄 License
MIT License - Open source and free for commercial and personal use.
This server cannot be installed
Maintenance
Related MCP Servers
- AlicenseAqualityDmaintenanceAn MCP server that lets your AI coding agent (Claude Code, OpenClaw, Codex, Cursor, etc.) discover and pay on-chain agents registered on ERC-8004, using Coinbase's official x402 protocol. No smart account. No bundler. No relay. Just your EOA, an HTTPS request, and an automatic 402 → sign → retry flow.35MIT
- AlicenseAqualityAmaintenanceAn MCP server that enables AI agents to access paid AI inference and web tools via HTTP 402 micropayments in USDC on Base, using the agent's wallet as identity.14572MIT
- AlicenseBqualityDmaintenanceMCP server providing AI agents access to 38 pay-per-call APIs (LLM, image, code, audio, crypto, web, IPFS) via HTTP 402 micropayments in USDC/USDm.2289MIT
- FlicenseAqualityBmaintenanceMCP server for a live x402 payment gateway on Base (USDC). Lets AI agents discover, preview for free, then pay per call — with prepaid gasless payments, signed receipts, and delta delivery.7
Related MCP Connectors
Monetize any MCP server: x402 paywall, pay-per-call billing in USDC on Base, agent marketplace.
Solana-native MCP gateway for SAP, DeFi tools, SNS identity, and x402 payments.
Attribution and settlement infrastructure for AI agent content access over HTTP 402 and MCP.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/AGICoffe/solana-402-agent-wallet'
If you have feedback or need assistance with the MCP directory API, please join our Discord server