autologin-mcp
Open-source MCP server · MIT · v1.0.0

Auto-login MCP server for AI coding agents

Let your AI agent log in. Keep the password. When Claude Code hits a login page or an expired session while testing your web app, it calls login, and autologin-mcp fills the form with credentials stored on your machine. The password never reaches the model.

Install in Claude Code
npx autologin-mcp install

Then add a login profile in a normal terminal, not in the AI chat: npx autologin-mcp add

✻ Welcome to Claude Codecwd: ~/shop-app

> Test the checkout flow on staging.example.com and report any bugs

⏺ I'll open the store in Chrome and walk through checkout.

⏺ claude-in-chrome - navigate (MCP)(url: "https://staging.example.com/checkout")

⎿  Redirected to https://staging.example.com/login?next=/checkout

⏺ The session expired and the store sent me to its login page. I'll sign in with autologin.

⏺ autologin - login (MCP)(url: "https://staging.example.com/login?next=/checkout")

⎿  { "status": "run_in_page", "profile": "staging", "expires_in_s": 60, "script": "await (async () => …)()" }

⏺ claude-in-chrome - javascript_tool (MCP)(action: "javascript_exec", text: "await (async () => …)()")

⎿  { "status": "success", "url": "https://staging.example.com/checkout" }

⏺ Signed in as qa@example.com. The password never entered this chat. Back to the checkout test.

A simulated Claude Code session. The agent decides when to log in; autologin-mcp fills the password straight into the page, so the transcript only shows a one-time script and the outcome.

Why AI agents need a login tool

An AI agent that tests your web app in a real browser meets a login form sooner or later: a session expires, a token is revoked, a test logs out. Every usual workaround either leaks the password or stops the run.

Sessions expire mid-run.

Long agent sessions outlive login sessions. The agent stops, or asks you for the password in the chat.

Chat is not a vault.

A password pasted into the conversation goes to the model provider and lands in transcripts, logs and context summaries.

Files the agent reads leak too.

A .env in your project, or any file the agent can open, ends up in the same context, and sometimes in git.

With autologin-mcp.

The agent calls login, the form is filled from a file on your machine, and the run continues.

How autologin-mcp works

The agent decides when to log in. A small deterministic program on your machine does the how, with no AI involved.

  1. When the tab under test shows a login form, a 401/403, a login redirect or a "session expired" message, the agent calls the login tool with the tab's URL. autologin-mcp picks the matching profile.

  2. The result holds a small loader script that contains only a one-time URL on 127.0.0.1. It expires after 60 seconds and never contains a credential.

  3. The agent runs the script in the tab. The local bridge releases the credentials only if the browser-set Origin header matches the profile's site, so a page on another site gets nothing.

  4. autologin-mcp fills the fields the way React, Vue and Angular forms expect, submits, and returns success, or failed with the page's own error message. Then the agent continues the task.

Agent → autologin-mcp⏺ autologin - login (MCP)
    url: "https://staging.example.com/login?next=/checkout"

# Called when the page shows a login form, a 401/403,
# a redirect to a login URL or "session expired".
# The agent never asks you for the password.
autologin-mcp → agent{
  "status": "run_in_page",
  "profile": "staging",
  "expires_in_s": 60,
  "script": "await (async () => …)()",
  "function": "async () => …"
}

# No username, no password: only a one-time
# URL on 127.0.0.1 that works once, for 60 seconds.
Tab → 127.0.0.1 bridgeOrigin: https://staging.example.com
✓ matches profile "staging": credentials released once

Origin: https://phishing.example.net
✗ no matching profile: nothing released

# Browsers set the Origin header themselves.
# Page scripts cannot fake it.
Result returned to the agent{ "status": "success",
  "url": "https://staging.example.com/checkout" }

{ "status": "failed",
  "hint": "Invalid email or password" }

# Three failed logins in five minutes pause the
# profile, so a wrong password cannot lock the account.

With Chrome remote debugging turned on, autologin-mcp fills the tab itself over the Chrome DevTools Protocol (CDP), and the agent runs nothing. Bridge mode and CDP mode in detail

Quick start in 2 min

Requires Node.js 22.12+, Claude Code, and a browser tool such as Claude in Chrome. You type the password only into your own terminal.

# 1. Register the MCP server, skill and guard hook in Claude Code
$ npx autologin-mcp install

# 2. Add a login profile. Run this in a normal terminal, not in the AI chat.
$ npx autologin-mcp add
  Profile name: staging
  Root URL: staging.example.com
  Username: qa@example.com
  Password (hidden):

