fix(windows): resolve MCP stdio server crash on Windows#496
Open
6uu1 wants to merge 6 commits into
Open
Conversation
On Windows, npm packages like npx are installed as .cmd batch files. Dart's Process.start cannot directly execute these files, causing crashes when connecting to MCP stdio servers. This change wraps .cmd/.bat files and known npm commands (npx, npm) with cmd.exe /c for proper execution on Windows platforms.
- Add Windows support in _getSystemPath() to merge user PATH from registry via PowerShell, fixing missing npm paths in GUI apps - Improve _validateCommand() to properly validate .cmd/.bat files and npm commands using cmd.exe on Windows - This resolves crashes when adding MCP stdio servers like `npx -y @e2b/mcp-server` on Windows
The textSelect icon does not exist in lucide_icons_flutter 3.1.x, causing build errors. Replace with lassoSelect which serves similar purpose for text selection UI.
Owner
|
lucide图标那个我改了,可以把那个删了 |
Author
我去掉了。你看看 |
Owner
High Priority1. 预检与执行逻辑不一致,存在较严重的回归风险
2. Windows 命令大小写判断不一致,修复未完全覆盖
Medium/Low Priority3. 移除多余的进程测试开销 4. 缓存 5. 统一使用 6. 缺少对
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
修复在 Windows 平台上添加 MCP stdio 服务器时应用程序崩溃的问题(BEX64 异常)。
Closes #490
问题描述
在 Windows 上添加 MCP stdio 服务器(如
npx -y @e2b/mcp-server)并保存后,应用程序会立即崩溃退出。崩溃特征:
c0000409(STATUS_STACK_BUFFER_OVERRUN / C++ Fast-Fail)flutter_windows.dll原因分析
问题由两个层面的原因导致:
1. 命令执行方式问题
Windows 上 npm 全局包(如
npx)安装为.cmd批处理文件。Dart 的Process.start()无法直接执行这些文件,导致进程启动失败并触发底层异常。2. PATH 环境变量问题
Windows GUI 应用程序无法获取完整的用户 PATH 环境变量(相比于终端启动的应用)。当用户通过 npm 安装了 MCP 服务器命令后,Flutter 应用可能无法找到该命令。
修复方案
Commit 1: mcp_client 传输层修复
在
StdioClientTransport.create()中增加 Windows 特殊处理:Commit 2: Provider 层 PATH 解析与命令验证
_getSystemPath(): 通过 PowerShell 获取用户 PATH 并合并,解决 GUI 应用缺少 PATH 的问题_validateCommand(): 改进 Windows 命令验证逻辑,正确处理.cmd/.bat文件Commit 3: 图标兼容性修复
lucide_icons_flutter3.1.x 中不存在textSelect图标,替换为lassoSelect。修改文件
dependencies/mcp_client/lib/src/transport/transport.dartlib/core/providers/mcp_provider.dartlib/icons/lucide_adapter.dart测试环境
测试计划
npx -y @e2b/mcp-serverMCP stdio 服务器,验证不再崩溃验证步骤
npx-y @e2b/mcp-serverE2B_API_KEY=<your_key>