Provider-agnostic payment layer for MCP (Model Context Protocol) tools and agents.
Project description
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.
🔧 Features
- ✅ Add
@price(...)decorators to your MCP tools to enable payments - 🔁 Choose between different payment flows (elicit, confirm, etc.)
- 🔌 Pluggable support for providers like Walleot, Stripe, and more
- ⚙️ Easy integration with
FastMCPor other MCP servers
🧭 Payment Flows
The payment_flow parameter controls how the user is guided through the payment process. Choose the strategy that fits your use case:
-
PaymentFlow.TWO_STEP(default)
Splits the tool into two separate MCP methods.
The first step returns apayment_urland anext_stepmethod for confirmation.
The second method (e.g.confirm_add_payment) verifies payment and runs the original logic.
Supported in most clients. -
PaymentFlow.ELICITATIONSends the user a payment link when the tool is invoked. If the client supports it, a payment UI is displayed immediately. Once the user completes payment, the tool proceeds. -
PaymentFlow.PROGRESS
Shows payment link and a progress indicator while the system waits for payment confirmation in the background. The result is returned automatically once payment is completed. -
PaymentFlow.OOB(Out-of-Band)
Not yet implemented.
All flows require the MCP client to support the corresponding interaction pattern. When in doubt, start with TWO_STEP.
🚀 Quickstart
Install the SDK from PyPI:
pip install mcp paymcp
Initialize PayMCP:
from mcp.server.fastmcp import FastMCP, Context
from paymcp import PayMCP, price, PaymentFlow
mcp = FastMCP("AI agent name")
PayMCP(
mcp, # your FastMCP instance
providers={
"provider_name": {"apiKey": "your-api-key-here"},
},
payment_flow=PaymentFlow.ELICITATION
)
Use the @price decorator on any tool:
@mcp.tool()
@price(amount=0.19, currency="USD")
def add(a: int, b: int, ctx: Context) -> int:
# `ctx` is required by the PayMCP tool signature — include it even if unused
return a + b
Demo server: For a complete setup, see the example repo: python-paymcp-server-demo.
🪟 Optional: WebView (STDIO)
Open the payment link in a native window when your MCP server is connected via the stdio transport (typical for local/desktop installs).
- Install:
pip install paymcp[webview](orpdm add paymcp[webview]). - What it does: when a priced tool is invoked, PayMCP opens a lightweight in-app webview to the provider's
payment_urlso the user can complete checkout without leaving the client. - Scope: applies only to stdio connections on the user's machine.
- Notes: requires a desktop environment.
🧩 Supported Providers
- ✅ Adyen
- ✅ Coinbase Commerce
- ✅ PayPal
- ✅ Stripe
- ✅ Square
- ✅ Walleot
- 🔜 Want another provider? Open an issue or submit a pull request!
📄 License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file paymcp-0.1.2.tar.gz.
File metadata
- Download URL: paymcp-0.1.2.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.25.6 CPython/3.10.14 Darwin/24.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07161f579c74c2484c149c1c2d13d471fe87af4ea0a61748a87373c9e1fa79a8
|
|
| MD5 |
1f75b0039ca2cc7fcbb3e5b9dd097076
|
|
| BLAKE2b-256 |
8b0bcc6d5f2667a614342b15ee57eecb7b747d57cd9d9a8c1a5b06c60606a122
|
File details
Details for the file paymcp-0.1.2-py3-none-any.whl.
File metadata
- Download URL: paymcp-0.1.2-py3-none-any.whl
- Upload date:
- Size: 20.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.25.6 CPython/3.10.14 Darwin/24.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1be637521afa1046bd65fbdaecc18f28a580ca7cc32547ff836bf6feb414fdb
|
|
| MD5 |
9ea88ac741942477b39e13ef84c8d2da
|
|
| BLAKE2b-256 |
77ec2072a7f2193fbd866552766f57f5e9f2e74c2db401ee1b6d1b2143e1a486
|