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
@price(...)decorators to your MCP tools. For TypeScript, add apricevariable inregisterTool()to enable payments - Flexible Coordination Modes - Choose between different payment modes (two-step, resubmit, elicitation, progress, dynamic tools)
- Built-in and Custom Providers - Most top payment providers are built in, and you can easily add custom providers
- 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 { FastMCP } from '@mcp/server-fastmcp';
import { installPayMCP } from 'paymcp';
import { StripeProvider } from 'paymcp/providers';
import type { Context } from '@mcp/server-fastmcp';
import { z } from 'zod';
const mcp = new FastMCP("AI agent name");
installPayMCP(mcp, { providers: [new StripeProvider({ apiKey: "sk_test_..." })] });
mcp.tool(
"add_numbers",
{
description: "Add two numbers together",
inputSchema: { a: z.number(), b: z.number() },
price: { amount: 1.00, currency: "USD" },
},
async ({ a, b }, ctx) => {
return { content: [{ type: "text", text: String(a + b) }] };
}
);
Coordination Modes
PayMCP supports multiple coordination modes to fit different use cases:
- TWO_STEP - Split tool execution into initiate/confirm steps (default, most compatible)
- RESUBMIT - First call returns HTTP 402 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)
- 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 | Status | Features |
|---|---|---|
| Stripe | ✅ Available | Cards, ACH, international payments |
| Walleot | ✅ Available | Pre-purchased credits, auto payments |
| PayPal | ✅ Available | PayPal balance, cards, bank transfers |
| Square | ✅ Available | Cards, in-person payments |
| Adyen | ✅ Available | Global payments, 40+ countries |
| Coinbase Commerce | ✅ Available | Bitcoin, Ethereum, stablecoins |
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.