"不要急于求成。"
一个智慧的上下文守护者,用于AI代理的MCP(模型上下文协议)服务器,具有类似Gemini CLI的持久浏览器会话。
当AI模型的有限上下文窗口被加载来自每个连接的MCP服务器的所有工具定义和元数据时,挑战就出现了。这种大量加载无论工具是否与当前任务相关,都会消耗宝贵的上下文空间,这些空间本应保留给推理和任务完成。
mcp-cli-ent通过根本改变交互模型来充当一个谨慎的守护者。
与其强迫代理将所有服务器上的所有工具定义加载到其有限的上下文中,代理现在被赋予了一个单一且轻量级的工具:mcp-cli-ent CLI本身。
代理现在可以通过执行简单的CLI命令按需访问任何MCP服务器。定义和元数据存在于上下文窗口之外,仅在需要时调用。
这提供了多层上下文安全交互模型:
mcp-cli-ent暴露了简单、代理可用的命令(如list-servers,list-tools [server]),允许代理动态发现可用的服务器、它们的工具以及所需的参数。代理可以在需要时学习它可以做什么,而无需任何前期上下文成本。mcp-cli-ent call-tool ...)。这消除了上下文“森林砍伐”的主要原因,因为没有任何服务器定义被加载到代理的提示中。mcp-cli-ent拦截工具的冗长原始JSON输出,并返回干净解析的摘要,防止成功调用导致上下文被淹没。CLI-Ent的名字体现了这一理念:
mcp_servers.json格式${VAR_NAME}替换实现安全凭证管理MCP CLI-Ent引入了一个完整的持久守护进程架构,提供类似Gemini CLI的会话持久性,用于浏览器自动化:
mcp_servers.json配置# 手动守护进程控制(可选 - 需要时自动启动)
mcp-cli-ent daemon start # 启动后台守护进程
mcp-cli-ent daemon status # 显示守护进程状态和活动会话
mcp-cli-ent daemon logs # 查看守护进程日志
mcp-cli-ent daemon stop # 停止守护进程
工具执行 - 通过Context7获取文档:

