An MCP (Model Context Protocol) server implementing the x402 payment protocol for paid Solidity development tools using USDC on Base networks (Sepolia testnet and mainnet).
This is a server-side implementation of an x402-enabled MCP server that provides paid Solidity development tools. The server:
- Verifies x402 payment settlements on-chain before providing services
- Provides Solidity compilation, security analysis, and deployment services
- Uses USDC payments via EIP-3009
TransferWithAuthorization - Operates a delegated deployment service where the server deploys contracts on behalf of clients
- π Usage Guide - Getting started, wallet setup, payment flow, and examples
- π API Reference - Complete API specs for all 4 tools
- π₯οΈ Claude Setup Guide - Connect to Claude Desktop or Claude Code CLI with automatic x402 payments
- compile_solidity - Solidity compilation (0.01 USDC)
- analyze_with_slither - Security analysis (0.02 USDC)
- compile_and_deploy - Single network deployment (dynamic pricing)
- compile_and_deploy_multi_network - Multi-network deployment (dynamic pricing)
- x402 Payment Protocol: On-chain settlement verification before service execution
- USDC Payments: EIP-3009
TransferWithAuthorizationfor gasless approvals - Delegated Deployment: Server deploys contracts without requiring client private keys
- Dynamic Gas Pricing: Fair, transparent gas-based pricing for deployments
- MCP Integration: Built with Ampersend SDK for seamless payment-gated tools
- Bazaar Discovery: Indexed on agentic.market with full metadata for AI agent discovery
Modular MCP server implementation with payment-gated tools:
src/server/- Organized server architectureindex.ts- Main entry pointdiscovery.ts- Bazaar discovery HTTP servertools/- Individual MCP toolscompile-solidity.ts- Solidity compilationanalyze-slither.ts- Security analysis via Slithercompile-deploy.ts- Delegated deployment with dynamic gas-based pricingcompile-deploy-multi.ts- Multi-network deployment support
utils/- Shared utilitiespayment.ts- Payment verification utilities
config/- Configuration managementnetwork.ts- Centralized network configuration for easy mainnet/testnet switchingtools.ts- Central tool configuration (compiler versions, pricing, gas settings)bazaar.ts- Bazaar discovery metadata for all tools
- Verifies X402 payments on-chain before executing tools
- Integrates with Remix API for Slither analysis
- Provides Delegated Deployment Service for secure contract deployment
- Exposes discovery endpoint for x402 Bazaar indexing
- See
REFACTORING_SUMMARY.mdfor detailed refactoring documentation
src/lib/- Client SDK (included for testing and examples)src/examples/- Example client implementationstests/e2e/- End-to-end integration tests
# Install dependencies
yarn installMost configuration values now have defaults in src/server/config/tools.ts. You only need to set:
SERVER_DEPLOYER_PRIVATE_KEY(required for deployment service)PAY_TO_ADDRESS(required for receiving payments)
All tool settings are centralized in src/server/config/tools.ts:
- Default compiler version (currently v0.8.35+commit.47b9dedd)
- Note: Users can specify custom versions via the
versionparameter
- Note: Users can specify custom versions via the
- EVM version (currently osaka)
- Pricing for each tool
- Gas estimation parameters
- Service fees and buffers
- Default network and RPC URLs
# Build TypeScript files
yarn run build# Build and start the server
yarn build && yarn startThe server will start:
- MCP Server:
http://localhost:8000/mcp- Main MCP endpoint for tool execution - Discovery Server:
http://localhost:8001/discovery- Bazaar discovery metadata endpoint - HTTP x402 Server (optional):
http://localhost:8002- REST endpoints with x402 protocol (requiresPAY_TO_ADDRESS)
The discovery endpoint exposes metadata for all tools in a format compatible with the x402 Bazaar:
# View discovery metadata
curl http://localhost:8001/discoveryThis endpoint is used by:
- agentic.market - To index and validate your service
- CDP Facilitator - To automatically catalog your tools
- AI agents - To discover available tools and their capabilities
End-to-end tests verify the complete payment and tool execution flow with real blockchain transactions.
Prerequisites:
- MCP server must be running
- Test wallet funded with USDC on Base Sepolia
- Configure
.env.testor.envwith test wallet
Run tests:
# Run all E2E tests
yarn test
# Watch mode
yarn test:watch
# Verbose output
yarn test:verboseTest coverage:
- β Compilation with automatic payment
- β Custom compiler settings
- β Multiple files with imports
- β Security analysis with Slither
- β Contract deployment
- β Multi-network deployment
- β Payment flow verification
Example client implementations are provided in src/examples/ for testing and reference:
The server implements the x402 protocol for pay-per-use services:
Client Server
| |
|---(1) Request Tool----------->|
| |
|<--(2) 402 Payment Required----|
| (amount, USDC address) |
| |
|---(3) Create Authorization--->|
| (EIP-712 signature) |
| |
|---(4) Settle On-Chain-------->| (Blockchain)
| (executes USDC transfer) |
| |
|---(5) Re-request with Proof-->|
| |
| (6) Verify Settlement
| (reads blockchain)
| |
|<--(7) Execute & Return--------|
Key Points:
- Payment verified on-chain before service execution
- EIP-3009 for gasless USDC approvals
- Dynamic pricing for deployment tools based on actual gas costs
- Transparent pricing: clients see exact costs before payment
π For detailed usage examples and tool specifications, see USAGE.md and API_REFERENCE.md
This server is compatible with the x402 Bazaar discovery layer, making it discoverable on agentic.market and by AI agents.
The server exposes structured metadata at http://localhost:8001/discovery that includes:
- Tool specifications - Input/output schemas with JSON Schema validation
- Pricing information - Exact costs for each tool
- Payment requirements - Network, USDC address, and payment scheme
- Service descriptions - Natural language descriptions for semantic search
- Examples - Sample inputs and outputs for each tool
- Network: Base Sepolia
- Chain ID: 84532
- USDC Contract:
0x036CbD53842c5426634e7929541eC2318f3dCF7e - RPC:
https://sepolia.base.org