Mpp session flow

From OrcaQubits/agentic-commerce-skills-plugins · View interactive version

Mpp session flow is an AI agent skill from the GitHub repository OrcaQubits/agentic-commerce-skills-plugins. Implement MPP session-based streaming payment flows — authorize-once pay-as-you-go patterns for continuous data feeds, per-token billing, and micropayment aggregation. Use when building streaming APIs or services that charge incrementally.

How to use this skill

Skill file

MPP Session Flow (Streaming Payments)

Before writing code

Fetch live docs:

  1. Fetch https://www.npmjs.com/package/mppx for the session middleware API and payment channel configuration
  2. Fetch https://paymentauth.org/ for the canonical session intent specification
  3. Web-search mpp session streaming micropayments payment channel for session implementation patterns
  4. Web-search site:mpp.dev session for session-specific documentation

Conceptual Architecture

What Session Intent Is

The session intent implements streaming micropayments — often described as "OAuth for money". The agent authorizes a spending limit upfront, then streams micropayments continuously as it consumes resources:

1. Client opens session with spending cap
2. Server creates payment channel
3. Client makes requests — each deducts from the spending cap
4. Micropayments stream at sub-cent costs, sub-millisecond latency
5. Session closes — final settlement on-chain (single transaction)

When to Use Session

Session vs Charge Comparison

| Dimension | Charge | Session |

|-----------|--------|---------|

| Settlement | Per-request on-chain/card | Aggregated at session close |

| Latency | Includes payment settlement per call | Sub-millisecond after session open |

| Cost | One tx per request | One tx for entire session |

| Pricing | Fixed per request | Variable, metered |

| Use case | Infrequent, high-value calls | Frequent, low-value calls |

Server-Side Implementation

// Protect a route with a session payment gate
app.get('/api/stream', mppx.session({ maxAmount: '10000' }), async (c) => {
  // Deducts from the session's spending cap
  return c.json({ data: 'streaming content' });
});

Session Lifecycle

  1. Open — Client sends initial request; server returns 402 with session challenge
  2. Authorize — Client authorizes spending cap (e.g., 10,000 units)
  3. Active — Client makes requests; each deducts from the cap
  4. Refill — Client can extend the cap before it runs out
  5. Close — Either party closes; final settlement happens on-chain
  6. Settled — Single on-chain transaction for the total consumed amount

Payment Channel

Session payments use a payment channel — an off-chain mechanism where:

Spending Cap Management

Metering Patterns

| Pattern | Description |

|---------|-------------|

| Fixed per request | Each request costs a fixed amount |

| Per-unit | Cost varies by units consumed (tokens, bytes, seconds) |

| Time-based | Cost accrues per time interval |

| Tiered | Rate decreases with volume (first 100 at $X, next 1000 at $Y) |

Best Practices

Fetch the latest mppx SDK documentation and MPP specification for exact session API, payment channel mechanics, and configuration options before implementing.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.