The Problem: AI Agents and the 2FA Wall
AI agents are taking over repetitive, high-value workflows: provisioning cloud infrastructure, running browser-based automation, logging into SaaS portals to pull reports, and executing multi-step tasks on behalf of developers and operations teams.
They work beautifully — right up until they hit a 2FA prompt.
Two-factor authentication is designed to confirm that a human is present. A one-time password (OTP) arrives by SMS or authenticator app, and someone needs to read it and type it in. That assumption breaks down the moment the agent isn't human.
The typical failure modes:
- The agent reaches a login screen, enters valid credentials, and then stalls indefinitely at the 2FA challenge.
- The automation pipeline fails overnight when no one is watching.
- Developers work around it by disabling 2FA on the shared service account — creating a real security gap.
- Someone sets up a manual "hold loop" where a human must be on standby to enter codes during automation runs.
None of these are acceptable at scale. AI agent adoption is accelerating, and 2FA is not going away. The question is: how do you give an agent access to a live OTP code without compromising the security model that makes 2FA worthwhile?
What is MCP (Model Context Protocol)?
Model Context Protocol (MCP) is an open standard that allows AI agents and large language model (LLM)-based tools to connect to external data sources and services. Developed by Anthropic and now adopted across the AI ecosystem, MCP gives agents a structured, authenticated way to call real-world tools — reading data, triggering actions, and retrieving live information — all within a controlled permission model.
Think of MCP as a universal adapter between AI agents (Claude, GPT-4, Cursor, and others) and the services they need to interact with. Instead of hardcoding API integrations or giving an agent raw credentials, MCP lets the agent request exactly what it needs, when it needs it, through a verified tool call.
Common MCP use cases today include:
- Querying live databases and internal APIs
- Retrieving file contents from storage systems
- Triggering GitHub actions, Slack messages, or calendar entries
- And now: fetching live 2FA codes at the moment of login
GroupFactor MCP Server: Live OTP Codes for AI Agents
GroupFactor has launched an MCP server that exposes a simple, secure tool call: get the current OTP code for a named service.
When an AI agent encounters a 2FA prompt, instead of stalling, it calls the GroupFactor MCP tool. GroupFactor returns the live, valid OTP — whether that's the current SMS code on your team's dedicated number, or the active TOTP rotating code — and the agent enters it and continues.
The OTP is only available to agents that have been granted explicit access by a GroupFactor admin. Every retrieval is logged. Codes are not stored beyond the delivery window. The security model that protects your team also protects your agents.
What the Agent Sees
From the agent's perspective, the integration is a single tool call:
get_otp({ service: "AWS Production" })
→ { code: "481623", expires_in: 22 }
The agent receives the current code and its remaining validity window, enters it at the 2FA prompt, and the workflow continues without human intervention.
What the Admin Configures
From the GroupFactor dashboard, administrators:
- Create an agent credential — a named identity for each AI agent or automation pipeline.
- Assign that credential access to specific services (e.g., "AWS Production" but not "Company GitHub").
- Every OTP retrieval is logged under that credential name, with a timestamp and the service accessed.
Access is revocable per agent credential at any time. If an automation pipeline is decommissioned, you remove its access in one step.
Use Cases: Where This Matters Most
CI/CD Pipelines That Access Protected Portals
Deployment pipelines regularly need to authenticate against cloud consoles, container registries, or infrastructure management tools. When these services enforce 2FA, pipelines either need a human in the loop or a way to retrieve the OTP automatically. GroupFactor's MCP integration slots directly into the agent step that handles authentication.
Browser Automation and RPA
Robotic process automation (RPA) tools and browser automation frameworks — Playwright, Puppeteer, and AI-driven browsers like Stagehand — routinely encounter 2FA challenges when automating logins. With the GroupFactor MCP server, the automation script calls get_otp at the challenge step and proceeds without interruption.
Scheduled and Overnight Agent Tasks
Agents running scheduled tasks — nightly report generation, automated data pulls, recurring SaaS integrations — are especially vulnerable to 2FA failures because no one is watching when they run. GroupFactor lets these tasks proceed autonomously without compromising the 2FA requirement on the underlying account.
LLM-Powered Internal Tools
Developer tools, internal dashboards, and Copilot-style assistants that act on behalf of users increasingly need to perform authenticated actions in external systems. If those systems require 2FA, MCP is the integration layer and GroupFactor is the OTP source.
Security: Why This is Not the Same as Disabling 2FA
The objection to giving AI agents OTP access is understandable: isn't this just removing the "human verification" element of 2FA?
The answer depends on what 2FA is protecting.
2FA exists to prevent account takeover by an attacker who has obtained a password. An AI agent running in your infrastructure is not an attacker — it's an authenticated system identity operating within your access control model. The question is whether that identity has been granted access to the OTP delivery mechanism under controlled, auditable conditions.
GroupFactor's MCP integration does not:
- Give agents access to all OTPs on your account
- Bypass the requirement to authenticate as a GroupFactor user
- Store OTPs beyond the delivery window
- Allow agents to self-grant access to new services
GroupFactor's MCP integration does:
- Require explicit, admin-granted access per agent per service
- Log every retrieval with timestamp, agent identity, and service name
- Deliver only the currently valid OTP — no historical codes
- Expire agent credentials independently of user accounts
This is the same access control and audit model that governs human team members in GroupFactor — applied to agents.
Getting Started
Prerequisites
- A GroupFactor account with at least one team and a connected service (SMS or TOTP)
- An AI agent that supports MCP tool calls (Claude, GPT-4 with tools, Cursor, or a custom MCP client)
Step 1: Install the GroupFactor MCP Server
The GroupFactor MCP server is available via npm:
npx @groupfactor/mcp-server
Or add it to your MCP client configuration:
{
"mcpServers": {
"groupfactor": {
"command": "npx",
"args": ["-y", "@groupfactor/mcp-server"],
"env": {
"GROUPFACTOR_API_KEY": "your-agent-api-key"
}
}
}
}
Step 2: Create an Agent Credential in GroupFactor
In the GroupFactor admin panel, navigate to Settings → Agent Credentials and create a new credential. Give it a descriptive name (e.g., "CI Pipeline – Staging") and copy the API key.
Step 3: Assign Service Access
Under the credential, select which services this agent is allowed to retrieve OTPs for. Save.
Step 4: Use in Your Agent Workflow
Your agent can now call get_otp at any point it encounters a 2FA challenge. The tool returns the current code and its expiry window.
Frequently Asked Questions
Can any AI agent use the GroupFactor MCP server?
Any agent or tool that supports the Model Context Protocol can use the GroupFactor MCP server. This includes Claude (via Claude Desktop or API), GPT-4 with tool use, Cursor, and custom MCP clients. If your framework supports MCP, it works with GroupFactor.
Does this mean AI agents can access my 2FA codes without my knowledge?
No. Every agent credential must be created by a GroupFactor administrator. No agent can self-register or self-grant access. All OTP retrievals are logged and visible in the admin panel. You can revoke an agent credential at any time.
Is SMS-based 2FA supported as well as TOTP?
Yes. The GroupFactor MCP server can return live SMS-delivered OTPs (from your team's dedicated Twilio number) and TOTP rotating codes. Both are accessible through the same get_otp tool call, specified by service name.
Does this create a compliance risk?
For most compliance frameworks, the question is whether access to authentication tokens is controlled, logged, and revocable. GroupFactor's MCP integration meets all three criteria. If you are operating under SOC 2, ISO 27001, or similar frameworks, consult your compliance team — GroupFactor provides the audit log export needed for access reviews.
What happens if the agent calls get_otp and the code has just expired?
GroupFactor returns the currently valid code with its remaining validity window. For SMS codes (which are valid once), GroupFactor returns the most recently received code. For TOTP codes, the code is valid for up to 30 seconds from generation. The agent should enter the code promptly after retrieval — the expiry window is included in the response.
Can I limit which services an agent can access?
Yes. Access is configured per agent credential per service. An agent authorized for "AWS Staging" cannot access "AWS Production" or any other service unless an admin explicitly grants it.
Stop letting 2FA block your AI agents
GroupFactor delivers live OTP codes to your agents through a secure, audited MCP integration — so your workflows run without human standby.
Start free trial →