跳到正文
Skillpedia
API 与服务器(后端)7.0k · #13689

mppx

它能做什么

这项技能涵盖用于 Payment HTTP 认证方案的 mppx TypeScript SDK。它适合需要让客户端为资源付款,或让服务器对资源收费的开发者。

适用场景

  • ✓当你的客户端应用收到 402 付款要求响应,并需要自动付款时。
  • ✓当你希望服务器路由通过 Tempo 稳定币或 Stripe 对访问收费的时候。
  • ✓当你需要包装 MCP 客户端或服务器,使工具调用需要付款的时候。

技能链接

https://github.com/internet-court/internet-court-skill/blob/main/vendored/tempo/mppx/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/internet-court/internet-court-skill/blob/main/vendored/tempo/mppx/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我希望我的服务器端点在返回数据之前,先通过 Tempo 收取一笔小额 USDC 付款。你能用 mppx 设置吗?”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会把 mppx 客户端或服务器辅助工具添加到项目中,设置币种和金额,并把付款质询接入路由。它会把密钥保留在服务器上,并返回所需的收据。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

mppx

TypeScript SDK for the "Payment" HTTP Authentication Scheme. Full 402 flow: challenge → credential → receipt.

What I can accomplish

  • Add 402 payment handling to a client with Fetch.polyfill or Fetch.from.
  • Protect HTTP routes with server-side MPP Challenges and Receipt responses.
  • Accept one-time Tempo stablecoin payments with tempo.charge.
  • Accept metered Tempo stablecoin payments with tempo.session.
  • Accept one-time card payments with stripe.charge.
  • Verify Credentials directly for custom transports or background workflows.
  • Wrap MCP clients and servers so tool calls can require payment.

Required inputs

  • Client integrations need a signing account and one or more client payment methods.
  • Server integrations need a recipient, currency, amount, and MPP_SECRET_KEY.
  • Tempo examples use chain ID 4217 unless a page explicitly covers Moderato testnet.
  • Stripe examples need a configured Stripe account and Shared Payment Token flow.
  • MCP integrations need the MCP client or server object to wrap.

Constraints

  • Keep MPP_SECRET_KEY server-side and out of logs.
  • Never commit private keys or wallet seeds.
  • Treat runtime 402 Challenges as authoritative for current payment terms.
  • Return id and opaque unchanged when responding to a Challenge.
  • Use USDC.e for Tempo bridged USDC examples, not generic USDC.

Client

import { Mppx, tempo } from 'mppx/client'

// Polyfills globalThis.fetch to handle 402 automatically
Mppx.create({
  methods: [tempo({ account })],
})

const res = await fetch('https://api.example.com/resource')

Without polyfilling:

const mppx = Mppx.create({
  methods: [tempo({ account })],
  polyfill: false,
})

const res = await mppx.fetch('https://api.example.com/resource')

Server

import { Mppx, Store, tempo } from 'mppx/server'
import { privateKeyToAccount } from 'viem/accounts'

const account = privateKeyToAccount('0x...')

const mppx = Mppx.create({
  methods: [
    tempo.charge({ currency: '0x...', recipient: '0x...' }),
    tempo.session({
      account,
      chainId: 4217,
      currency: '0x...',
      store: Store.memory(),
    }),
  ],
  secretKey: process.env.MPP_SECRET_KEY,
})

async function handler(request: Request): Promise<Response> {
  const result = await mppx.charge({ amount: '1.00' })(request)
  if (result.status === 402) return result.challenge
  return result.withReceipt(Response.json({ data: '...' }))
}

Methods

Method Intent Description
tempo.charge charge One-time stablecoin payment (TIP-20 token transfer on Tempo)
tempo.session session Streaming payments via payment channels on Tempo
stripe.charge charge One-time payment via Stripe

tempo() returns [tempo.charge, tempo.session] as a tuple using the current v2 Sessions implementation. Use tempo.charge() or tempo.session() individually if you only need one intent. Use tempo.sessionLegacy only for Legacy Sessions v1 compatibility.

Exports

Path Purpose
mppx Core primitives (Challenge, Credential, Method, Receipt, PaymentRequest)
mppx/client Mppx, tempo, stripe, session, Transport
mppx/server Mppx, tempo, stripe, Transport, Store, NodeListener
mppx/hono Hono middleware
mppx/express Express middleware
mppx/nextjs Next.js middleware
mppx/elysia Elysia middleware

CLI

mppx includes a CLI for making paid requests during development:

npx mppx account create        # create wallet
npx mppx mpp.dev/api/ping/paid # make paid request
npx mppx example.com -v        # verbose output

References

常见问题

密钥应放在哪里?

该技能说明,MPP_SECRET_KEY 保留在服务器上,并不写入日志。

它支持哪些付款方式?

它提到 Tempo 的一次性和计量稳定币付款,以及 Stripe 银行卡付款。

它使用 USDC 还是 USDC.e?

对于 Tempo 桥接 USDC 的示例,该技能要求使用 USDC.e。

详情

作者的原始描述

TypeScript SDK for the Payment HTTP Authentication Scheme. Handles 402 Payment Required flows with Tempo, Stripe, and other payment methods. Use when integrating payments or mppx into a client or server application.

repo: internet-court/internet-court-skill

热度

GitHub 星标
7.0k
排名
#13689
许可证
—
更新时间
2026/10/26

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能