AI Agent Delegation Guide

AI Credential Broker & MCP Integration Guide

Never paste plaintext passwords or permanent 2FA seeds into AI chat windows. AI agents request scoped access on demand, LazyCoffee surfaces a live approval prompt on your phone or desktop, and you authorize with biometrics to release an ephemeral E2EE bundle.

1. Bind a Scoped Agent Token in App

  • Open LazyCoffee and go to Settings -> AI Credential Broker -> Bind AI Assistant.
  • Set an agent name (e.g. Claude Desktop / Cursor) and restrict its maximum allowed scopes (account, password, totp_code, notes).
  • Copy the one-time lca_... agent token; your primary user session JWT is never shared with AI agents.

2. Connect via MCP or REST API

  • For Claude Desktop or Cursor, configure @lazycoffee/mcp-server to handle ephemeral P-256 key generation and local decryption automatically.
  • Each request specifies targetDomain, minimal requestedScopes, and a human-readable reason.
  • Approving a 15-minute task lease (task_15m) lets the local MCP client reuse the scoped grant without repeated prompts.

3. Verify Number Matching & Approve

  • Pending requests appear immediately on your home banner or via real-time SSE stream, visually separating verified metadata from the AI self-reported reason.
  • For new domains or sensitive fields (password / notes), tap the matching 2-digit code shown on the AI side from 3 shuffled options before biometrics.
  • Tap Reject & Block anytime to blacklist suspicious domains for that agent, or toggle the Global Freeze switch.

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 ToolBest ForPayload & Security Guarantee
lazycoffee_get_totp_code2FA verification stepsRequests only account + totp_code; computes the live 6-digit OTP on your device without ever exposing the raw TOTP seed.
lazycoffee_request_credentialScoped login or API workflowsRequests 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"
EndpointAuth HeaderBehavior & Lifecycle
POST /api/ai-auth/requestsBearer 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/waitBearer lca_...Supports SSE (?mode=sse) or long polling (?mode=poll) to wake up immediately upon biometric decision.
POST /api/ai-auth/requests/:id/consumeBearer lca_...Atomically returns encryptedGrantBundle via PostgreSQL FOR UPDATE; wipes bundle on final consumption (replay returns 409).

3. Security Safeguards & Architecture Guarantees

  1. End-to-End Ephemeral Envelopes (ECDH-P256 + AES-256-CBC + HMAC-SHA256): Even with zero-knowledge vault encryption enabled, your client unlocks locally and seals credentials directly for the AI ephemeral public key—the server never sees plaintext.
  2. Blind 3-Option Number Matching: GET /api/ai-auth/pending strips the raw matchCode and delivers 3 shuffled candidates (matchCodeOptions). Submitting the wrong code fails closed and marks the request REJECTED.
  3. Domain Blocklists & Instant Kill Switch: Choosing REJECT_AND_BLOCK adds targetDomain to the agent blocked_domains list, while Settings -> AI Credential Broker provides full audit history and an instant Global Freeze toggle.

Ready to Delegate Credentials Safely to AI?

Download the latest LazyCoffee client, create your first scoped agent token, and keep every AI access biometric-gated and auditable.