pympp
Python SDK for the Machine Payments Protocol
Documentation
Full documentation, API reference, and guides are available at mpp.dev/sdk/python.
Install
pip install pympp
Quick Start
Server
from 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}
If the endpoint already uses Authorization (API keys, Bearer tokens), create the server with requires_auth=True. Challenges then advertise header="Payment-Authorization", and clients send the Payment credential in that header instead of Authorization.
server = Mpp.create(method=tempo(...), requires_auth=True)
result = await server.charge(
authorization=request.headers.get("Authorization"),
amount="0.50",
payment_authorization=request.headers.get("Payment-Authorization"),
)
Client
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")
Custom transports can reuse method matching and credential creation without depending on HTTPX:
from mpp.client import PaymentTransport
from mpp.runtime import PaymentRuntime
payments = PaymentRuntime([method])
challenge, method = payments.match_challenge(challenges)
credential = await payments.create_credential(challenge, method)
transport = PaymentTransport(runtime=payments)
Examples
| 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 |
Protocol
Built on the "Payment" HTTP Authentication Scheme. See mpp-specs for the full specification.
License
MIT OR Apache-2.0
Release files for pympp 0.11.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pympp-0.11.0.tar.gz | 205.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pympp-0.11.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 318.7 kB
Release files / pympp-0.11.0.tar.gz
| Download URL | pympp-0.11.0.tar.gz |
|---|---|
| Size | 205.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5264850cc3b8c8e3610aac6efc1ac390120623a47f376fb0973bf433eac45855
|
|
BLAKE2b-256 checksum How to use checksums |
50b7b030c30c6ef748bd1c38acbdc2237907918b55e5d47115b6e80e74f7fec2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|
Release files / pympp-0.11.0-py3-none-any.whl
| Download URL | pympp-0.11.0-py3-none-any.whl |
|---|---|
| Size | 113.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
714cb93a3d4f4fba31f062545617876dc460a7bc712947a7f6910ea5f9afa262
|
|
BLAKE2b-256 checksum How to use checksums |
7250756e7c2a5936125afa04a0b258637a50d5d5eeec8cbe5e93e39d5fc5e445
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|