1. MCP Quickstart (Claude Desktop / Cursor)
Add the following configuration to your MCP client settings and replace LAZYCOFFEE_AGENT_TOKEN with the lca_... token generated in LazyCoffee:
{
"mcpServers": {
"lazycoffee": {
"command": "bun",
"args": ["run", "/path/to/lc-totp-app/packages/mcp-server/src/index.ts"],
"env": {
"LAZYCOFFEE_AGENT_TOKEN": "lca_your_agent_token_here",
"LAZYCOFFEE_API_URL": "https://www.lazycoffee.com"
}
}
}
}
| MCP Tool | Best For | Payload & Security Guarantee |
|---|
| lazycoffee_get_totp_code | 2FA verification steps | Requests only account + totp_code; computes the live 6-digit OTP on your device without ever exposing the raw TOTP seed. |
| lazycoffee_request_credential | Scoped login or API workflows | Requests minimal account / password / totp_code / notes fields; supports 15-minute local lease caching when task_15m is granted. |
2. Direct HTTP REST API Flow (Custom Agents)
Custom agents can integrate directly with /api/ai-auth/* by generating an ephemeral ECDH P-256 (prime256v1) keypair per request and submitting the uncompressed 65-byte Base64 public key:
# 1. 发起按需授权请求(由 AI 本地生成临时 ECDH P-256 公钥)
curl -X POST https://www.lazycoffee.com/api/ai-auth/requests \
-H "Authorization: Bearer lca_your_agent_token" \
-H "Content-Type: application/json" \
-d '{
"targetDomain": "github.com",
"accountHint": "alice@example.com",
"requestedScopes": ["account", "totp_code"],
"reason": "登录 GitHub 检查 CI 发布状态",
"ephemeralPubKey": "<Base64_Uncompressed_P256_PublicKey>"
}'
# 2. 长轮询 / SSE 等待用户在 App 上完成生物识别放行
curl "https://www.lazycoffee.com/api/ai-auth/requests/<requestId>/wait?mode=sse&timeoutMs=25000" \
-H "Authorization: Bearer lca_your_agent_token"
# 3. 原子阅后即焚消费(仅提取密文信封,服务端立即抹除载荷)
curl -X POST https://www.lazycoffee.com/api/ai-auth/requests/<requestId>/consume \
-H "Authorization: Bearer lca_your_agent_token"
| Endpoint | Auth Header | Behavior & Lifecycle |
|---|
| POST /api/ai-auth/requests | Bearer lca_... | Creates a 90s PENDING request (rate-limited to 5 req/min per user) and returns matchCode exclusively to the agent. |
| GET /api/ai-auth/requests/:id/wait | Bearer lca_... | Supports SSE (?mode=sse) or long polling (?mode=poll) to wake up immediately upon biometric decision. |
| POST /api/ai-auth/requests/:id/consume | Bearer lca_... | Atomically returns encryptedGrantBundle via PostgreSQL FOR UPDATE; wipes bundle on final consumption (replay returns 409). |