CLI-Ent 提供了一个干净的命令行界面,用于与MCP服务器交互,同时保留了AI代理的上下文窗口。
Linux, macOS 和 Windows (WSL):
# 选项1:一行安装
curl -fsSL https://raw.githubusercontent.com/EstebanForge/mcp-cli-ent/main/scripts/install.sh | bash
# 选项2:下载并本地运行
curl -fsSL https://raw.githubusercontent.com/EstebanForge/mcp-cli-ent/main/scripts/install.sh -o install.sh
chmod +x install.sh
./install.sh
Windows (PowerShell):
# 选项1:一行安装
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/EstebanForge/mcp-cli-ent/main/scripts/install.ps1" -OutFile "install.ps1"
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process -Force
.\install.ps1
# 选项2:直接执行
iwr -useb https://raw.githubusercontent.com/EstebanForge/mcp-cli-ent/main/scripts/install.ps1 | iex
安装程序做了什么:
~/.local/bin/%USERPROFILE%\AppData\Roaming\mcp-cli-ent\git clone https://github.com/EstebanForge/mcp-cli-ent.git
cd mcp-cli
make build
需求:Go 1.21+
安装后,请验证它是否正常工作:
mcp-cli-ent --version
mcp-cli-ent create-config
mcp-cli-ent list-servers
MCP CLI将MCP服务器配置存储在mcp_servers.json中,位于标准平台特定位置:
Linux, macOS 和 WSL:
~/.config/mcp-cli-ent/mcp_servers.json
Windows:
%USERPROFILE%\AppData\Roaming\mcp-cli-ent/mcp_servers.json
注意:mcp_servers.json仅包含MCP服务器定义。未来将使用单独的config.json文件进行工具配置(尚未实现)。
创建配置文件最简单的方法是:
mcp-cli-ent create-config
这将在标准位置创建带有示例服务器配置的mcp_servers.json。
参考项目目录中的mcp_servers.example.json以了解配置格式。
配置文件格式兼容Claude Code和VSCode:
{
"mcpServers": {
"chrome-devtools": {
"command": "npx",
"args": ["-y", "chrome-devtools-mcp@latest", "--isolated"],
"persistent": true,
"timeout": 60
},
"playwright": {
"command": "npx",
"args": ["-y", "@playwright/mcp@latest"],
"persistent": true,
"timeout": 60
},
"context7": {
"type": "http",
"url": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "${CONTEXT7_API_KEY}"
},
"persistent": false,
"timeout": 30
},
"sequential-thinking": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-sequential-thinking"],
"persistent": false,
"timeout": 30
},
"deepwiki": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://mcp.deepwiki.com/sse"],
"persistent": false,
"timeout": 30
}
}
}
"type": "http" 或提供 "url""command" 和可选的 "args""headers" 对象用于HTTP认证"env" 对象用于stdio服务器${VAR_NAME}"disabled": true 临时禁用服务器"timeout" 秒数(默认:30)"persistent": true 用于浏览器自动化服务器(Chrome DevTools、Playwright)--isolated 标志以防止Chrome DevTools配置文件冲突mcp-cli-ent create-config
# 列出所有已配置的服务器
mcp-cli-ent list-servers
# 列出所有启用服务器的工具
mcp-cli-ent list-tools
# 列出特定服务器的工具
mcp-cli-ent list-tools context7
# 调用工具并传递参数
mcp-cli-ent call-tool context7 resolve-library-id '{"libraryName": "react"}'
# 列出服务器资源
mcp-cli-ent list-resources deepwiki
# 导航到网站(如果需要,守护进程自动启动)
mcp-cli-ent call-tool chrome-devtools navigate_page '{"url": "https://wicket.io"}'
# 访问浏览器控制台消息
mcp-cli-ent call-tool chrome-devtools list_console_messages
mcp-cli-ent call-tool chrome-devtools get_console_message '{"msgid": 3}'
# 捕获快照和截图
mcp-cli-ent call-tool chrome-devtools take_snapshot
mcp-cli-ent call-tool chrome-devtools take_screenshot
# 点击元素并与页面互动
mcp-cli-ent call-tool chrome-devtools click '{"uid": "1_31"}'
# 导航和互动(命令间持久会话)
mcp-cli-ent call-tool playwright browser_navigate '{"url": "https://antronio.cl"}'
# 捕获可访问性快照以分析
mcp-cli-ent call-tool playwright browser_snapshot
# 点击元素并导航页面
mcp-cli-ent call-tool playwright browser_click '{
"element": "Era que no - CASO SQM: Tras 11 años de litigios...",
"ref": "e59"
}'
# 捕获全屏截图
mcp-cli-ent call-tool playwright browser_take_screenshot
# 检查守护进程状态 - 显示所有活跃的持久会话
mcp-cli-ent daemon status
# 输出示例:
# MCP守护进程正在运行(PID:12345)
# 平台:darwin
# 终端:127.0.0.1:8080
# 活跃会话:
# • chrome-devtools(活跃)[运行时间:5分12秒]
# • playwright(活跃)[运行时间:3分45秒]
# 通过Context7获取HyperPress块构建文档
mcp-cli-ent --timeout 60 call-tool context7 get-library-docs '{
"context7CompatibleLibraryID": "/estebanforge/hyperpress",
"query": "如何构建一个块"
}'
# 使用顺序思维解决复杂问题
mcp-cli-ent call-tool sequential-thinking sequentialthinking '{
"thought": "我需要逐步解决这个复杂的问题...",
"nextThoughtNeeded": true,
"thoughtNumber": 1,
"totalThoughts": 5
}'
对于自定义配置或测试,指定不同的文件:
mcp-cli-ent --config /path/to/custom.json list-servers
MCP CLI自动按以下顺序发现配置文件:
--config 标志指定mcp_servers.json(为了向后兼容)这意味着现有用户在当前目录中有配置文件的情况下将继续正常工作,无需更改。
mcp-cli-ent --verbose list-tools
list-servers - 列出所有已配置的MCP服务器list-tools [server] - 列出服务器的工具call-tool <server> <tool> [args] - 调用特定工具list-resources <server> - 列出服务器资源create-config [filename] - 创建示例配置version - 显示版本信息daemon start - 启动后台守护进程服务daemon stop - 停止运行的守护进程daemon status - 显示守护进程状态和活跃会话daemon logs - 查看守护进程服务日志--config <path> - 使用自定义配置文件--timeout <seconds> - 设置请求超时--verbose, -v - 启用详细输出--help, -h - 显示帮助信息# 解析库
mcp-cli-ent call-tool context7 resolve-library-id '{"libraryName": "react"}'
# 获取库文档
mcp-cli-ent call-tool context7 get-library-docs '{
"context7CompatibleLibraryID": "/reactjs/react.dev",
"tokens": 2000
}'
# 列出GitHub仓库结构
mcp-cli-ent call-tool deepwiki read_wiki_structure '{
"repoName": "facebook/react"
}'
# 获取仓库内容
mcp-cli-ent call-tool deepwiki read_wiki_contents '{
"repoName": "facebook/react"
}'
# 开始思考过程
mcp-cli-ent call-tool sequential-thinking sequentialthinking '{
"thought": "我需要系统地分析这个复杂的系统设计问题...",
"nextThoughtNeeded": true,
"thoughtNumber": 1,
"totalThoughts": 8
}'
# 通过Context7获取库文档
mcp-cli-ent call-tool context7 get-library-docs '{
"context7CompatibleLibraryID": "/reactjs/react.dev",
"query": "开始使用钩子"
}'
# 使用顺序思维解决问题
mcp-cli-ent call-tool sequential-thinking sequentialthinking '{
"thought": "我需要系统地分析这个复杂的API设计决策...",
"nextThoughtNeeded": true,
"thoughtNumber": 1,
"totalThoughts": 5
}'
# 通过DeepWiki获取仓库文档
mcp-cli-ent call-tool deepwiki read_wiki_structure '{
"repoName": "facebook/react"
}'
# 为当前平台构建
make build
# 为所有平台构建
make build-all
# 开发设置
make dev-setup
# 运行测试
make test
# 运行带覆盖率的测试
make test-coverage
# 格式化代码
make fmt
# 检查代码
make lint
该工具包括全面的错误处理,涵盖:
git checkout -b feature/amazing-feature)git commit -m '添加精彩功能')git push origin feature/amazing-feature)该项目采用MIT许可证 - 详情参见LICENSE文件。