Skip to main content
Glama
AgentOTP

AgentOTP

by kuanlinb

AgentOTP

2FA codes for AI agents, approved on your phone.

Your agent hits a login that asks for a 2FA code. With AgentOTP it asks for the code over MCP or REST, you get a push notification with the agent's reason, and one tap with Face ID lets exactly that code through. Agents only see the accounts you picked, and every code they read is logged.

It is a self-hosted TOTP vault on the Cloudflare Workers free plan, with a passkey-only web app for people.

Deploy to Cloudflare

繁體中文說明 · Deploy guide · Threat model · Backup and key rotation · Security policy

What it does

For people (an installable web app that works well as an iPhone home-screen app)

  • Passkey sign-in only (Face ID, Touch ID, Windows Hello, a password manager). No passwords. Invite-only.

  • Codes with a countdown ring, tap to copy, search, English and Traditional Chinese.

  • Add accounts by camera QR scan, screenshot upload, pasted otpauth:// links, manual entry, or a Google Authenticator export QR.

  • Each user has their own vault. Share a single account with another user; they see codes, never the secret.

  • Export any time: encrypted backup file, Google Authenticator QR codes, or plain otpauth:// links. An offline decrypt script needs nothing but Node.js. See docs/backup.md.

For AI agents

  • Remote MCP server at https://<your-instance>/mcp with OAuth (claude.ai, the Claude apps, Claude Code and other MCP clients), or a static abx_… token.

  • REST: GET /api/v1/accounts and GET /api/v1/code?query=github with Authorization: Bearer abx_….

  • Each connection only sees the accounts you chose, and every code request is written to the activity log.

Approvals

  • Mark an account "ask me first". An agent's request sends a push notification with the agent's stated reason; you approve with a passkey.

  • Grant once, for 15 minutes, 1 hour or 8 hours, or always. Revoke grants and connections at any time.

  • Optional notification on every agent access, per account.

Related MCP server: Authn8 MCP Server

Agent API in one minute

curl -H "Authorization: Bearer abx_..." \
  "https://<your-instance>/api/v1/code?query=github&reason=deploy%20PR%2012&wait_seconds=20&min_validity_seconds=10"

Parameter

Range

Meaning

query

Account id, exact label, or a partial match on issuer or label

reason

short text

Shown to you, marked as untrusted text, when approval is needed

wait_seconds

0–25, default 20

How long the request waits for your approval before it returns

min_validity_seconds

0–20, default 0

If the current code expires sooner than this, wait for the next one

The response is either status: "ok" with code, expires_in and next_code, or status: "pending_approval" (HTTP 202 with a Retry-After header) with approval_id and retry_after_seconds. Pending approval is not an error: call again with the same arguments after retry_after_seconds. The MCP tools list_2fa_accounts and get_2fa_code take the same arguments and return the same fields.

How it compares

AgentOTP

Phone authenticator apps (Google Authenticator, Aegis, 2FAS)

Password managers with TOTP (1Password, Bitwarden)

Self-hosted TOTP web apps (for example 2FAuth)

Runs on

Your Cloudflare account, free plan

Your phone

Vendor cloud, or your server

Your server (PHP and a database)

Sign-in

Passkey only

Device unlock

Master password and/or passkey

Password, optional WebAuthn

AI agent access

MCP (OAuth) and REST, limited per connection

No

CLI and service accounts

REST API

Phone approval per agent request

Yes, per account, with time-boxed grants

No

No

No

Stores passwords

No

No

Yes

No

Cost

Free plan

Free

Paid tiers

Free, plus hosting

Based on public documentation as of November 2026. Corrections are welcome in an issue.

Limitations

  • Free-plan CPU. A Worker request gets 10 ms of CPU on the free plan. Opening the vault page decrypts every account and computes its codes, which fits roughly 150 accounts per user. Above that the page can fail with a CPU-limit error.

  • Daily free-plan quotas (100,000 requests, D1 and KV write limits) can be used up by a flood of requests. That stops the service until UTC midnight; it does not leak data. See THREAT_MODEL.md.

  • OAuth client registration (Dynamic Client Registration) is limited to 5 new clients per IP per day and 100 per instance.

  • MCP versions: 2026-07-28 (no initialize; the version travels in each request's _meta) plus the legacy 2025-11-25, 2025-06-18 and 2025-03-26 handshake.

  • Agent limits: 20 codes per minute and 500 per day per connection; 30 approval requests per day per connection.

  • TOTP only. No HOTP, Steam Guard or password storage. No offline mode.

  • One URL per instance. Passkeys are bound to the domain. After setup, other hostnames redirect (GET) or get HTTP 421.

  • iPhone push needs iOS 16.4 or later and the app added to the home screen.

  • No professional security audit. Read the threat model: whoever controls the Cloudflare account can read every secret.

Deploy

The short version; docs/deploy.md has the details.

  1. Click Deploy to Cloudflare above. Cloudflare copies the repository to your GitHub account, creates the D1 database and KV namespace, and asks for one secret, AGENTOTP_SECRET (openssl rand -base64 32). Save that secret in your password manager.

  2. Open https://<worker-name>.<your-subdomain>.workers.dev/, paste the root secret on the setup page and create your passkey. The secret stays in the browser; the page only sends an HMAC proof.

  3. Invite other people from Settings. Connect agents from the AI connections page.

From the command line instead:

npm ci
npx wrangler login
npx wrangler secret put AGENTOTP_SECRET   # paste the output of: openssl rand -base64 32
npm run deploy                           # builds, creates D1 and KV on the first run, applies migrations

Develop

npm ci
npm run dev:setup          # writes .dev.vars with a throwaway root secret and TEST_MODE=1
npm run dev                # http://localhost:5173
npm run typecheck && npm test
npm run e2e                # resets the local database, starts Vite, runs the Playwright e2e and the MCP SDK test

The e2e test needs Playwright's Chromium (npx playwright install chromium, or point PW_CHROME at a Chrome binary). The MCP SDK test needs a Python venv in .venv with tests/requirements.txt. See CONTRIBUTING.md.

Part

Where

Worker entry: security headers, routing, OAuth provider, daily cleanup

worker/index.ts

Passkeys, invites, sessions, first-run setup and break-glass recovery

worker/routes/auth.ts, session.ts, setup.ts

Web app API

worker/routes/app.ts

MCP and REST

worker/routes/agent.ts

Permissions, audit, rate limits, approvals

worker/lib/core.ts

Encryption (AES-256-GCM, versioned keyring, HKDF from one root secret)

worker/lib/crypto.ts, worker/lib/keys.ts, shared/keys.ts

TOTP, otpauth, Google Authenticator migration format

shared/otp.ts

Schema

migrations/

Web app (React and shadcn/ui)

web/src/

License

Apache-2.0

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Access your team's 2FA codes from AI agents without sharing secrets. List accounts, generate TOTP codes, and maintain full audit trails. Built for DevOps, CI/CD pipelines, and automated workflows that need to authenticate to protected services.
      14
      5
      77 npm
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Enables AI agents to securely manage local credentials, obtain short-lived tokens for authenticated API access, and audit every use by purpose.
      9
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI agents to look up stored logins by URL, name, or alias and use them without seeing the secrets, injecting authentication into HTTP requests, running commands with credentials in the environment and scrubbed output, and fetching 2FA codes, subject to per-credential policies and user approval.
      23
      MIT