PayMCP
Provider-agnostic payment layer for MCP (Model Context Protocol) tools and agents.
PayMCP is a lightweight SDK that helps you add monetization to your MCP-based tools, servers, or agents. It supports multiple payment providers and integrates seamlessly with MCP's tool/resource interface.
Key Features
- Simple Integration - For Python, add the
@price(...)decorator to your MCP tools. For TypeScript, add price to tool metadata (_meta.price) - Subscription Gating - Gate tools behind active subscriptions
- Built-in and Custom Providers - Most top payment providers are built in, and you can easily add custom providers
- Flexible Coordination Modes - Choose between different payment modes (auto, resubmit, elicitation, two-step, x402, progress, dynamic tools)
- Framework Agnostic - Easy integration with FastMCP or other MCP servers
- Production Ready - Built for reliability and scale
Quick Example
- Python
- TypeScript
from mcp.server.fastmcp import FastMCP, Context
from paymcp import PayMCP, price
from paymcp.providers import StripeProvider
mcp = FastMCP("AI agent name")
PayMCP(mcp, providers=[StripeProvider(apiKey="sk_test_...")])
@mcp.tool()
@price(amount=1.00, currency="USD")
def add_numbers(a: int, b: int, ctx: Context) -> int:
"""Add two numbers together"""
return a + b
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { installPayMCP } from 'paymcp';
import { StripeProvider } from 'paymcp/providers';
import { z } from 'zod';
const mcp = new McpServer({name: "My AI Assistant"});
installPayMCP(mcp, { providers: [new StripeProvider({ apiKey: "sk_test_..." })] });
mcp.registerTool(
"add_numbers",
{
description: "Add two numbers together",
inputSchema: { a: z.number(), b: z.number() },
_meta: { price: { amount: 1.00, currency: "USD" } },
},
async ({ a, b }, extra) => {
return { content: [{ type: "text", text: String(a + b) }] };
}
);
Coordination Modes
PayMCP supports multiple coordination modes to fit different use cases:
- AUTO - Detects client capabilities; uses elicitation if supported, otherwise falls back to resubmit (default)
- RESUBMIT - First call returns error with a payment ID and payment URL; the retry completes once payment is verified
- ELICITATION - Payment link during tool execution (requires elicitation capability from MCP Clients)
- TWO_STEP - Split tool execution into initiate/confirm steps
- X402 - On-chain x402 payment request with signed payment response (requires x402-capable clients)
- PROGRESS - Experimental auto-checking of payment status (requires progress capability from MCP Clients)
- DYNAMIC_TOOLS - Dynamic tool lists that expose the next valid action (requires listChanged support from MCP Clients)
See the list of clients and their capabilities here: https://modelcontextprotocol.io/clients
Supported Providers
| Provider | Pay-per-request | Subscription | Features |
|---|---|---|---|
| Stripe | ✅ | ✅ | Cards, ACH, international payments |
| Walleot | ✅ | Pre-purchased credits, auto payments | |
| PayPal | ✅ | PayPal balance, cards, bank transfers | |
| Square | ✅ | Cards, in-person payments | |
| Adyen | ✅ | Global payments, 40+ countries | |
| Coinbase Commerce | ✅ | Bitcoin, Ethereum, stablecoins | |
| X402 | ✅ | On-chain x402 payments (Base/Solana) |
Getting Started
- Installation - Install PayMCP via pip or npm
- Basic Setup - Configure your first provider
- Add Pricing - Monetize your tools
- Test Integration - Verify everything works
Security Notice
PayMCP is NOT compatible with STDIO mode deployments where end users download and run MCP servers locally. This would expose your payment provider API keys to end users, creating serious security vulnerabilities.
PayMCP must be deployed as a hosted service where:
- You control the server environment
- API keys remain secure on your infrastructure
- Users connect via network protocols (HTTP, WebSocket, etc.)
Ready to start? Check out our Quickstart Guide to get up and running in minutes.