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

🧩 Supported Providers

  • Walleot
  • ✅ Stripe
  • 🔜 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.0.4.tar.gz (9.4 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.0.4-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for paymcp-0.0.4.tar.gz
Algorithm Hash digest
SHA256 21c752f778dc5a26cc45dc387041cad345aabd90f28170f08364bbbe8a6285f0
MD5 e47cdf4a1857b43042a3bea6ec6923a3
BLAKE2b-256 0af3270376d015c3d836a673d71ab46215f4603e0806753918ffea03d1a7a056

See more details on using hashes here.

File details

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

File metadata

  • Download URL: paymcp-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.25.2 CPython/3.10.14 Darwin/24.3.0

File hashes

Hashes for paymcp-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 cfdb8378a731fffe7ae295837d42b9c62eaf236c6001d81f82933a00f85a9c5a
MD5 bf71c702de735d81f3ac3bc240312dcc
BLAKE2b-256 8c4b9b2adbbd956c32f22222fffc476a799f4a8d6c34b07ab0a658640e726387

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