A production-ready Model Context Protocol (MCP) server that bridges Irys's programmable datachain with x402 micropayments, enabling AI agents to pay-per-access for verifiable data stored permanently on Irys.
Deploy the MCP server yourself - full control, no monthly fees. Payments route through our PaymentRouter contract (3% commission).
Use our managed API service - no setup required, API keys included, managed infrastructure.
Get Started | Documentation | Deploy Guide
- Data Upload: Upload data to Irys with x402 pricing metadata
- Payment-Gated Access: Access data through x402 payment verification on Base or any EVM chain
- Data Search: Search for available data by title or creator
- Data Listing: List all data by creator address
- Access Tokens: Secure access tokens with expiration after payment verification
-
Upload Payment → Irys Network
- Creator pays Irys (with Base ETH/other tokens) to store data
- One-time storage cost
- Data permanently stored on Irys L1 blockchain
-
Access Payment → Creator (x402)
- AI agent pays creator (via x402 on Base/any chain) to access data
- Micropayment per access
- Payment verified on-chain before data access granted
AI Agent (Claude) → MCP Server → Irys L1 (storage) + x402 Payments (Base/ETH)
npm installCopy .env.example to .env and configure:
cp .env.example .envRequired environment variables:
IRYS_PRIVATE_KEY: Your Ethereum private key for Irys uploadsCREATOR_PAYMENT_ADDRESS: Address where you want to receive x402 paymentsIRYS_NETWORK: Network to use (testnetormainnet)
Optional:
BASE_SEPOLIA_RPC: RPC URL for payment verification (default: Base Sepolia)DATA_REGISTRY_ADDRESS: Smart contract address (if using on-chain registry)
Run in development mode:
npm run devBuild the project:
npm run buildRun production build:
npm startUpload data to Irys with x402 pricing.
Parameters:
data(object, required): Data to upload (will be JSON stringified)title(string, required): Title of the datadescription(string, optional): DescriptiondataType(string, optional): Type of data (default: "general")pricePerAccessInEth(string, required): Price per access in ETH (e.g., "0.001")paymentChain(string, optional): Blockchain for payments (default: "base")
Returns:
dataId: Irys transaction IDurl: Gateway URLpricing: Price and currency information
Access data from Irys with x402 payment verification.
Parameters:
dataId(string, required): Irys data IDpaymentProof(object, optional): Payment proof object with txHash, from, to, amount, chain
Returns:
- If no payment proof: HTTP 402 payment requirement
- If payment proof provided: Data content + access token
Search for data available on Irys x402 marketplace.
Parameters:
query(string, required): Search query (searches in titles)creator(string, optional): Filter by creator address
Returns:
results: Array of matching data listings with pricing info
Get detailed information about a specific data listing.
Parameters:
dataId(string, required): Irys data ID
Returns:
- Complete data metadata including pricing and payment requirements
List all data uploads by the configured creator address.
Parameters: None
Returns:
listings: Array of all data uploaded by creatortotalValue: Total value of all listings
irys-x402-mcp/
├── src/
│ ├── index.ts # MCP server entry point
│ ├── server/
│ │ ├── MCPServer.ts # Main server class
│ │ └── tools.ts # MCP tool definitions
│ ├── irys/
│ │ ├── IrysClient.ts # Irys operations class
│ │ └── types.ts # Irys types
│ ├── x402/
│ │ ├── PaymentHandler.ts # x402 payment verification
│ │ └── types.ts # Payment types
│ └── utils/
│ ├── config.ts # Configuration management
│ └── logger.ts # Logging utility
├── .env.example # Environment variables template
├── package.json
├── tsconfig.json
└── README.md
Create/edit ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"irys-x402": {
"command": "node",
"args": [
"/absolute/path/to/irys-x402-mcp/dist/index.js"
],
"env": {
"IRYS_NETWORK": "testnet",
"IRYS_PRIVATE_KEY": "your_irys_private_key",
"BASE_SEPOLIA_RPC": "https://sepolia.base.org",
"CREATOR_PAYMENT_ADDRESS": "your_payment_address"
}
}
}
}// Via MCP tool
{
"data": { "message": "Hello World" },
"title": "Test Data",
"pricePerAccessInEth": "0.001",
"paymentChain": "base"
}// First request returns payment requirement
{
"dataId": "irys-transaction-id"
}
// After payment, provide proof
{
"dataId": "irys-transaction-id",
"paymentProof": {
"txHash": "0x...",
"from": "0x...",
"to": "0x...",
"amount": "1000000000000000",
"chain": "base"
}
}Run integration tests:
npm test- Ensure
IRYS_PRIVATE_KEYis set in .env - Check wallet has testnet funds: https://faucet.irys.xyz
- Verify transaction is confirmed (wait for block confirmation)
- Check payment amount >= required amount
- Ensure correct recipient address
- Verify RPC endpoint is responding
- Check data ID is correct
- Wait for Irys indexing (30-60 seconds)
- Verify upload was successful
- Check Irys gateway:
https://gateway.irys.xyz/{dataId}
This project uses a 3% commission model on all x402 payments:
- Self-hosted users: Free to deploy, but payments route through PaymentRouter contract (3% commission)
- Hosted service users: $20/month subscription + 3% commission on payments
- Commission funds: Platform maintenance, development, and infrastructure
The commission is automatically deducted by the PaymentRouter smart contract before forwarding to data creators.
# 1. Setup server
DROPLET_IP=your.droplet.ip ./scripts/deploy-digitalocean.sh
# 2. Configure Nginx (see scripts/nginx-config.conf)
# 3. Setup SSL
sudo certbot --nginx -d yourdomain.com# Build and run
docker-compose up -d
# Or build manually
docker build -t irys-x402-api .
docker run -p 3001:3001 --env-file .env irys-x402-apiSee Deployment Guide for detailed instructions.
The PaymentRouter contract routes all payments and takes commission:
- Contract:
contracts/PaymentRouter.sol - Deploy:
npm run deploy:contract - Commission: Configurable (default 3%)
- Treasury: Your wallet address
For users who prefer managed service:
- Base URL:
https://api.irys-x402.com - Authentication: API key in
X-API-Keyheader - Pricing: $20/month
- Features: Managed infrastructure, API keys, priority support
See API Documentation for full details.
ISC