# 3. Restart Claude Code and test as usual.

Works with your browser tool

autologin-mcp does not replace your browser automation. The agent keeps the browser tool it already has; autologin-mcp only handles the login, then hands the tab back.

Claude in Chrome

The primary setup, tested end to end on real apps. The agent runs the script field with javascript_tool.

# Claude Code + Claude in Chrome
javascript_tool(
  text: login.script
)

Playwright MCP

The agent passes the function field to browser_evaluate, or both share one Chrome over CDP.

# Claude Code + Playwright MCP
browser_evaluate(
  function: login.function
)

chrome-devtools-mcp

The agent passes the function field to evaluate_script, or both share one debug Chrome over CDP.

# Claude Code + chrome-devtools-mcp
evaluate_script(
  function: login.function
)
  • Claude Code
  • Google Chrome
  • CDP mode: no JavaScript tool needed
  • Any stdio MCP client (manual setup)

Built so the model never sees the password

autologin-mcp keeps secrets out of the model context by design, and says plainly what it does not protect against.

Origin-checked bridge

Credentials go only to pages whose browser-set Origin belongs to the profile. A prompt-injected page on another site gets nothing.

One-time, loopback only

The bridge listens on 127.0.0.1. Each script carries a random token, works once and expires in 60 seconds.

Guard hook

A Claude Code PreToolUse hook and deny rules block the agent from reading the credentials folder, also in skip-permissions mode.

Redacted results

Every tool result and error is scrubbed of each password. Failed attempts clear the password field.

No account lockouts

Three failed logins in five minutes pause the profile until you check the credentials.

Honest limits

It prevents accidental exposure, not a deliberately hostile agent. Use dedicated test accounts. Security model

Stop pasting passwords
into chat

How autologin-mcp compares with the usual ways of getting an AI agent past a login form.

autologin-mcp

MCP login tool

Password reaches the model
No
Agent recovers from an expired session
Yes
Credentials can end up in git
No

Credentials live in one global file outside your projects.

Install now

Paste the password into the chat

Manual

Password reaches the model
Yes
Agent recovers from an expired session
Only if pasted again
Credentials can end up in git
No

Put it in the prompt or a project file

Shortcut

Password reaches the model
Yes
Agent recovers from an expired session
Yes
Credentials can end up in git
Possible

Log in by hand whenever the session expires

Babysitting

Password reaches the model
No
Agent recovers from an expired session
No, it stops
Credentials can end up in git
No

Frequently asked questions

How do I let Claude Code log in to my web app without giving it my password?

Install autologin-mcp with npx autologin-mcp install and add a login profile in a normal terminal with npx autologin-mcp add. When Claude Code's browser tab shows a login form, Claude calls the login tool and autologin-mcp fills the form with the credentials stored on your machine. Claude only sees the outcome, never the password.

What happens when my session expires while an AI agent is testing my app?

Without autologin-mcp the agent stops or asks you for the password. With autologin-mcp it notices the login form, session-expired message, 401/403 or login redirect, calls login, and continues the task where it left off.

Does the password ever reach the AI model?

No. The password goes from a local credentials file directly into the page, over a one-time 127.0.0.1 bridge that checks the page's origin or through the Chrome DevTools Protocol. Tool results are redacted, and a guard hook blocks the agent from reading the credentials file.

Which agents and browser tools does autologin-mcp work with?

It is built and tested for Claude Code with Claude in Chrome, and also works with Playwright MCP and chrome-devtools-mcp. Other MCP clients can run the stdio server; the installer, skill and guard hook are Claude Code features today.

Do I need to enable Chrome remote debugging?

No. The default bridge mode needs no browser setup. Remote debugging enables CDP mode, which helps when the app's Content-Security-Policy blocks the bridge.

Can a malicious page trick the agent into sending my credentials to it?

A profile only fills pages whose host matches its root URL. The bridge checks the Origin header that the browser sets and page scripts cannot fake, and CDP mode reads the tab's URL from Chrome. A page on another site receives nothing.

Does autologin-mcp support SSO, two-factor authentication or multi-step logins?

Not yet. It handles the common username and password form on the app's own page, including React, Vue and Angular forms. Multi-step logins, iframes, SSO login hosts and TOTP codes are on the roadmap.

Is autologin-mcp free?

Yes. autologin-mcp is open source under the MIT license.

More answers: FAQ · Troubleshooting · llms.txt for AI assistants