Skip to main content
@aifinpay/mcp is an MCP server that exposes AiFinPay’s autonomous x402 payment loop as agent-callable tools. Drop it into Claude Desktop (or any MCP-aware runtime) and your agent can buy services on its own — detect an HTTP 402, sign, pay, and retry — without you writing a line of payment code.
AiFinPay is payment infrastructure for AI agents — the Stripe for autonomous agents. It is token-free: there is nothing to buy, hold, or trade to use it. Agents pay real stablecoins per call. mSECCO are non-transferable usage credits, not a tradable asset.

Install

Configure Claude Desktop

Add the server to ~/Library/Application Support/Claude/claude_desktop_config.json:
Restart Claude Desktop. Claude can now call any of the tools below — payable_fetch, agent_call, pay_with_split, and the read-only marketplace directory — like any other tool.
Always set AIFINPAY_MAX_USD. It is a hard cap on any single payment and is your primary safety control when an autonomous agent is spending on its own.

First run — generating an agent

If AIFINPAY_AGENT_SECRET is not set, the server generates an ephemeral keypair and prints it to stderr at startup:
Save the printed secret to AIFINPAY_AGENT_SECRET in your client config so the agent identity — and any funded Seat — persists across restarts.
Treat AIFINPAY_AGENT_SECRET like a private key. Never commit it or paste it into chats. Anyone with it controls the agent and its funds.

Environment variables

Tools

The server exposes 16 tools: 7 for payment and agent identity, and 9 read-only marketplace directory tools.

Payment / agent

Marketplace directory (read-only)

Try it in Claude

Once the server is running, drive it in natural language. Claude picks the right tools:
1

Fund the agent

Ask Claude for agent_address(), then send stablecoins to that address so it has a balance to spend.
2

Browse the directory

“What AI services can I pay for through AiFinPay?” → Claude calls list_providers() and provider_info(name).
3

Preview before paying

“How much would this 402 endpoint cost?” → Claude calls agent_quote(url) or quote_cost(...) — no payment is made.
4

Pay and fetch

“Fetch this paid endpoint and summarize it” → Claude calls payable_fetch(url), which pays and retries automatically, staying under AIFINPAY_MAX_USD.

How payable_fetch works

  1. Sends the request unauthenticated.
  2. On 402, the underlying @aifinpay/agent SDK detects the facilitator flavor (AiFinPay native, Coinbase x402, …).
  3. Signs a payment payload and retries.
  4. Returns { status, ok, headers, body } to the agent.
The flow is identical to calling agent.pay(url) directly — this package just wraps it as an MCP tool surface so LLM agents can call it without writing payment code.

Programmatic use

You can also embed the server in your own MCP host:
Works with Claude Desktop, MCP Inspector, and any MCP-aware agent runtime. The server communicates over stdio.