402.md

@402md/mcp

MCP tools reference for AI agents

Installation

npm install -g @402md/mcp

Configuration

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "402md": {
      "command": "402md-mcp",
      "env": {
        "WALLET_PRIVATE_KEY": "0xabc...",
        "NETWORK": "base"
      }
    }
  }
}

Add to .cursor/mcp.json:

{
  "mcpServers": {
    "402md": {
      "command": "402md-mcp",
      "env": {
        "WALLET_PRIVATE_KEY": "0xabc...",
        "NETWORK": "base"
      }
    }
  }
}

Any MCP-compatible client can connect via stdio:

WALLET_PRIVATE_KEY=0xabc... NETWORK=base 402md-mcp

Environment variables

VariableRequiredDefaultDescription
WALLET_PRIVATE_KEYYesHex private key for USDC wallet
NETWORKNobasebase or base-sepolia
API_BASE_URLNohttps://api.402.md402.md API endpoint

Tools

search_skills

Search 402.md for available skills (APIs, SaaS, products, services).

ParameterTypeRequiredDescription
querystringYesSearch query

Returns: list of matching skills with name, description, price, and type.

call_api

Call a paid API with automatic x402 payment.

ParameterTypeRequiredDescription
skillstringYesSkill name or ID
pathstringYesAPI endpoint path
methodstringNoHTTP method. Defaults to GET
bodystringNoJSON request body as string

Returns: API response data.

subscribe

Subscribe to a SaaS service.

ParameterTypeRequiredDescription
skillstringYesSkill name or ID

Returns: ticket JWT, access URL, and expiration date.

buy_product

Purchase a product.

ParameterTypeRequiredDescription
skillstringYesSkill name or ID
pathstringYesProduct endpoint path
quantitynumberNoNumber of items. Defaults to 1
shippingobjectNoShipping address (name, address, city, state, zip, country)

Returns: order ID, tracking URL, and total amount.

check_balance

Check the USDC wallet balance. No parameters.

Returns:

FieldTypeDescription
balancestringUSDC balance
tokenstring"USDC"
networkstringNetwork name
walletstringWallet address
spentTodaynumberAmount spent today
dailyBudgetstringDaily budget limit or "unlimited"
perTransactionLimitstringPer-tx limit or "unlimited"

get_orders

View recent purchases and orders. No parameters.

Returns: list of recent transactions with status.

Programmatic usage

Register 402.md tools on an existing MCP server:

import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
import { register402Tools } from '@402md/mcp'

const server = new McpServer({ name: 'my-agent', version: '1.0.0' })

register402Tools(server, {
  privateKey: process.env.WALLET_PRIVATE_KEY!,
  network: 'base',
  apiBaseUrl: 'https://api.402.md',
  budget: {
    daily: '100.00',
    perTransaction: '50.00'
  }
})

McpConfig

FieldTypeRequiredDescription
privateKeystringYesWallet private key
network'base' | 'base-sepolia'NoNetwork. Defaults to 'base'
apiBaseUrlstringNoAPI URL. Defaults to 'https://api.402.md'
budget.dailystringNoDaily spending limit
budget.perTransactionstringNoPer-transaction limit

Example conversation

User: Find me an API that can analyze sentiment and call it with "I love this product"

Claude (using 402.md MCP tools):

  1. Calls search_skills with query "sentiment analysis"
  2. Finds "sentiment-api" at $0.05/call
  3. Calls call_api with skill "sentiment-api", path "/analyze", body {"text": "I love this product"}
  4. Auto-pays $0.05 USDC via x402
  5. Returns: { "sentiment": "positive", "score": 0.95 }