mcp-cli-exec MCP 服务器
一个强大的 CLI 命令执行 MCP 服务器,支持运行带有结构化输出的 Shell 命令。该软件包专注于命令执行功能,与其他 MCP CLI 工具有所区别。
特征
工具
cli-exec-raw
执行原始 CLI 命令并返回结构化输出
- 接受命令字符串和可选超时(默认值:5 分钟)
- 返回详细的执行结果,包括 stdout、stderr、退出代码
- 使用结构化的错误响应优雅地处理错误
命令行执行
在特定工作目录中执行一个或多个 CLI 命令
- 支持单个命令、&& 链式命令或命令数组
- 所有命令都在指定的工作目录中执行
- 返回每个命令的详细结果:
- 成功/失败状态
- 退出代码
- stdout 和 stderr(去除 ANSI 代码)
- 执行时长
- 工作目录
- 第一次命令失败时停止
- 每个命令的可选超时(默认值:5 分钟)
注意:由于执行上下文的限制,每个命令都会独立运行。命令中的目录更改 (cd) 不会影响后续命令。所有命令均在最初指定的工作目录中执行。
输出格式
命令返回结构化结果,包括:
- 成功/失败状态
- 退出代码
- stdout 和 stderr(去除了 ANSI 代码)
- 执行时长
- 工作目录
- 详细的错误信息(如果适用)
示例用法
cli-exec-raw
简单命令执行:
超时:
命令行执行
特定目录中的单个命令:
多个命令(均在同一个工作目录中运行):
安装
可选择从 npm 安装:
或者在你的配置中使用 npx
对于 Cline VSCode 扩展
添加到%APPDATA%/Code - Insiders/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json
:
对于克劳德桌面
添加到适当的配置文件:
Windows: %APPDATA%/Claude/claude_desktop_config.json
MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
特殊 Windows 配置
如果您在 Windows 上遇到 ENOENT spawn npx 问题,请使用指定完整路径的替代配置:
发展
安装依赖项:
构建服务器:
对于使用自动重建的开发:
调试
由于 MCP 服务器通过 stdio 进行通信,调试起来可能颇具挑战性。MCP Inspector 提供了一些实用的调试工具:
这将提供一个 URL 来访问浏览器中的检查器,您可以在其中:
- 查看所有 MCP 消息
- 检查请求/响应有效载荷
- 以交互方式测试工具
- 监视服务器状态
错误处理
该服务器包括全面的错误处理:
- 所有工具参数的输入验证
- 结构化错误响应
- 命令超时处理
- 工作目录验证
- 剥离 ANSI 代码以获得干净的输出
技术细节
- 使用 TypeScript 和 MCP SDK 构建
- 使用 execa 实现可靠的命令执行
- 默认命令超时:5分钟
- 支持 Windows 和类 Unix 系统(使用适合您操作系统的命令,例如“dir”与“ls”)
- 按顺序执行命令,第一次失败时停止
- 每个命令在指定的工作目录中独立运行
You must be authenticated.
local-only server
The server can only run on the client's local machine because it depends on local resources.
Tools
一个 CLI 命令执行服务器,可以运行具有结构化输出的 shell 命令,提供详细的执行结果,包括 stdout、stderr、退出代码和执行持续时间。
Related Resources
Related MCP Servers
- AsecurityAlicenseAqualityA secure shell command execution server implementing the Model Context Protocol (MCP). This server allows remote execution of whitelisted shell commands with support for stdin input.Last updated -174PythonMIT License
- -securityAlicense-qualityShell and file edit capabilities tightly coupled to provide a powerful coding experience. You can work with different modes: architect and code-writer for separate plan and implementation phase. You can get it to invoke any cli command, e.g., compiling, type checking, linting, github cli, pythonLast updated -494PythonApache 2.0
- -securityAlicense-qualityA secure server that enables AI applications to execute shell commands in specified directories, supporting multiple shell types (bash, sh, cmd, powershell) with built-in security features like directory isolation and timeout control.Last updated -9PythonApache 2.0
- AsecurityFlicenseAqualityA CLI tool that runs a Model Context Protocol server over stdio, enabling interaction with specification documents like business requirements, product requirements, and user stories for the Specif-ai platform.Last updated -90TypeScript
Appeared in Searches
- How to run a Python file using Claude Desktop
- How to view console logs
- Information about Penetration Testing
- Marking Linux terminal commands as safe or unsafe for local execution
- How to clone a Git repository, create a Gradle 8 project with Java 21 and Spring Boot REST API, compile it, and upload to Git