Skip to main content

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 FastMCP or 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 a payment_url and a next_step method for confirmation.
    The second method (e.g. confirm_add_payment) verifies payment and runs the original logic.
    Supported in most clients.

  • PaymentFlow.ELICITATION Sends 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] (or pdm add paymcp[webview]).
  • What it does: when a priced tool is invoked, PayMCP opens a lightweight in-app webview to the provider's payment_url so 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
  • Stripe
  • Walleot
  • 🔜 Want another provider? Open an issue or submit a pull request!

📄 License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

paymcp-0.1.1.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

paymcp-0.1.1-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file paymcp-0.1.1.tar.gz.

File metadata

  • Download URL: paymcp-0.1.1.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.25.6 CPython/3.10.14 Darwin/24.3.0

File hashes

Hashes for paymcp-0.1.1.tar.gz
Algorithm Hash digest
SHA256 53968347f13a2623a28dd06bef577674a832d69dc988f14b1b5c7b1d1fd6d39a
MD5 dd7f6d5efc3ac845f6d79a56dae74f95
BLAKE2b-256 22cf7d51bfa05aa133b2c459e80ad1613581f1943870ae5a209e502aec258c53

See more details on using hashes here.

File details

Details for the file paymcp-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: paymcp-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 16.4 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

Hashes for paymcp-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 240fd63468d776d11f8220b3927f56421a7bfc9c93dd4d99f0ec5b4dce15525d
MD5 c58931608251709fa869476b4a5556d9
BLAKE2b-256 1cd26f6ed413f2c24d04a2fcf5520b98e76326746b82f684ca2901f6bd6d310f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page