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:
- SDK sends
POST /v1/chargesto api.payre.dev with{ apiKey, tool, amount } - API validates the developer's secret key and the consumer's API key
- API checks consumer balance >= amount
- API atomically deducts amount, credits 97% to developer, creates charge record, generates HMAC-SHA256 receipt
- API returns
{ chargeId, receipt, balance } - 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
+-- createdAtAuthentication
| Who | Key prefix | Header | Used for |
|---|---|---|---|
| Developer | pyr_sk_live_ | Authorization: Bearer pyr_sk_live_xxx | SDK calls to Payre API |
| Consumer | pyr_ck_live_ | X-Payre-Key: pyr_ck_live_xxx | Calls to your MCP server |
Infrastructure
| Component | Technology | URL |
|---|---|---|
| API | Fastify 5, Node.js 23 | api.payre.dev |
| Dashboard | Next.js 16 | console.payre.dev |
| Docs | VitePress | docs.payre.dev |
| Payments | Stripe Checkout + Connect | -- |
| Database | PostgreSQL + Prisma | -- |