Skip to content

Architecture

How Payre works under the hood.

System Overview

+---------------------+         +------------------+
|   MCP Server        |         |   Payre API      |
|   (your server)     |         |  api.payre.dev   |
|                     |         |                  |
|  @payre/pay SDK ----+---------+> POST /v1/charges|
|                     |  <50ms  |  GET /v1/balance |
|                     |         |  GET /v1/earnings|
+----------+----------+         +---------+--------+
           |                              |
           | Direct connection            | Stripe
           | (not proxied)                |
           |                              |
+----------v----------+         +---------v--------+
|   Consumer          |         |   Stripe         |
|   (AI agent or      |         |   Checkout +     |
|    human user)      |         |   Connect        |
+---------------------+         +------------------+

Key design: Payre does not proxy traffic. Your MCP server and its consumers connect directly. The @payre/pay SDK makes a lightweight API call to api.payre.dev to validate the consumer's key, check their balance, and record the charge. Average latency: 0.5ms. P99: < 4ms.

Charge Flow

When payre.charge() is called:

  1. SDK sends POST /v1/charges to api.payre.dev with { apiKey, tool, amount }
  2. API validates the developer's secret key and the consumer's API key
  3. API checks consumer balance >= amount
  4. API atomically deducts amount, credits 97% to developer, creates charge record, generates HMAC-SHA256 receipt
  5. API returns { chargeId, receipt, balance }
  6. SDK returns the receipt to your tool handler

Total time: typically 0.5ms (API processing) + network latency.

Data Model

Developer
+-- id, email, name
+-- secretKey (pyr_sk_live_xxx)
+-- balance (accumulated earnings)
+-- tools[] { name, description, price }

Consumer
+-- id, email, name
+-- apiKey (pyr_ck_live_xxx)
+-- balance (prepaid credits)
+-- topUps[] { amount, status, stripeSessionId }

Charge
+-- id, developerId, consumerId
+-- tool, amount, receipt
+-- createdAt

Authentication

WhoKey prefixHeaderUsed for
Developerpyr_sk_live_Authorization: Bearer pyr_sk_live_xxxSDK calls to Payre API
Consumerpyr_ck_live_X-Payre-Key: pyr_ck_live_xxxCalls to your MCP server

Infrastructure

ComponentTechnologyURL
APIFastify 5, Node.js 23api.payre.dev
DashboardNext.js 16console.payre.dev
DocsVitePressdocs.payre.dev
PaymentsStripe Checkout + Connect--
DatabasePostgreSQL + Prisma--