Menu

Explorer & Settings

Tempo Explorer Submit Project
Back to all projects

pi-mpp

by p1rallels · Updated 4 months ago

Machine Payments Protocol extension for Pi

TypeScript MPP p1rallels/pi-mpp

In the AI payments ecosystem

pi-mpp is an early-stage TypeScript project in the AI payments / x402 ecosystem. It currently has 0 GitHub stars and 0 forks.

README.md View on GitHub →

pi-mpp-extension

MPP (Machine Payments Protocol) extension for Pi and OpenClaw. Lets the agent make paid HTTP requests to MPP-enabled services, handling the 402 Payment Required challenge flow automatically.

Install

git clone <this-repo> ~/.pi/agent/extensions/mpp
cd ~/.pi/agent/extensions/mpp
npm install

Or for project-local use:

git clone <this-repo> .pi/extensions/mpp
cd .pi/extensions/mpp
npm install

Quick test without installing globally:

pi -e ./index.ts

Payment Methods

Set env vars for whichever methods you want. Multiple can coexist — the SDK picks the right one based on what the server's 402 challenge offers.

Method Env Vars Notes
Tempo MPPX_PRIVATE_KEY Hex private key (0x...) for a Tempo wallet
Stripe MPPX_STRIPE_SPT_URL URL of your SPT proxy endpoint
MPPX_STRIPE_PAYMENT_METHOD (optional) Default Stripe payment method ID
Lightning MPPX_SPARK_MNEMONIC BIP39 mnemonic for a Spark wallet
MPPX_SPARK_NETWORK (optional) mainnet (default), regtest, or signet
Card MPPX_CARD_ID Card ID from your tokenization provider
MPPX_CARD_ENABLER_URL URL of your credential issuer endpoint

Secrets

Credentials can be provided via env vars or a JSON secrets file (aligned with OpenClaw's source: "file" pattern):

export MPPX_SECRETS_FILE=~/.openclaw/mpp-secrets.json

The file uses env var names as keys:

{
  "MPPX_PRIVATE_KEY": "0x...",
  "MPPX_SPARK_MNEMONIC": "word1 word2 ...",
  "MPPX_ALLOWED_HOSTS": "api.example.com,mpp.dev"
}

Env vars take priority over the file. The secrets file should be chmod 600 — OpenClaw enforces this for its own secrets files.

Security

Host Allowlist

Strongly recommended for OpenClaw users. Without an allowlist, the agent can pay any MPP-enabled endpoint — including attacker-controlled services via prompt injection.

export MPPX_ALLOWED_HOSTS="api.example.com,mpp.dev,fal.mpp.tempo.xyz"

Supports subdomains — example.com allows api.example.com. If unset, all hosts are allowed.

Spend Guard

Env Var Default Description
MPPX_SPEND_LIMIT 10 Max paid requests per session
MPPX_AUTO_APPROVE false Skip first-use confirmation prompt

Pi TUI (interactive):

  • First paid request prompts for confirmation
  • At the limit, prompts to extend by another N requests
  • Status bar shows MPP: tempo [3/10]

OpenClaw (headless):

  • Auto-approves up to the limit (no UI to prompt)
  • Hard-blocks at the limit
  • Set MPPX_SPEND_LIMIT to control the ceiling

Tool

The extension registers a single tool: mpp_request

mpp_request({
  url: "https://api.example.com/resource",
  method: "POST",                          // optional, default GET
  body: '{"prompt": "hello"}',             // optional, JSON string
  headers: { "X-Custom": "value" }         // optional
})

The tool returns the response status, body, payment receipt (if paid), and running spend count.

How It Works

  1. Agent calls mpp_request with a URL
  2. Extension makes the HTTP request via mppx SDK
  3. If the server returns 402 Payment Required, the SDK automatically:
    • Parses the payment challenge from WWW-Authenticate header
    • Fulfills payment using the configured method (Tempo, Stripe, Lightning, or Card)
    • Retries the request with a Authorization: Payment credential
  4. Server verifies payment and returns the resource with a Payment-Receipt

Reference

License

MIT

All MPP projects →