Login MCP Server
Connects to Google Chrome via the DevTools Protocol to list open browser pages and read or set localStorage and cookies, enabling login-state synchronization between sites such as a SIT environment and localhost.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Login MCP Server
一个用于同步 SIT 环境登录信息到本地开发环境的 MCP 服务器。
功能
sync_login: 自动从源站点(如 SIT 环境)同步 localStorage 和 cookies 到目标站点(如 localhost)
get_login_info: 获取指定站点的登录信息
set_login_info: 手动设置指定站点的登录信息
list_browser_pages: 列出浏览器中所有打开的页面
Related MCP server: Debug Web MCP
工作原理
sequenceDiagram
participant User as 用户
participant Cursor as Cursor IDE
participant MCP as login-mcp
participant Chrome as Chrome浏览器
participant SIT as SIT页面
participant Local as localhost页面
User->>Chrome: 1. 启动Chrome带远程调试端口
User->>SIT: 2. 打开SIT页面并登录
User->>Cursor: 3. 请求同步登录信息
Cursor->>MCP: 4. 调用 sync_login 工具
MCP->>Chrome: 5. 通过CDP连接浏览器
MCP->>SIT: 6. 获取localStorage和cookies
SIT-->>MCP: 7. 返回登录数据
MCP->>Local: 8. 打开/切换到localhost
MCP->>Local: 9. 注入localStorage和cookies
MCP->>Local: 10. 刷新页面
MCP-->>Cursor: 11. 返回同步结果
Cursor-->>User: 12. 同步完成前置条件
1. 安装依赖
cd login-mcp
npm install2. 编译 TypeScript
npm run build3. 启动 Chrome(自动或手动)
MCP 需要通过 Chrome DevTools Protocol 与浏览器通信。
方式一:自动启动(推荐)
无需手动操作! login-mcp 会自动尝试:
首先连接到已运行的调试模式 Chrome
如果连接失败,自动启动一个新的 Chrome 实例
只需在 Cursor 中发送同步命令即可,MCP 会自动处理浏览器连接。
方式二:手动启动
如果自动启动失败,可以手动以调试模式启动 Chrome:
Mac:
# 推荐:使用 --user-data-dir 参数避免端口不监听的问题
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-debug
# 或者使用 open 命令
open -a "Google Chrome" --args --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-debugWindows:
"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 --user-data-dir=%TEMP%\chrome-debugLinux:
google-chrome --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-debug重要:
如果 Chrome 已经在运行且不是调试模式,需要先关闭所有 Chrome 窗口
如果直接使用
--remote-debugging-port=9222端口不监听,请添加--user-data-dir参数
4. 配置 Cursor MCP
在 Cursor 的 MCP 配置文件中添加:
Mac/Linux: ~/.cursor/mcp.json
Windows: %APPDATA%\Cursor\mcp.json
{
"mcpServers": {
"login-mcp": {
"command": "node",
"args": ["/Users/taowenxin/Desktop/login-mcp/dist/index.js"]
}
}
}请将路径替换为实际的项目路径。
使用方法
同步登录信息
在 Cursor 中对 AI 说:
帮我把 SIT 环境的登录信息同步到 localhost:8080或者指定具体参数:
使用 sync_login 工具,sourceUrl 为 sit.mfosunhani.com,targetUrl 为 http://localhost:3000查看登录信息
获取 sit.mfosunhani.com 页面的登录信息列出所有页面
列出当前浏览器打开的所有页面工具详细说明
sync_login
参数 | 类型 | 默认值 | 说明 |
sourceUrl | string | 源站点 URL(部分匹配) | |
targetUrl | string | 目标站点 URL | |
syncLocalStorage | boolean | true | 是否同步 localStorage |
syncCookies | boolean | true | 是否同步 cookies |
autoRefresh | boolean | true | 同步后是否刷新目标页面 |
browserURL | string | Chrome 调试地址 |
get_login_info
参数 | 类型 | 必填 | 说明 |
url | string | 是 | 站点 URL(部分匹配) |
browserURL | string | 否 | Chrome 调试地址,默认 http://localhost:9222 |
set_login_info
参数 | 类型 | 必填 | 说明 |
url | string | 是 | 目标站点 URL(部分匹配) |
localStorage | object | 否 | localStorage 数据 |
cookies | array | 否 | cookies 数组 |
refresh | boolean | 否 | 设置后是否刷新,默认 true |
browserURL | string | 否 | Chrome 调试地址,默认 http://localhost:9222 |
list_browser_pages
参数 | 类型 | 必填 | 说明 |
browserURL | string | 否 | Chrome 调试地址,默认 http://localhost:9222 |
项目结构
login-mcp/
├── package.json # 项目配置和依赖
├── tsconfig.json # TypeScript 配置
├── src/
│ └── index.ts # MCP 服务器源码
├── dist/ # 编译输出目录
│ └── index.js
└── README.md # 使用文档常见问题
1. 连接失败
错误信息:无法连接到 Chrome 浏览器 或 无法连接或启动 Chrome 浏览器
解决方法:
首选:让 MCP 自动启动 Chrome(无需手动操作)
如果自动启动失败,手动以调试模式启动 Chrome,建议添加
--user-data-dir参数检查是否有其他 Chrome 实例在运行(需要全部关闭后重新启动)
检查端口 9222 是否被占用
访问 http://localhost:9222/json 确认调试服务正常
1.1 端口不监听问题
错误信息:执行 --remote-debugging-port=9222 后端口不监听
解决方法:
# Mac
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-debug
# Windows
chrome.exe --remote-debugging-port=9222 --user-data-dir=%TEMP%\chrome-debug原因:当 Chrome 已有实例运行时,新的调试端口参数可能被忽略。使用 --user-data-dir 指定独立的用户数据目录可以解决此问题。
2. 找不到页面
错误信息:未找到源站点页面 或 未找到页面
解决方法:
确保目标页面已在浏览器中打开
检查 URL 是否正确(支持部分匹配,如
sit.mfosunhani.com)使用
list_browser_pages工具查看当前打开的页面
3. cookies 设置失败
某些 cookies 可能因为安全限制无法设置(如 HttpOnly、SameSite 等),这是正常现象。重要的登录 token 通常存储在 localStorage 中,一般不影响登录状态同步。
4. 重启 Cursor 后 MCP 不生效
修改 ~/.cursor/mcp.json 后需要重启 Cursor 才能生效。
开发
# 安装依赖
npm install
# 开发模式(监听文件变化)
npm run dev
# 编译
npm run build
# 运行
npm startLicense
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Browser MCP for logged-in tasks. Uses your Chrome — credentials stay local. Zero-token replay.
Let AI agents use any website you're logged in to. Sessions stay encrypted on your machine.
Logs your AI agent into websites, catches verification codes, and asks you before anything risky.
Browser automation MCP for whole web tasks in a cloud browser: saved logins, bot checks, replays.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to control an existing signed-in Chrome profile through MCP stdio, using its current tabs, cookies, and logins without pairing or a separate browser. It exposes tab management, page interaction, screenshots, and Chrome DevTools Protocol commands.MIT
- AlicenseBqualityBmaintenanceEnables agents to inspect localhost web applications through Chrome DevTools Protocol by listing Chrome targets, attaching to a page, capturing and querying network, console, navigation, and WebSocket events, and managing ephemeral sessions.81MIT
- AlicenseNot gradedqualityBmaintenanceEnables agents and CLI users to drive their locally installed Google Chrome through a dedicated persistent profile over the DevTools Protocol, so they can navigate open HTTP/HTTPS sites, manage tabs, and inspect pages while keeping existing sign-ins and cookies.MIT
- AlicenseBqualityBmaintenanceA drop-in chrome-devtools-mcp proxy that lets parallel AI agents, IDE windows, and Playwright/Puppeteer scripts share one persistent, logged-in Chrome. It lazy-launches a detached local browser on first tool call, keeping logins and extensions while avoiding profile-lock conflicts.433908 npmMIT