CX

civicteam/x402-mcp

Developer tools

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

4 stars 6 forks 品質 59 トレンド 12

X402 payment integration for Model Context Protocol (MCP)

概要

A server and client implementation for integrating X402 payment protocol with Model Context Protocol (MCP), enabling micropayments for MCP tool invocations. Try this out with your LLM by adding the following MCP server: This will connect to a hosted X402 MCP server that charges for tool invocations in USDC. The demo uses the Base Sepolia testnet. Obtain testnet ETH (for gas) and USDC (for payments) from a faucet like the Coinbase developer platform faucet. Enable micropayments for your MCP tools with X402 - get paid in USDC for every tool invocation. X402 is an open payment protocol developed by Coinbase that enables instant, automatic stablecoin payments directly over HTTP. It revives the HTTP 402 Payment Required status code to create a simple, programmatic payment flow: 1. Client requests a resource from the server 2. Server responds with 402 status and payment requirements 3. Client constructs and sends a payment payload 4.

README

以下は原文 README の抜粋です。原文を見る。

X402 MCP

A server and client implementation for integrating X402 payment protocol with Model Context Protocol (MCP), enabling micropayments for MCP tool invocations.

Demo

Try this out with your LLM by adding the following MCP server:

{
  "mcpServers": {
    "x402": {
      "command": "npx",
      "args": [ "@civic/[email protected]" ],
      "env": {
        "PRIVATE_KEY": "Your wallet private key",
        "TARGET_URL": "https://x402-mcp.fly.dev/mcp"
      }
    }
  }
}

This will connect to a hosted X402 MCP server that charges for tool invocations in USDC.

The demo uses the Base Sepolia testnet. Obtain testnet ETH (for gas) and USDC (for payments) from a faucet like the Coinbase developer platform faucet.

Quick Start

Enable micropayments for your MCP tools with X402 - get paid in USDC for every tool invocation.

Server: Charge for tool usage

const transport = makePaymentAwareServerTransport(
  "0x123...",
  { "my-tool": "$0.01" }
);
await mcpServer.connect(transport);

Client: Automatic payment handling

const transport = makePaymentAwareClientTransport(
  "http://localhost:3000/mcp",
  wallet
);
await mcpClient.connect(transport);

Table of Contents

What is X402?

X402 is an open payment protocol developed by Coinbase that enables instant, automatic stablecoin payments directly over HTTP. It revives the HTTP 402 Payment Required status code to create a simple, programmatic payment flow:

  1. Client requests a resource from the server
  2. Server responds with 402 status and payment requirements
  3. Client constructs and sends a payment payload
  4. Server verifies and settles the payment via a facilitator
  5. Server returns the requested resource

Key features:

  • Programmatic payments without accounts or complex authentication
  • Direct on-chain payments with minimal setup
  • Machine-to-machine transaction support
  • Micropayments and usage-based billing

Learn more: https://x402.org

What is MCP?

Model Context Protocol (MCP) is an open protocol that standardizes how applications provide context to AI models. It enables:

  • Standardized server implementations exposing tools and resources
  • Client libraries for connecting to MCP servers
  • Transport layers for communication between clients and servers
GitHub で README 全文を見る

インストール

npx @civic/[email protected]
MCP 初心者?mcpskill.org のガイドから始めましょう →

設定

{ "mcpServers": { "x402": { "command": "npx", "args": [ "@civic/[email protected]" ], "env": { "PRIVATE_KEY": "Your wallet private key", "TARGET_URL": "https://x402-mcp.fly.dev/mcp" } } } }