Turn your MCP server tools into paid endpoints using the Machine Payments Protocol
mpp-mcp is an early-stage TypeScript project in the AI payments / x402 ecosystem. It currently has 0 GitHub stars and 0 forks.
Turn your MCP server tools into paid endpoints — in minutes, not days.
@mpp/mcp makes it trivial to add the Machine Payments Protocol (MPP) to any MCP server. Define your tools, set a price, and get paid — in stablecoins or fiat — without touching blockchain code.
Built with ❤️ by clei | MIT License
Today, if you want to monetize an API or tool for AI agents, you need:
@mpp/mcp replaces all of that with a price config. Agents pay automatically, wallet-to-wallet, in a single HTTP request.
npm install @mpp/mcp
# Peer dependencies:
npm install @modelcontextprotocol/sdk mppx zod
import { createMcpServer } from '@mpp/mcp'
import { z } from 'zod'
const server = createMcpServer({
name: 'my-paid-tools',
version: '1.0.0',
methods: [{
type: 'tempo',
currency: 'usd',
recipient: '0x742d35Cc6634c0532925a3b844bC9e7595F8fE00',
}],
tools: {
translate: {
description: 'Translate text between languages',
inputSchema: z.object({
text: z.string(),
targetLang: z.string(),
}),
price: {
intent: 'charge', // 'charge' = per-call, 'session' = streaming
amount: '1', // $0.01
currency: 'usd',
method: 'tempo', // or 'stripe' for card payments
},
async execute({ text, targetLang }) {
// Your business logic here
return { translated: `[${targetLang}] ${text}` }
},
},
},
})
// Start with STDIO transport (works with Claude Desktop, Cursor, etc.)
server.start()
That's it. No payment middleware. No webhooks. No account setup.
Agent → MCP Server: tools/call { name: "translate", arguments: {...} }
MCP Server → Agent: error -32042 Payment Required { challenges: [...] }
Agent → Blockchain: pays the amount on Tempo
Agent → MCP Server: tools/call { name: "translate", ..., _meta: { ...credential } }
MCP Server → Agent: { content: { text: "..." } } ✅
All automatic from the agent's perspective.
| Method | Description | Status |
|---|---|---|
tempo |
Stablecoin on Tempo blockchain (sub-second, <$0.01/tx) | ✅ Testnet |
stripe |
Visa, Mastercard via Stripe Shared Payment Tokens | ✅ Production |
charge — Per-request paymentprice: {
intent: 'charge',
amount: '10', // $0.10 per call
currency: 'usd',
method: 'tempo',
}
session — Streaming paymentsOpen a payment channel once, make unlimited calls, settle on-chain:
price: {
intent: 'session',
setupAmount: '100', // $1.00 to open session
perCallAmount: '1', // $0.01 per call
maxTotal: '1000', // Cap at $10.00
currency: 'usd',
method: 'tempo',
}
import { createMcpServer } from '@mpp/mcp'
import { stripeMethod } from '@mpp/mcp/methods/stripe'
import { z } from 'zod'
const server = createMcpServer({
name: 'image-generator',
version: '1.0.0',
methods: [
stripeMethod({
currency: 'usd',
stripeAccountId: 'acct_xxx',
}),
],
tools: {
generate: {
description: 'Generate an image from a text prompt',
inputSchema: z.object({ prompt: z.string().max(500) }),
price: {
intent: 'charge',
amount: '50', // $0.50 per image
currency: 'usd',
method: 'stripe',
},
async execute({ prompt }) {
// Call your image generation API
return { imageUrl: 'https://example.com/img.png' }
},
},
},
})
server.start()
createMcpServer(config)interface MppMcpServerConfig {
name: string // Server name
version: string // Semantic version
methods: PaymentMethod[] // Supported payment methods
tools: Record<string, ToolDefinition>
logLevel?: 'debug' | 'info' | 'warn' | 'error' | 'silent'
}
PaymentMethod// Tempo (stablecoin — testnet ready)
{ type: 'tempo', currency: string, recipient: string }
// Stripe (card)
{ type: 'stripe', currency: string, stripeAccountId: string }
{
description: string
inputSchema: ZodSchema | JSONSchema
price: {
intent: 'charge' | 'session'
amount: string // Smallest unit (cents for USD)
currency: string
method: string
perCallAmount?: string // session only
maxTotal?: string // session only
}
execute: (args: unknown) => Promise<unknown>
}
import { startStdioServer } from '@mpp/mcp/adapters/stdio'
await startStdioServer(server)
// Coming soon
@mpp/mcp
├── core/
│ ├── createServer.ts # Server factory
│ ├── paidTool.ts # Tool with payment enforcement
│ ├── challengeBuilder.ts # -32042 challenge builder
│ ├── sessionManager.ts # Session lifecycle
│ └── credentialVerifier.ts # On-chain verification
├── methods/
│ ├── tempo.ts # Tempo blockchain method
│ └── stripe.ts # Stripe card method
├── adapters/
│ └── stdio.ts # STDIO transport
└── index.ts # Public exports
Contributions welcome! Please read the design doc first.
MIT © clei
TypeScript Interface for Machine Payments Protocol
Alephant is an open-source AI Agent Gateway for routing, tracking, and controlling LLM usage across AI agents, members, and workflows, and for publishing agent capabilities as paid endpoints with x402 and MPP payment rails.
Specifications for the Machine Payments Protocol - powered by the "Payment" HTTP authentication scheme
Rust SDK for the Machine Payments Protocol
Website for the Machine Payments Protocol
A universal framework designed to allow agents and other utilities to transparently make machine payments using web infrastructure.