Back to Blog

Give AI Agents Secure 2FA Access with Authn8 MCP Server

Published: December 7, 2025 8 min read Developer Tools

AI agents like Claude, Cursor, ChatGPT, and others are transforming how developers work. They're automating code reviews, managing deployments, running tests, and handling complex multi-step workflows. But there's a problem: these agents hit a wall the moment they encounter a service protected by two-factor authentication.

The current workarounds are all bad. Some teams disable 2FA on shared accounts (dangerous). Others manually paste codes when the AI asks (breaks the automation). And a few share TOTP secrets directly with AI agents (even worse from a security standpoint).

What teams actually need is a secure, auditable way to give AI agents access to 2FA codes without exposing secrets or sacrificing security. That's exactly what the Authn8 MCP Server provides.


What is MCP?

The Model Context Protocol (MCP) is an open standard developed by Anthropic that lets AI agents use external tools. Instead of being limited to conversation, AI agents can call specific functions, read data, and perform actions in external systems.

Think of MCP servers as plugins for AI. When you configure an MCP server, you're giving your AI agent new capabilities. There's a growing ecosystem of MCP servers for everything from database queries to file management to API integrations.

The Authn8 MCP Server adds one critical capability: secure access to your team's 2FA codes.


Introducing the Authn8 MCP Server

The @authn8/mcp-server package connects AI agents to your Authn8 account. Once configured, your AI can generate TOTP codes for any account you've authorized.

The server exposes three tools:

list_accounts

Returns all 2FA accounts accessible to the current token. The AI can see what accounts are available before requesting a specific code.

get_otp

Generates a time-based one-time password for a specific account. Supports lookup by account ID or partial name matching. Returns a fresh 6-digit code.

whoami

Shows information about the current token: which business it belongs to, what groups it can access, how many accounts are available, and when the token expires.

Critically, these tools are read-only. AI agents can generate codes, but they can't modify accounts, change settings, or access TOTP seeds. Every code generation is logged in Authn8's audit trail.


Security Model

Security is built into every layer of the Authn8 MCP integration.

Personal Access Tokens (PATs)

Authentication uses Personal Access Tokens created in your Authn8 dashboard. PATs are simpler than OAuth for automation use cases and give you fine-grained control over what each token can access.

Scoped Permissions

Each PAT can be limited to specific groups. Your AI agent only sees the 2FA accounts you explicitly grant access to. If you have 50 accounts but only want the AI to access staging environment credentials, create a group with just those accounts and scope the token accordingly.

Token Expiry

Set tokens to expire after a specific period. This is particularly useful for time-limited projects, contractor access, or rotating credentials on a schedule.

Instant Revocation

Revoke any token immediately from your Authn8 dashboard. The AI loses access instantly, without affecting other tokens or team members.

No Seed Exposure

The most important security property: AI agents never see your TOTP seeds. They receive generated codes, not the underlying secrets. Even if a token is compromised, the attacker can only generate codes while the token is valid. They can't extract seeds to generate codes independently forever.


Use Cases

CI/CD Pipelines

Automated deployments can request 2FA codes programmatically while maintaining a full audit trail.

AI Coding Assistants

Claude or Cursor can access staging environments and deploy to protected infrastructure without breaking the workflow.

Automated Testing

Integration tests against 2FA-protected APIs become straightforward without manual intervention.

DevOps Automation

Scripts logging into cloud consoles (AWS, GCP, Azure) or container registries can handle 2FA automatically.


Getting Started

Setting up the Authn8 MCP Server takes just a few minutes. There are two ways to connect: the NPM package (for local AI clients) or the SSE server (for remote/cloud-based agents).

Step 1: Set Up Authn8

If you don't have an account, sign up for Authn8. It's free for up to 3 users. Add the 2FA accounts you want to share with your AI agents.

Step 2: Generate an MCP Token

Go to MCP Tokens in the sidebar and create a new token. Scope it to the groups containing the accounts your AI should access. Set an appropriate expiry.

Step 3: Configure Your AI Client

Option A: NPM Package (Local Clients)

Best for Claude Desktop, Claude Code, Cursor, AntiGravity, and other local AI clients that support stdio transport.

{
  "mcpServers": {
    "authn8": {
      "command": "npx",
      "args": ["-y", "@authn8/mcp-server"],
      "env": {
        "AUTHN8_API_KEY": "pat_your_token_here"
      }
    }
  }
}

Option B: SSE Server (Remote/Cloud Clients)

Best for ChatGPT, remote agents, and AI clients that support Server-Sent Events (SSE) transport.

  • Server URL: https://api.authn8.com/mcp/sse
  • Authorization Header: Bearer pat_your_token_here

How This Compares to Other Approaches

Disable 2FA

Remove protection entirely for automation access.

Automation
Audit Trail
Revocable
Secrets Protected

Manual Code Entry

Paste codes manually when AI asks for them.

Automation
Audit Trail
Revocable
Secrets Protected

Share TOTP Secrets

Give AI agents direct access to seed secrets.

Automation
Audit Trail
Revocable
Secrets Protected

Authn8 MCP Server

Secure, auditable, revocable 2FA access for AI.

Automation
Audit Trail
Revocable
Secrets Protected

Ready to Give Your AI Agents Secure 2FA Access?

No credit card required. Start securing your AI workflows today.

Get Started Free

Resources


Related Articles