Python SDK for the Machine Payments Protocol
Full documentation, API reference, and guides are available at mpp.dev/sdk/python.
pip install pymppfrom mpp import Credential, Receipt
from mpp.server import Mpp
from mpp.methods.tempo import tempo, ChargeIntent
server = Mpp.create(
method=tempo(
intents={"charge": ChargeIntent()},
recipient="0x742d35Cc6634c0532925a3b844bC9e7595F8fE00",
),
)
@app.get("/paid")
@server.pay(amount="0.50")
async def handler(request, credential: Credential, receipt: Receipt):
return {"data": "...", "payer": credential.source}from mpp.client import Client
from mpp.methods.tempo import tempo, TempoAccount, ChargeIntent
account = TempoAccount.from_key("0x...")
async with Client(methods=[tempo(account=account, intents={"charge": ChargeIntent()})]) as client:
response = await client.get("https://mpp.dev/api/ping/paid")| Example | Description |
|---|---|
| api-server | Payment-gated API server |
| fetch | CLI tool for fetching URLs with automatic payment handling |
| mcp-server | MCP server with payment-protected tools |
Built on the "Payment" HTTP Authentication Scheme. See mpp-specs for the full specification.
MIT OR Apache-2.0