v0.1 — Beta

Installation

bash
pip install mpppal

Initialize the client

python
import os
from mpppal import MPPPal

client = MPPPal(api_key=os.environ["MPPPAL_API_KEY"])

Wallets

python
# Provision a new agent wallet
wallet = client.accounts.create(name="research-agent-prod")
print(wallet.account_id)        # acct_01j8k4x9p2qrst7yz
print(wallet.solana_address)    # 9xTz4KqR8...
print(wallet.usdc_token_account) # Fund this with USDC

# Get balance
balance = client.accounts.get_balance(wallet.account_id)
print(f"Balance: ${balance.balance_usdc} USDC")

# List wallets
wallets = client.accounts.list(limit=50)

Transfers

python
transfer = client.transfers.create(
    from_account="acct_01j8k4x9p2qrst7yz",
    to="acct_02k9n5y3q7wpuv8ab",   # MPPPal account_id or raw SPL address
    amount="8.50",
    memo="Task reward: data-fetch-88",
    idempotency_key="task-88-reward",
)

print(transfer.status)        # "settled"
print(transfer.tx_signature)  # Solana signature

MPP Agent (HTTP 402 auto-payment)

Wrap the SDK's HTTP session around your agent's outbound calls. MPPPal intercepts HTTP 402 responses, resolves the payment challenge against your wallet, and retries the request transparently.

python
from mpppal import Agent

agent = Agent(
    wallet=os.environ["MPPPAL_WALLET_ID"],
    api_key=os.environ["MPPPAL_AGENT_KEY"],
)

# Automatic MPP payment on 402 responses
with agent.http_session() as http:
    response = http.post(
        "https://api.inference.xyz/summarize",
        json={"text": document_content},
    )
    print(response.json())

MPP Sessions

python
from mpppal import Agent

agent = Agent(
    wallet=os.environ["MPPPAL_WALLET_ID"],
    api_key=os.environ["MPPPAL_AGENT_KEY"],
    intent="session",
    session_cap="5.00",  # pre-authorize up to $5 USDC
)

# 500 inference calls → one Solana settlement at the end
with agent.http_session() as http:
    results = []
    for doc in documents:
        resp = http.post("https://api.inference.xyz/summarize", json={"text": doc})
        results.append(resp.json())

# Session closes on context exit — single on-chain settlement fires
receipt = agent.last_session_receipt
print(f"Settled: ${receipt.settled_usdc} USDC. Tx: {receipt.tx_signature}")

Policy

python
# Update policy (operator key required)
client.policy.update(
    account_id="acct_01j8k4x9p2qrst7yz",
    max_single_transfer=10,
    max_daily_spend=100,
    categories=["inference", "data"],
    require_memo=True,
    paused=False,
)

# Emergency pause
client.policy.pause("acct_01j8k4x9p2qrst7yz")

Error handling

python
from mpppal.exceptions import MPPPalError, PolicyViolationError

try:
    transfer = client.transfers.create(...)
except PolicyViolationError as e:
    print(f"Blocked by policy: {e.message}")
    # escalate to operator, log event, etc.
except MPPPalError as e:
    print(f"API error {e.code}: {e.message}")

Framework integrations

For LangChain and CrewAI integrations, see Framework Integrations. The Python SDK is the foundation both packages build on.