AdvancedMCP Integration

MCP Integration

Enable AI agents like Claude to make stablecoin payments using the Model Context Protocol (MCP).

Overview

The @t402/mcp package provides an MCP server that exposes T402 payment capabilities to AI agents. This enables use cases like:

  • AI agents paying for API calls
  • Automated payment workflows
  • AI-powered financial assistants

Architecture

┌─────────────────┐     ┌─────────────────┐     ┌─────────────────┐
│  Claude Desktop │────▶│   @t402/mcp     │────▶│   Blockchain    │
│  (MCP Client)   │     │   (MCP Server)  │     │   (EVM/TON/etc) │
└─────────────────┘     └─────────────────┘     └─────────────────┘

Setup

1. Install the Package

npm install -g @t402/mcp

2. Configure Claude Desktop

Edit claude_desktop_config.json:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "t402": {
      "command": "npx",
      "args": ["@t402/mcp"],
      "env": {
        "T402_PRIVATE_KEY": "0x...",
        "T402_DEMO_MODE": "true",
        "T402_WDK_SEED_PHRASE": "your twelve word seed phrase here"
      }
    }
  }
}

Setting T402_WDK_SEED_PHRASE enables 5 additional WDK tools (11 total). Without it, only the 6 base tools are available.

3. Restart Claude Desktop

The T402 tools will now be available to Claude.

Available Tools

The MCP server provides 6 base tools, plus 5 additional WDK tools when a seed phrase is configured (11 total).

Base Tools (6)

t402/verify

Verify a payment authorization against the facilitator.

t402/settle

Settle a verified payment on-chain via the facilitator.

t402/supported

List all supported networks, schemes, and signers.

t402/getRequirements

Get payment requirements for a 402-protected resource.

t402/getAllBalances

Check balances across all supported networks.

"What are all my stablecoin balances?"

t402/pay

Execute a stablecoin payment.

"Send 5 USDT0 to 0x1234... on Arbitrum"

WDK Tools (5, requires T402_WDK_SEED_PHRASE)

wdk/getWallet

Get WDK wallet address and chain info.

wdk/getBalances

Check balances across all configured WDK chains.

wdk/transfer

Transfer tokens from the WDK wallet.

wdk/swap

Swap tokens via WDK on a given chain.

t402/autoPay

Autonomously fetch a 402-protected resource, sign the payment, and return the content.

Demo Mode

For testing without real transactions:

{
  "mcpServers": {
    "t402": {
      "command": "npx",
      "args": ["@t402/mcp"],
      "env": {
        "T402_DEMO_MODE": "true"
      }
    }
  }
}

In demo mode:

  • No private key required
  • Returns simulated balances and transactions
  • Safe for development and testing

Custom RPC Endpoints

Configure custom RPC URLs for better reliability:

{
  "env": {
    "T402_PRIVATE_KEY": "0x...",
    "T402_RPC_ETHEREUM": "https://eth.llamarpc.com",
    "T402_RPC_BASE": "https://base.llamarpc.com",
    "T402_RPC_ARBITRUM": "https://arb1.arbitrum.io/rpc"
  }
}

Security Best Practices

  1. Use environment variables for private keys
  2. Enable demo mode during development
  3. Set spending limits in your workflows
  4. Monitor transactions via block explorers
  5. Use separate wallets for AI agents

Example Conversations

Checking Balances

User: “What’s my USDT balance?”

Claude: Let me check your balances across all networks.

[Uses t402/getAllBalances]

Here are your current balances:

  • Ethereum: 150.00 USDT0
  • Arbitrum: 500.00 USDT0
  • Base: 75.50 USDT0
  • Total: 725.50 USDT0

Making Payments

User: “Pay 25 USDT0 to 0xAlice… on Base for the API subscription”

Claude: I’ll send 25 USDT0 to that address on Base.

[Uses t402/pay]

Payment sent successfully!

  • Amount: 25.00 USDT0
  • To: 0xAlice…
  • Network: Base
  • Transaction: 0x1234…

Cross-Chain Bridging

User: “I need USDT0 on Ethereum but my funds are on Arbitrum”

Claude: I can bridge your USDT0 from Arbitrum to Ethereum. Let me check the fee first.

[Uses t402/getBridgeFee]

The bridge fee is approximately 0.002 ETH (~$5). How much would you like to bridge?

User: “Bridge 200 USDT0”

[Uses t402/bridge]

Bridge transaction initiated!

  • Amount: 200.00 USDT0
  • From: Arbitrum
  • To: Ethereum
  • Estimated time: ~15 minutes
  • Transaction: 0x5678…

Troubleshooting

MCP Server Not Found

Ensure @t402/mcp is installed globally:

npm install -g @t402/mcp

Connection Errors

Check that Claude Desktop is properly configured and restarted.

Transaction Failures

  • Verify sufficient balance for amount + gas
  • Check network status
  • Ensure private key has correct permissions