Skip to main content

Installation

See the npm package for version details.

Server Implementation

Basic Setup

Create a payment-aware MCP server that charges for tool invocations:

Advanced Configuration

Client Implementation

Basic Setup

Create a client that automatically handles payments:

Proxy Deployments

Client Proxy (CLI)

Run a client proxy to enable non-payment-aware clients (like Claude Desktop) to use payment-required servers:

Claude Desktop Configuration

Add to your Claude Desktop config:

Client Proxy (Programmatic)

Server Proxy

Monetize existing API-key-protected MCP servers. See the example implementation:

Testing

Testnet Setup

  1. Get Base Sepolia testnet ETH from Coinbase Faucet
  2. Get testnet USDC from the same faucet
  3. Use baseSepolia chain in your configuration
  4. Learn more about X402 on Coinbase Developer Platform

Demo Server

Test against our hosted demo server:
Note - Civic makes no guarantees about the availability or reliability of the demo server. We advise you deploy your own instance to ensure stability. The demo server source code is available in the x402-mcp repository

Network Configuration

Supported networks from Viem chains:
  • base - Base mainnet
  • baseSepolia - Base Sepolia testnet (recommended for testing)
  • mainnet - Ethereum mainnet
  • sepolia - Ethereum Sepolia testnet
  • optimism - Optimism mainnet
  • arbitrum - Arbitrum One
  • polygon - Polygon mainnet

Error Handling

Common errors and solutions:

Insufficient Balance

Solution: Ensure your wallet has enough USDC for payments plus ETH for gas

Payment Verification Failed

Solution: Check that you’re using the correct network and the payment transaction succeeded

Tool Not Found in Pricing

Solution: Ensure all tools are configured with prices in the server transport

Security Considerations

  1. Private Keys: Never commit private keys to version control
  2. Environment Variables: Use environment variables for sensitive data
  3. Network Selection: Use testnet for development and testing
  4. Price Validation: Validate tool pricing on both client and server
  5. Rate Limiting: Implement rate limiting to prevent abuse

Support