ie-mode-mcp
ie-mode-mcp
用于从 AI 代理通过 MCP (Model Context Protocol) 操作 Microsoft Edge IE 模式下运行的旧版 Web 应用程序的 MCP Server。
AI Agent ──(MCP / stdio)──> ie-mode-mcp ──> BrowserManager ──> selenium-webdriver
│
IEDriverServer.exe
│
Microsoft Edge (IE Mode)
│
Legacy Web Application仅由 Node.js 22 / TypeScript / selenium-webdriver 构成(无 HTTP Server、DB、DI、Logging Framework)
MCP Transport 仅支持 stdio
浏览器会话仅 1 个,WebDriver 操作完全顺序执行
不返回完整 HTML,
inspect_page返回为 LLM 总结的屏幕信息无审批流程。调用 Tool 时立即执行操作
目录
1. 快速开始
在 Windows 上执行以下操作。
git clone https://github.com/sumikof/iedriver-mcp.git
cd iedriver-mcp
npm install
npm run build
# IEDriverServer.exe のパスと、遷移を許可する Origin を指定して起動
$env:IE_MCP_DRIVER_PATH = "C:\tools\IEDriverServer.exe"
$env:IE_MCP_ALLOWED_ORIGINS = "http://legacy01.local"
node dist/index.js如果 stderr 输出 {"level":"info","event":"started","transport":"stdio"} 则表示启动成功。
通常无需手动启动,而是通过 AI 代理端的 MCP 设置 自动启动。
2. 前提条件
项目 | 内容 |
OS | Windows 11 / Windows 10(已登录的交互式会话) |
Node.js | 22 以上 |
浏览器 | Microsoft Edge(可使用 IE 模式) |
Driver | IEDriverServer.exe(Selenium 4.x 系列。推荐 32bit 版) |
IEDriverServer.exe 从 Selenium 下载页面 获取, 放置在任意文件夹(例如
C:\tools\)中。 由于 64bit 版存在已知限制,Selenium 官方推荐使用 32bit 版。IEDriver 受 GUI、窗口焦点和原生事件的影响, 因此建议在专用的 Windows VM 或专用的 Windows 会话中使用。
不假设在 Windows Service(Session 0)上运行浏览器的配置。
MCP Server、IEDriver 和 Edge 应在同一 Windows 环境中运行。
3. Windows 端预先设置
IEDriver 受环境设置影响很大。请先手动完成设置,然后再启动 MCP Server。
3.1 使 Edge 的 IE 模式可用
先通过 Edge 的手动操作确认目标站点可以在 IE 模式下打开。IE 模式通过以下
任一策略启用(位于 Software\Policies\Microsoft\Edge 下)。
策略(显示名称) | 注册表值名称 |
Configure Internet Explorer integration |
|
Configure the Enterprise Mode Site List |
|
Send all intranet sites to Internet Explorer | (在 Edge 77 及更高版本的组策略中设置) |
具体配置取决于组织策略,详情请参考 Microsoft 的 IE 模式文档 并咨询本组织的管理员。确保 Windows / Edge 已应用最新更新。
3.2 IEDriver 要求的设置
项目 | 所需状态 | 本 Server 中的处理 |
浏览器缩放 | 100% | 已设置 |
保护模式(Protected Mode) | 所有区域设置相同 | 未统一时启动会抛出异常。在 Internet 选项 → 安全 中统一 |
IEDriverServer 的位数 | 推荐 32bit | — |
如果保护模式设置未统一,browser_start 将失败。IEDriver 的
introduceFlakinessByIgnoringProtectedModeSettings 会导致行为不稳定,因此未使用。
4. 安装与构建
npm install # 依存パッケージの取得
npm run build # TypeScript を dist/ へビルド产物为 dist/index.js。构建后也可通过 npm start(= node dist/index.js)启动。
5. 环境变量
不使用配置文件(YAML / JSON),仅通过环境变量进行设置。
环境变量 | 说明 | 默认值 |
| msedge.exe 的路径 | 未指定(IEDriver 自动检测) |
| IEDriverServer.exe 的路径 | 未指定(从 |
| 允许 |
|
| 元素搜索和等待的默认超时时间(ms) |
|
IE_MCP_EDGE_PATH=C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe
IE_MCP_DRIVER_PATH=C:\tools\IEDriverServer.exe
IE_MCP_ALLOWED_ORIGINS=http://legacy01.local,http://legacy02.local
IE_MCP_TIMEOUT_MS=10000IE Driver 4.5.0 及更高版本会在未安装 IE 的环境(Windows 11 默认)中自动检测 Edge, 因此通常不需要
IE_MCP_EDGE_PATH。仅在自动检测失败时显式指定。如果优先考虑操作的可重复性,建议显式指定
IE_MCP_DRIVER_PATH。IE_MCP_ALLOWED_ORIGINS是用于防止误操作的简易限制,通过 Origin(scheme + host + port) 完全匹配进行判断。不进行路径级别的限制。
6. 启动方法
手动启动(用于确认操作)
PowerShell:
$env:IE_MCP_DRIVER_PATH = "C:\tools\IEDriverServer.exe"
$env:IE_MCP_ALLOWED_ORIGINS = "http://legacy01.local"
node dist/index.js命令提示符:
set IE_MCP_DRIVER_PATH=C:\tools\IEDriverServer.exe
set IE_MCP_ALLOWED_ORIGINS=http://legacy01.local
node dist\index.js通过 stdio 等待客户端连接。标准输入输出用于 MCP 协议,
因此在此状态下键盘输入不会有响应(正常)。所有日志输出到 stderr。
使用 Ctrl+C 退出(浏览器也会自动关闭)。
注意: 仅启动 MCP Server 不会启动浏览器。浏览器在代理调用
browser_start时才会启动。
常规操作
AI 代理(MCP 客户端)将本 Server 作为子进程启动。无需手动启动。 进行下一章的设置。
7. 注册到 AI 代理
在 MCP 客户端的配置文件中添加以下内容。
{
"mcpServers": {
"ie-mode": {
"command": "node",
"args": ["C:\\ie-mode-mcp\\dist\\index.js"],
"env": {
"IE_MCP_DRIVER_PATH": "C:\\tools\\IEDriverServer.exe",
"IE_MCP_EDGE_PATH": "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe",
"IE_MCP_ALLOWED_ORIGINS": "http://legacy01.local,http://legacy02.local",
"IE_MCP_TIMEOUT_MS": "10000"
}
}
}
}路径需要在 JSON 中转义反斜杠(
C:\\...)。args中指定构建后dist/index.js的绝对路径。对于 Claude Code,也可以使用
claude mcp add进行注册。
claude mcp add ie-mode --env IE_MCP_DRIVER_PATH=C:\tools\IEDriverServer.exe --env IE_MCP_ALLOWED_ORIGINS=http://legacy01.local -- node C:\ie-mode-mcp\dist\index.js注册后,如果客户端能看到包括 browser_start 在内的 10 个 Tool,则表示连接成功。
8. Tool 参考
公开的 Tool 共 10 个。不公开 WebDriver 的低级 API(如 findElement / executeScript)。
Tool | 输入 | 概要 |
| 无 | 启动 Edge IE Mode。如果已启动则重用现有会话 |
| 无 | 关闭浏览器。多次调用也不会出错 |
|
| 检查 URL 允许列表后导航 |
|
| 返回 URL / title / 屏幕文本 / 可操作元素 |
|
| 等待显示和启用后点击 |
|
| 向 input / textarea 输入 |
|
| 选择 |
|
| 等待条件满足 |
|
| 切换到弹出窗口或另一个窗口 |
| 无 | 返回当前屏幕的 PNG(MCP image content) |
通用: Selector
{ "by": "id | name | css | xpath | linkText", "value": "searchButton" }由于旧版 Web 应用中 name 和 xpath 使用频率较高,因此支持它们。
通用: frame(iframe 仅一层)
所有元素操作 Tool 都接受可选的 frame。指定后会先返回 defaultContent,
然后切换到该 frame,在其中搜索元素。
{
"frame": { "by": "name", "value": "mainFrame" },
"selector": { "by": "id", "value": "searchButton" }
}browser_start
{}{ "status": "ready", "reused": false }reused: true 表示直接使用了现有会话。如果现有会话已失效,则会自动重新启动。
navigate
{ "url": "http://legacy01.local/customer" }{ "url": "http://legacy01.local/customer", "title": "顧客検索" }inspect_page
代理理解屏幕的主要 Tool。不返回完整 HTML,仅返回 URL / title / 显示文本 /
可操作元素(a button input textarea select iframe)。
隐藏元素和 type="hidden" 的 input 会被排除。
{ "frame": { "by": "name", "value": "mainFrame" } }{
"url": "http://legacy01.local/customer",
"title": "顧客検索",
"text": "顧客検索 顧客名 支店 検索",
"elements": [
{ "tag": "input", "id": "customerName", "name": "customerName", "type": "text" },
{ "tag": "select", "id": "branch", "name": "branch", "text": "東京支店", "optionCount": 12 },
{ "tag": "button", "id": "searchButton", "text": "検索" },
{ "tag": "iframe", "name": "mainFrame" }
],
"truncated": false
}truncated: true表示元素数量达到上限(300 个)而被截断。如果元素列表中包含
iframe,要查看其内容,需要指定frame再次调用。
click
{ "selector": { "by": "id", "value": "searchButton" } }{ "url": "http://legacy01.local/customer", "title": "顧客検索" }等待元素显示和启用后点击。click 不会自动重试(为了防止在注册、更新、提交 已成功的情况下再次点击导致重复处理)。
type
{
"selector": { "by": "id", "value": "customerName" },
"text": "山田太郎",
"clear": true
}如果 clear(默认 true)为 true,则先执行 clear() 再输入;为 false 则追加输入。
select
{
"selector": { "by": "id", "value": "branch" },
"by": "text",
"value": "東京支店"
}{ "text": "東京支店", "value": "13", "index": 2 }by 可以是 text / value / index(index 从 0 开始)。
wait_for
不使用固定 sleep,而是显式等待。
{
"type": "visible",
"selector": { "by": "id", "value": "resultTable" },
"timeoutMs": 10000
}
| 所需输入 | 条件 |
|
| 元素存在于 DOM 中 |
|
| 元素已显示 |
|
| 元素已显示且可操作 |
|
| 元素的文本包含 |
|
| 当前 URL 包含 |
|
| title 包含 |
省略 timeoutMs 时使用 IE_MCP_TIMEOUT_MS。
switch_window
{ "target": "newest" }{ "index": 1 }{ "url": "http://legacy01.local/detail", "title": "顧客詳細", "index": 1, "windowCount": 2 }newest 会短时间轮询直到出现新的 Window Handle。如果未检测到,则切换到现有的最后一个 Window。
screenshot
{}返回 PNG 图像(MCP 的 image content)。用于确认仅凭 DOM 无法判断的布局和错误画面。
9. 使用示例
基本循环
browser_start → navigate → inspect_page → click / type / select → wait_for → inspect_page通过 inspect_page 了解屏幕 → 操作 → 通过 wait_for 等待结果 → 再次 inspect_page,重复此过程。
示例: 搜索客户“山田太郎”并打开详情画面
# | Tool | 参数 |
1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
示例: 操作 iframe 内部
{"tool": "inspect_page", "args": {}}
{"tool": "inspect_page", "args": { "frame": { "by": "name", "value": "mainFrame" } }}
{"tool": "click", "args": {
"frame": { "by": "name", "value": "mainFrame" },
"selector": { "by": "id", "value": "searchButton" }
}}每次操作都需要传递 frame 指定(因为内部每次都会返回 defaultContent 再切换,
状态不会保持)。
示例: 操作弹出窗口并返回原窗口
{"tool": "click", "args": { "selector": { "by": "id", "value": "openPopup" } }}
{"tool": "switch_window", "args": { "target": "newest" }}
{"tool": "inspect_page", "args": {}}
{"tool": "switch_window", "args": { "index": 0 }}10. 错误与处理
错误不返回 Selenium 的 Stack Trace,而是返回以下代码(isError: true)。
{
"error": "ELEMENT_NOT_FOUND",
"message": "Element was not found: id=searchButton",
"selector": { "by": "id", "value": "searchButton" }
}错误代码 | 含义 | 处理 |
| 浏览器未启动 | 调用 |
| 元素或 frame 未找到 | 使用 |
|
| 重新检查条件和 |
| 指定的 Window 不存在 | 重新检查 |
| 导航失败 | 检查 URL、网络、认证 |
| IEDriver / Edge 异常终止 | 通过 |
| 不在允许列表中的 Origin | 重新检查 |
| 参数无效 | 确认 Tool 的输入规范 |
| 其他(包括启动失败) | 检查 |
从 DRIVER_LOST 恢复
如果浏览器或 Driver 崩溃,内部 WebDriver 将被销毁,后续操作将返回
BROWSER_NOT_STARTED。不会自动恢复或自动重试前一步操作(为了防止重复注册等
副作用)。代理端需要重新调用 browser_start,通过 inspect_page 确认屏幕状态后
再继续操作。由于前一步操作可能已经成功,因此不应直接重新执行注册、更新类操作。
11. 日志
stdout 用于 MCP 协议,因此所有日志均输出到 stderr,每行一个 JSON。
{"level":"info","event":"started","transport":"stdio"}
{"level":"info","tool":"navigate","url":"http://legacy01.local/customer","durationMs":842}
{"level":"info","tool":"type","selector":{"by":"id","value":"password"},"textLength":16,"durationMs":128}
{"level":"error","tool":"click","selector":{"by":"id","value":"x"},"error":"ELEMENT_NOT_FOUND","message":"Element was not found: id=x","durationMs":5012}不记录输入字符串本身、Cookie、认证信息、完整 HTML(type 仅记录字符数)。
如果需要保存到文件,请重定向 stderr。
node dist/index.js 2>> C:\logs\ie-mode-mcp.log12. 故障排除
症状 | 确认事项 |
|
|
出现保护模式相关异常 | Internet 选项 → 安全性 中统一所有区域的保护模式设置 |
出现缩放相关异常 | 将 Edge / IE 的缩放恢复为 100% |
Edge 启动但未进入 IE 模式 | 确认 IE 模式的策略(站点列表等)。先手动确认能否以 IE 模式显示 |
操作卡住·无法点击元素 | 窗口是否最小化或非激活。远程桌面断开期间会不稳定 |
| 是否在 frame 内画面(指定 |
Agent 侧看不到 Tool | 是否使用绝对路径指定了 |
标准输出无任何输出 | 正常。日志输出到 stderr |
screenshot 对原因调查有效。可以确认仅靠 DOM 信息无法判断的状态(模态框、认证对话框、
渲染异常)。
13. 开发
src/
├─ index.ts MCP Server のエントリーポイント(stdio)
├─ config.ts 環境変数と stderr ログ
├─ tools.ts MCP Tool の Schema と Handler
├─ browser.ts BrowserManager(Selenium / IEDriver 操作の集約)
├─ selectors.ts Selector → Selenium の By 変換
└─ errors.ts Selenium Error → MCP Error Code 変換npm run build # tsc でビルド
npm start # node dist/index.jsMCP Tool 不直接操作 Selenium,必须通过
BrowserManager进行。所有 WebDriver 操作均通过 Promise Chain 串行化,即使 Tool 被并行调用, 也只会逐条发送给 IEDriver。
仅重试无副作用的操作(元素搜索·窗口句柄检测)。不重试
click或提交操作。
14. 限制事项
初始实现不支持以下内容。
多浏览器会话 / 多用户 / HTTP Transport / REST API / DB / 会话持久化 /
自动浏览器恢复 / 复杂重试策略 / WebDriver Grid / 通用 Selenium API /
executeScript Tool / 多层 iframe(仅支持一层)/ Element Cache / Metrics / 审批流 / 认证与授权
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Live browser debugging for AI assistants — DOM, console, network via MCP.
Screenshot, diff, audit and sitemap-capture any web page — 5 MCP tools for AI agents.
A paid remote MCP for AI agent browser MCP session, built to return verdicts, receipts, usage logs,
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/sumikof/iedriver-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server