LiveAuth MCP服务器
用于LiveAuth身份验证的模型上下文协议(MCP)服务器。使AI代理能够使用工作量证明或闪电网络支付进行身份验证。
⚡ One Liner演示
npx @liveauth-labs/mcp-server就是这样!在演示模式下运行(每次验证3次)。不需要API密钥。
演示与生产:
- 演示模式:返回真实的Lightning发票(由用户钱包支付),但模拟确认以进行测试
- 生产:需要实际付款,签发真实JWT
⚡ 快速入门(5分钟)
选项1:演示模式(无配置)
# Just run - no API key needed
npx @liveauth-labs/mcp-server就是这样!服务器在演示模式下运行,每次验证3次。
注: 演示模式返回真实的Lightning发票(因此您可以看到实际的支付流程),但确认是为了测试而模拟的。对于生产,设置 LIVEAUTH_API_KEY.选项2:生产模式
- 获取API密钥 在 Liveauth.app
- 添加到克劳德桌面 (
claude_desktop_config.json):
{
"mcpServers": {
"liveauth": {
"command": "npx",
"args": ["-y", "@liveauth-labs/mcp-server"],
"env": {
"LIVEAUTH_API_KEY": "la_pk_xxx"
}
}
}
}- 重新启动克劳德 -完成!
选项3:CLI(可编程)
# Production
export LIVEAUTH_API_KEY=la_pk_xxx
npx @liveauth-labs/mcp-server
# Demo
npx @liveauth-labs/mcp-server______________________________________________________________________
这是什么?
此MCP服务器允许AI代理(Claude、GPT、AutoGPT等):
- 启动MCP会话并获得工作量证明挑战
- 解决挑战以证明计算工作
- 接收JWT令牌以进行经过身份验证的API访问
- 测量API使用情况,每次调用sats
安装
npm install -g @liveauth-labs/mcp-server或者直接与npx一起使用:
npx @liveauth-labs/mcp-server配置
克劳德桌面版
添加到您的 claude_desktop_config.json:
{
"mcpServers": {
"liveauth": {
"command": "npx",
"args": ["-y", "@liveauth-labs/mcp-server"],
"env": {
"LIVEAUTH_API_BASE": "https://api.liveauth.app",
"LIVEAUTH_API_KEY": "your-project-public-key"
}
}
}
}演示模式: 如果你忽略了 LIVEAUTH_API_KEY 或设置 LIVEAUTH_DEMO=true,服务器将使用免费的演示端点(每次验证3个sat)。这对于没有API密钥的测试非常有用。
其他MCP客户端
服务器通过stdio进行通信。从以下内容开始:
liveauth-mcp可用工具
liveauth_mcp_start
启动新的LiveAuth MCP会话。默认情况下返回PoW挑战,或者在以下情况下返回Lightning发票 forceLightning=true.
参数:
forceLightning(布尔值,可选):如果为真,则请求闪电发票而不是PoW挑战
退货(PoW):
{
"quoteId": "uuid-of-session",
"powChallenge": {
"projectId": "guid",
"projectPublicKey": "la_pk_...",
"challengeHex": "a1b2c3...",
"targetHex": "0000ffff...",
"difficultyBits": 18,
"expiresAtUnix": 1234567890,
"signature": "sig..."
},
"invoice": null
}回报(闪电):
{
"quoteId": "uuid-of-session",
"powChallenge": null,
"invoice": {
"bolt11": "lnbc...",
"amountSats": 50,
"expiresAtUnix": 1234567890,
"paymentHash": "abc123..."
}
}liveauth_mcp_confirm
提交已解决的工作量证明挑战以接收JWT身份验证令牌。
参数:
quoteId(string):起始响应中的quoteIdchallengeHex(string):开始响应中的挑战十六进制nonce(number):解决PoW挑战的随机数hashHex(string):得到的哈希值(sha256)projectPublicKey:challengeHex:nonce)expiresAtUnix(数字):挑战的到期时间戳difficultyBits(数字):挑战中的难度位signature(string):挑战签名
退货:
{
"jwt": "eyJhbGc...",
"expiresIn": 600,
"remainingBudgetSats": 10000,
"refreshToken": "abc123def456..."
}注: 保存 refreshToken!使用 liveauth_mcp_refresh 无需重新验证即可获得新的JWT。
liveauth_mcp_charge
在进行经过身份验证的调用后测量API使用情况。用每个API请求的成本(以sat为单位)调用它。
参数:
callCostSats(数字):在sats中调用API的成本
退货:
{
"status": "ok",
"callsUsed": 5,
"satsUsed": 15
}如果超出预算:
{
"status": "deny",
"callsUsed": 100,
"satsUsed": 1000
}liveauth_mcp_status
检查MCP会话的状态。用于轮询闪电支付确认。
参数:
quoteId(string):起始响应中的quoteId
退货:
{
"quoteId": "uuid-of-session",
"status": "pending",
"paymentStatus": "pending",
"expiresAt": "2026-02-17T12:00:00Z"
}当 paymentStatus 如果“付费”,则确认会话。呼叫 liveauth_mcp_confirm 再次获得JWT。
liveauth_mcp_lnurl
获取会话的Lightning发票(lnget兼容)。使用此功能可检索BOLT11发票,以便使用任何Lightning钱包付款。
参数:
quoteId(string):起始响应中的quoteId
退货:
{
"pr": "lnbc2100n1...",
"routes": []
}注: 这与lnget和其他Lightning支付工具兼容。在以下情况下使用此功能轮询发票 liveauth_mcp_confirm 返回“待付款”。
liveauth_mcp_usage
在不收费的情况下查询当前使用情况和剩余预算。在进行API调用之前,使用此功能检查状态。
参数: (无需)
退货:
{
"status": "active",
"callsUsed": 5,
"satsUsed": 15,
"maxSatsPerDay": 10000,
"remainingBudgetSats": 9985,
"maxCallsPerMinute": 60,
"expiresAt": "2026-02-17T12:00:00Z",
"dayWindowStart": "2026-02-17T00:00:00Z"
}liveauth_mcp_refresh
刷新JWT令牌而不重新进行身份验证。当当前JWT到期时,使用confirm返回的refreshToken获取新的JWT。
参数:
refreshToken(string):来自确认响应的refreshToken
退货:
{
"jwt": "eyJhbGc...",
"expiresIn": 600,
"remainingBudgetSats": 9985
}注: 安全地保存refreshToken。您需要它来延长会话,而无需解决新的PoW或进行另一次闪电支付。
使用示例
PoW身份验证
- 呼叫
liveauth_mcp_start获得PoW挑战和报价Id - 解决PoW挑战:
- 计算 hash = sha256(projectPublicKey:challengeHex:nonce) - 查找哈希值\` API请求的标头
- 每次API调用后,调用
liveauth_mcp_charge通话费用以卫星为单位
闪电身份验证
- 呼叫
liveauth_mcp_start随着forceLightning: true获取Lightning发票 - 使用
liveauth_mcp_lnurl(或投票liveauth_mcp_status)获取BOLT11发票 - 使用您的Lightning节点/钱包支付发票
- 投票
liveauth_mcp_status使用quoteId直到付款状态为“已支付” - 呼叫
liveauth_mcp_confirm只需报价即可收到JWT - 使用JWT并致电
liveauth_mcp_charge同上
身份验证流程
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ AI Agent │────▶│ MCP Server │────▶│ LiveAuth API │
│ │ │ │ │ │
│ 1. Start │ │ /api/mcp/start │ │ Returns PoW │
│ 2. Solve PoW │ │ │ │ challenge │
│ 3. Confirm │ │ /api/mcp/confirm│ │ Returns JWT │
│ 4. API calls │ │ │ │ │
│ 5. Charge │ │ /api/mcp/charge │ │ Meter usage │
└─────────────────┘ └─────────────────┘ └─────────────────┘
## x402 Compatibility
LiveAuth supports the x402 standard (Cloudflare/Coinbase). Use either format:
L402 (LiveAuth native)
curl -H "Authorization: L402 l402_xxx" https://api.liveauth.app/api/mcp/start
x402 (Cloudflare/Coinbase compatible)
curl -H "Authorization: x402 preimage_xxx" https://api.liveauth.app/api/mcp/start
API接受两者并返回 `WWW-Authenticate: x402` 在402个回复中。
## 为什么选择LiveAuth?
**对于API提供商:**
- 在没有验证码的情况下保护端点免受滥用
- 通过小额支付将人工智能代理访问货币化
- 无用户摩擦(代理处理身份验证)
**对于AI代理:**
- 无权限访问(无帐户注册)
- 经过加密验证的身份验证
- 使用计算(PoW)或卫星支付
## 发展
Install dependencies
npm install
Build
npm run build
Run locally
node dist/index.js
## 资源
- [LiveAuth演示和文档](https://liveauth.app)
- [MCP协议规范](https://modelcontextprotocol.io)
-
## 许可证
麻省理工学院