cd /news/ai-agents/stop-pasting-passwords-into-your-ai-… · home › topics › ai-agents › article
[ARTICLE · art-175370] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=↑ positive

Stop Pasting Passwords Into Your AI Coding Agent

A developer built autologin-mcp, an open-source Model Context Protocol server that lets an AI coding agent log a browser tab into a test application without the password ever entering the model's context. When the agent hits a login form, session-expired message, 401/403 or login redirect, it calls the server's login tool and receives a one-time script or a CDP-driven form fill, with credentials stored locally in a 600-permission file outside the project. The server returns needs_human for SSO, passkeys, captchas and MFA, pauses a profile after three failed logins in five minutes, and the developer cautions it prevents accidental exposure rather than a deliberately hostile agent.

key takeaway

An MCP server can keep credentials out of the model's context by having the agent call a login tool that returns a one-time script or a CDP form fill, with the password stored locally in a 600-permission file and the agent seeing only success, submitted or failed.

by read6 min views2 publishedNov 24, 2026

autologin-mcp is an open-source MCP server that logs your AI agent's browser tab into the app it is testing. The password stays on your machine and never reaches the model.

You ask Claude Code to test the checkout flow on staging. It opens Chrome, clicks through a few pages, and then the app shows a login form: the session has expired.

From there, the run goes one of two ways. The agent stops and waits for you, or it asks you for the password. Neither is what you wanted from an autonomous test run.

The obvious fixes all put the password somewhere it does not belong.

.env the agent can read. I wanted the agent to get past the login screen on its own, without the password ever entering the conversation. So I built autologin-mcp.

autologin-mcp is a small Model Context Protocol server with one job. When the tab under test shows a login form, a "session expired" message, a 401/403 or a redirect to a login page, the agent calls its login tool. The tab gets signed in with credentials stored on your machine, and the agent only sees the outcome.

You:            "Test the checkout flow on staging"
Agent:          ...navigates... the session has expired, the app shows a login form
Agent:          calls autologin.login({ url })                 <- no password in the request
autologin-mcp:  returns a one-time script                      <- no password in the response
Agent:          runs it in the tab -> { "status": "success" }  <- the page got the password from your machine
Agent:          continues the checkout test

The agent decides when to log in by itself. The server ships its own instructions with the tools, so even a fresh agent with no memory of your project calls login when it meets a login form, then carries on with its task. Besides login, the agent gets list_profiles (names, URLs and usernames, never passwords), login_status and open_config.

There are two ways to fill the form. In neither does the password pass through the agent.

Bridge mode is the default and needs no browser setup:

login({ url }). 127.0.0.1, valid for 60 seconds. Origin header belongs to the profile's site. Browsers set that header themselves; a page's scripts cannot fake it.success, submitted, or failed with the page's own error message. The only hop that carries the password is step 5, from your machine straight to the page, and only to the profile's own site.

CDP mode kicks in when Chrome remote debugging is on (chrome://inspect/#remote-debugging, Chrome 144+). autologin-mcp connects to Chrome over the DevTools Protocol, finds the tab and fills it itself. The agent runs nothing.

In both modes the filler handles React, Vue and Angular inputs, forms that render late, identifier-first pages that ask for the email and then swap in the password field, and submit buttons in many languages.

Some logins need a person: single sign-on, passkeys, captchas, or a one-time code after the password. autologin-mcp recognises them and returns needs_human with a reason (sso, passkey, captcha, mfa_required) instead of failing or retrying, and the agent hands the login to you. Those pages never receive the credentials.

Three failed logins in five minutes the profile until you check the credentials, so an agent stuck in a loop cannot lock your test account.

Several layers keep the password away from the model:

600, outside every project, so they never end up in git. install adds a Claude Code PreToolUse hook and deny rules that block the agent from reading the credentials folder, also in skip-permissions mode. The honest part: autologin-mcp prevents accidental exposure, not a deliberately hostile agent. The username and the logged-in session are visible to the agent; only the password is kept out. Use dedicated test accounts, never production credentials.

You need Node.js 22.12+, Claude Code, and a browser tool for the agent, for example Claude in Chrome.

npx autologin-mcp install

npx autologin-mcp add

Then restart Claude Code and test as usual. When the app asks for a login, the agent calls login by itself.

You can add as many profiles as you need, including several accounts for the same app (say admin and viewer). A profile only fills pages whose host matches its root URL, such as example.com, *.example.com or localhost:3000.

autologin-mcp does not replace your browser automation. The agent keeps its own browser tool; autologin-mcp only handles the login, then hands the tab back. The one-time comes in three forms, one per kind of tool:

script field with javascript_tool. This is the primary setup, tested end to end on real apps. function field with browser_evaluate and evaluate_script. expression field with page.evaluate. It also reaches beyond Claude Code:

npx autologin-mcp print-config --client codex prints the configuration for Codex CLI. It also knows Gemini CLI, Cursor, VS Code, Claude Desktop and Hermes Agent. The server is in the official MCP Registry as io.github.olgaysezgin/autologin-mcp. The guard hook is a Claude Code feature, so with other agents, deny the credentials folder in their own permission settings.add --password-stdin creates a profile without any questions, reading the password from a pipe:

printf '%s' "$STAGING_PASSWORD" | npx autologin-mcp add staging \
  --url staging.example.com --username qa@example.com --password-stdin -y

There is deliberately no --password <value> option, because it would leave the password in your shell history and the process list.

The agent's JavaScript call often never comes back. In my Chrome profile, submitting any login form made another extension take over the tab, most likely a password manager offering to save the password. Claude in Chrome then failed with "Detached while handling command", although the login had worked. So the page also reports the outcome to the server, and a login_status tool hands it to the agent.

A memoryless agent has to find its own way. I ran five fresh Claude Code sessions (Opus, Sonnet and Haiku) on tasks that never mentioned logging in. All five called login on their own. The JavaScript call failed every time; four went straight to login_status, and one re-ran the script and got the first run's outcome. That is why the server's instructions spell out the whole recovery path.

"Run this script" means three different things. Claude in Chrome's javascript_tool supports top-level await but does not wait for a returned Promise. Puppeteer's page.evaluate waits for a Promise but has no top-level await, so it fails with "await is not defined". Playwright MCP wants a function. A friend hit the Puppeteer case in a real test, and that report became a release.

A good guard is annoying. The hook blocks any shell command that so much as mentions the credentials folder, including my own test commands while I was building this. That is exactly the point.

doctor and test <profile> commands autologin-mcp is free and MIT licensed. If it saves you a babysat test run, a star on GitHub helps other people find it. Issues and pull requests are welcome, especially reports from agents other than Claude Code.

── more in #ai-agents 4 stories · sorted by recency
── more on @autologin-mcp 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/stop-pasting-passwor…] indexed:0 read:6min 2026-11-24 · —