{
  "markdown": "# agenticpay\n\n[![CI](https://github.com/agenticpay-dev/agenticpay/actions/workflows/ci.yml/badge.svg)](https://github.com/agenticpay-dev/agenticpay/actions/workflows/ci.yml)\n[![CodeQL](https://github.com/agenticpay-dev/agenticpay/actions/workflows/codeql.yml/badge.svg)](https://github.com/agenticpay-dev/agenticpay/actions/workflows/codeql.yml)\n[![gitleaks](https://github.com/agenticpay-dev/agenticpay/actions/workflows/gitleaks.yml/badge.svg)](https://github.com/agenticpay-dev/agenticpay/actions/workflows/gitleaks.yml)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n[![GitHub stars](https://img.shields.io/github/stars/agenticpay-dev/agenticpay?style=flat&logo=github&color=yellow)](https://github.com/agenticpay-dev/agenticpay/stargazers)\n[![npm: @agenticpay/sdk](https://img.shields.io/npm/v/@agenticpay/sdk?label=npm%20%40agenticpay%2Fsdk)](https://www.npmjs.com/package/@agenticpay/sdk)\n[![npm downloads](https://img.shields.io/npm/dm/@agenticpay/sdk?label=downloads)](https://www.npmjs.com/package/@agenticpay/sdk)\n\n**[Website](https://agenticpay-dev.github.io/)** ·\n[Spend caps](https://agenticpay-dev.github.io/#spend-caps) ·\n[npm](https://www.npmjs.com/package/@agenticpay/mcp-bridge)\n\n<!-- The landing page lives in its own repo so it sits at the root of the\n     host: github.com/agenticpay-dev/agenticpay-dev.github.io -->\n\n\n**Get paid by AI agents.** Open-source payment infrastructure for the MCP\necosystem - declare a price on any tool, agents pay in USDC over [x402](https://x402.org),\nsettles on Solana in ~1.5 seconds.\n\nNo Stripe. No accounts. No API keys.\n\nThe full stack is here - SDK, CLI, paywall middleware, **self-hosted x402\nfacilitator**, and a live LLM agent demo. All TypeScript, MIT licensed.\n\n> **Just want to test it?** Point your `mcp-server` at our hosted devnet\n> facilitator: `FACILITATOR_URL=https://agentpay-facilitator-e9b20a5fee6a.herokuapp.com`\n> No setup needed.\n\n## Live demo\n\nA real Claude Opus agent receives a task, decides which paid tools to use,\npays autonomously via x402 micropayments on Solana, and answers the user.\n\n```\n$ pnpm --filter @agenticpay/two-agent-demo agent\n\nAgent wallet: 3rHoEumCpH8EGrr6Lq2vBKeyec6h3yPRGj2nGG2FzEfX\nServer:       http://localhost:4021\nFacilitator:  http://localhost:4022   ← our own\nModel:        claude-opus-4-7\nTask:         Reverse the string 'agentpay rocks' and tell me how many words\n              are in 'The quick brown fox jumps over the lazy dog'.\n\n[turn 1] tool_use: reverse_string({\"text\":\"agenticpay rocks\"})  →  paying $0.001 USDC ...\n  ✓ paid + got result in 1596ms: {\"result\":\"skcor yaptnega\"}\n[turn 1] tool_use: word_count({\"text\":\"The quick...\"})  →  paying $0.0005 USDC ...\n  ✓ paid + got result in 1286ms: {\"count\":9}\n\nAgent final answer:\n  1. Reversed string: skcor yaptnega\n  2. Word count: 9 words\n\n=== payments summary ===\n  reverse_string   $0.0010 USDC   1596ms\n  word_count       $0.0005 USDC   1286ms\n  TOTAL            $0.0015 USDC   2 calls\n```\n\nOn-chain proof (Solana devnet):\n- Settled by our self-hosted facilitator: [`EsqzTG8id...Bnku`](https://explorer.solana.com/tx/EsqzTG8id5CF5yxXmSSictkJnqn1uVC514joHqVBpdfSy4MkzvGzGGdb7Fybkn5ruSGyCQ87jyjmHuSGpU2Bnku?cluster=devnet)\n- Earlier settle via x402.org: [`2d2HcefgJ...vkqY`](https://explorer.solana.com/tx/2d2HcefgJYmkivWvf4x3TtZENnNEwJ94c9jLHZsHaDbYmEuBGuv3RCojLzsAjsqF2CKHujgX7QaDcApSLSQAvkqY?cluster=devnet)\n\n## Why\n\nThe current AI agent stack assumes humans hold the credit card. That breaks\nthe moment agents act on their own initiative - calling APIs, hiring\nsub-agents, paying for compute. You can't OAuth your way through it.\n\nStablecoin micropayments over HTTP fix it. agenticpay packages the missing\nergonomics for the MCP ecosystem specifically: any tool can declare a price,\nany agent can pay it, and the whole pipeline - including the facilitator that\nactually submits the on-chain settlement - is open source and self-hostable.\n\n## Architecture\n\n```\n┌──────────────┐     1) HTTP request                    ┌─────────────┐\n│   Claude /   │ ────────────────────────────────────▶ │  mcp-server │\n│   GPT agent  │     2) HTTP 402 + payment requirements │  (yours)    │\n│              │ ◀──────────────────────────────────── │             │\n│              │     3) signed USDC payload             │             │\n│              │ ────────────────────────────────────▶ │             │\n└──────────────┘                                        └─────┬───────┘\n                                                              │ verify+settle\n                                                              ▼\n                                                   ┌──────────────────────┐\n                                                   │ agenticpay facilitator │\n                                                   │   (also yours, this  │\n                                                   │    repo, port 4022)  │\n                                                   └──────────┬───────────┘\n                                                              │ submit\n                                                              ▼\n                                                          Solana\n                                                       (USDC SPL,\n                                                       sub-cent fees)\n```\n\nYou can also point `mcp-server` at the public `x402.org/facilitator` for\ntestnet/devnet, or at Coinbase CDP for mainnet. We just made the\nself-hosted route easy.\n\n## Packages\n\n| Package | What it does |\n|---|---|\n| `packages/sdk` | TypeScript primitives: USDC transfers, wallet management, network config |\n| `packages/cli` | `agenticpay` command - wallet, balance, send |\n| `packages/mcp-server` | HTTP server with x402 paywall middleware. Each tool has a price. |\n| `packages/facilitator` | **Self-hosted x402 facilitator** - verify + settle USDC payments on Solana. Pays SOL fees on behalf of agents. |\n| `packages/eliza-plugin` | **Eliza plugin** - wraps paid HTTP endpoints as native Eliza Actions. Solana-native AI agents pay per tool call. |\n| `packages/ai-sdk` | **Vercel AI SDK helpers** - drop paid tools straight into `generateText` / `streamText`. |\n| `packages/mcp-bridge` | **Real MCP server** (stdio + `@modelcontextprotocol/sdk`) wrapping x402 paid tools. Drop into Claude Desktop / Cursor. |\n| `examples/two-agent-demo` | Real Claude Opus agent paying for tool calls |\n\n## Install\n\n```bash\nnpm install @agenticpay/sdk           # Solana + USDC primitives\nnpm install -g @agenticpay/cli        # `agenticpay` command\nnpm install @agenticpay/mcp-server    # paywalled HTTP server\nnpm install @agenticpay/facilitator   # self-hosted x402 facilitator\nnpm install @agenticpay/eliza-plugin  # Eliza plugin (Solana-native agents)\nnpm install @agenticpay/ai-sdk        # Vercel AI SDK paid tools\nnpm install -g @agenticpay/mcp-bridge # MCP server for Claude Desktop / Cursor\n```\n\nOr clone the monorepo to get the live two-agent demo and edit-friendly\ntemplates (recommended for first run - see Quickstart below).\n\n## Use with Claude Code\n\nThis repo ships an [Anthropic Skill](https://docs.claude.com/en/docs/claude-code/skills)\nat `.claude/skills/agenticpay/SKILL.md`. Copy it into your `~/.claude/skills/`\nto give Claude Code first-class context about agenticpay - it'll then walk you\nthrough monetizing an MCP server, generating tool routes, and verifying\non-chain settlements without re-reading the README every time.\n\n```bash\nmkdir -p ~/.claude/skills\ncp -r .claude/skills/agenticpay ~/.claude/skills/\n```\n\n## Quickstart (devnet, ~5 minutes, free)\n\n```bash\n# 1. Install\npnpm install\npnpm -r build\n\n# 2. Generate a payer wallet, fund it on devnet\nnode packages/cli/dist/index.js wallet new\nnode packages/cli/dist/index.js wallet show\n# → fund SOL at https://faucet.solana.com  (paste pubkey)\n# → fund USDC at https://faucet.circle.com (Solana Devnet, same pubkey)\n\n# 3. (option A - fastest) Use our hosted devnet facilitator. Skip step 4.\nexport FACILITATOR_URL=https://agentpay-facilitator-e9b20a5fee6a.herokuapp.com\n\n# 3. (option B - fully self-hosted) Start your own facilitator (terminal 1)\npnpm --filter @agenticpay/facilitator dev\n# Note the printed feePayer address. It needs ~0.05 SOL devnet to cover fees.\n# Either airdrop or use the helper:\npnpm --filter @agenticpay/facilitator fund\nexport FACILITATOR_URL=http://localhost:4022\n\n# 4. Start the paywalled mcp-server (terminal 2)\nPAY_TO=<recipient pubkey> pnpm --filter @agenticpay/mcp-server dev\n\n# 5. Run the live LLM agent demo (terminal 3, needs ANTHROPIC_API_KEY in .env)\npnpm --filter @agenticpay/two-agent-demo agent\n```\n\n## Framework integrations\n\nDrop-in templates for the most common AI agent stacks live under `examples/`:\n\n| Framework | File |\n|---|---|\n| Anthropic SDK (canonical) | `examples/two-agent-demo/src/agent-llm.ts` |\n| Real-world paid server template (Claude-backed tools) | `examples/research-server/` |\n| LangChain.js | `examples/langchain-js/agent-with-paid-tools.ts` |\n| LangChain Python | `examples/langchain-python/agent_with_paid_tools.py` |\n| Eliza (Solana-native) | `examples/eliza/plugin-agenticpay.ts` |\n| Mastra | `examples/mastra/paid-tool.ts` |\n| Vercel AI SDK | `examples/vercel-ai-sdk/paid-tool.ts` |\n| OpenAI Custom GPT | `examples/openai-gpt/action-schema.json` |\n\nSee `examples/README.md` for the integration matrix.\n\n## Status\n\nPre-alpha. Devnet validated end-to-end. Mainnet config supported but requires\nfunding the facilitator with real SOL and pointing at a mainnet-capable RPC\n(Helius, QuickNode, etc.).\n\n## Roadmap\n\n- [x] Devnet end-to-end demo (smoke + LLM agent)\n- [x] Self-hosted x402 facilitator (verify + settle, fee_payer abstraction)\n- [ ] Real-world MCP server template (search, fetch, summarize, extract - instead of toy `reverse_string`)\n- [ ] On-chain escrow for long-running tasks (Anchor program)\n- [ ] Agent reputation registry on-chain\n- [ ] Hosted facilitator service (`agenticpay.com`)\n\n## What's a facilitator?\n\nIf you've never seen x402 before: the **facilitator** is the trusted middleman\nthat (1) verifies an agent's signed payment payload, (2) submits the USDC\ntransfer on-chain, and (3) pays the SOL gas fees so the agent doesn't need\nany SOL - only USDC. Most MCP devs don't want to run their own; they point\nat a hosted one.\n\nThis repo ships a complete facilitator implementation. You can self-host it,\nfork it, audit it, or deploy it as a service for your own users.\n\n## What happens when a paid tool call fails?\n\nShort version: **a failed tool call is never charged.** x402 settlement is an\nirreversible push, so the middleware is careful about *when* it settles:\n\n1. **Verify before execute.** The payment payload (signature, funds,\n   requirements match) is verified before your tool handler runs. Invalid\n   payment → HTTP 402, the tool never executes.\n2. **Execute with a buffered response.** The handler runs, but its response is\n   held back - nothing is sent to the agent yet.\n3. **Settle only on success.** If the handler responds with status ≥ 400, the\n   middleware skips settlement entirely and just returns the error. The agent\n   pays nothing for a failed call.\n4. **No result without payment.** If on-chain settlement itself fails, the\n   buffered tool result is discarded and the agent gets a payment error\n   instead - the server never leaks a result it wasn't paid for.\n\nWhat this doesn't cover: a tool that returns `200 OK` with a junk answer is\nstill charged - the protocol can't judge response quality. That's what keeps\nper-call prices micro ($0.0005–$0.001 in the demo): the worst case is capped\nat one call's price, and quality enforcement belongs to a reputation layer\n(see Roadmap) rather than the payment protocol.\n\n## License\n\nMIT\n",
  "bytes": 11739,
  "sha": "becd6d424466f7697604e89cc33885e90b00ea1677cfae10e714193584a1780e",
  "repo_slug": "krystiangw/agenticpay",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_krystiangw_agenticpay_c101e8f3/readme"
}