Skip to main content
Glama

mcp-cli-exec MCP Server

by jakenuts

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

简单命令执行:

{ "command": "echo Hello World" }

超时:

{ "command": "long-running-script.sh", "timeout": 300000 }
命令行执行

特定目录中的单个命令:

{ "workingDirectory": "/path/to/project", "commands": "npm install" }

多个命令(均在同一个工作目录中运行):

{ "workingDirectory": "C:\\project", "commands": [ "dir /b", "npm run build" ] }

安装

可选择从 npm 安装:

npm install -g mcp-cli-exec # or with pnpm pnpm add -g mcp-cli-exec

或者在你的配置中使用 npx

对于 Cline VSCode 扩展

添加到%APPDATA%/Code - Insiders/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json

{ "mcpServers": { "mcp-cli-exec": { "command": "npx", "args": ["-y", "mcp-cli-exec"] } } }

对于克劳德桌面

添加到适当的配置文件:

Windows: %APPDATA%/Claude/claude_desktop_config.json MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json

{ "mcpServers": { "mcp-cli-exec": { "command": "npx", "args": ["-y", "mcp-cli-exec"] } } }

特殊 Windows 配置

如果您在 Windows 上遇到 ENOENT spawn npx 问题,请使用指定完整路径的替代配置:

{ "mcpServers": { "mcp-cli-exec": { "command": "C:\\Users\\jim\\AppData\\Roaming\\nvm\\v22.1.0\\node.exe", "args": [ "C:\\Users\\jim\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npx-cli.js", "-y", "mcp-cli-exec" ] } } }

发展

安装依赖项:

pnpm install

构建服务器:

pnpm run build

对于使用自动重建的开发:

pnpm run watch

调试

由于 MCP 服务器通过 stdio 进行通信,调试起来可能颇具挑战性。MCP Inspector 提供了一些实用的调试工具:

pnpm run inspector

这将提供一个 URL 来访问浏览器中的检查器,您可以在其中:

  • 查看所有 MCP 消息
  • 检查请求/响应有效载荷
  • 以交互方式测试工具
  • 监视服务器状态

错误处理

该服务器包括全面的错误处理:

  • 所有工具参数的输入验证
  • 结构化错误响应
  • 命令超时处理
  • 工作目录验证
  • 剥离 ANSI 代码以获得干净的输出

技术细节

  • 使用 TypeScript 和 MCP SDK 构建
  • 使用 execa 实现可靠的命令执行
  • 默认命令超时:5分钟
  • 支持 Windows 和类 Unix 系统(使用适合您操作系统的命令,例如“dir”与“ls”)
  • 按顺序执行命令,第一次失败时停止
  • 每个命令在指定的工作目录中独立运行
Install Server
A
security – no known vulnerabilities
F
license - not found
A
quality - confirmed to work

local-only server

The server can only run on the client's local machine because it depends on local resources.

一个 CLI 命令执行服务器,可以运行具有结构化输出的 shell 命令,提供详细的执行结果,包括 stdout、stderr、退出代码和执行持续时间。

  1. 特征
    1. 工具
    2. 输出格式
    3. 示例用法
  2. 安装
    1. 对于 Cline VSCode 扩展
    2. 对于克劳德桌面
    3. 特殊 Windows 配置
  3. 发展
    1. 调试
  4. 错误处理
    1. 技术细节

      Related MCP Servers

      • -
        security
        A
        license
        -
        quality
        A 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 -
        10
        Python
        Apache 2.0
        • Linux
        • Apple
      • -
        security
        F
        license
        -
        quality
        A cross-platform shell command execution server that supports Windows, macOS, and Linux environments with PowerShell, CMD, GitBash, and Bash shells, optimized for Japanese language environments.
        Last updated -
        1
        JavaScript
        • Apple
        • Linux
      • A
        security
        A
        license
        A
        quality
        A command-line interface server that provides unrestricted system access to Windows environments with SYSTEM-level privileges, allowing complete control over files, processes, and configuration settings.
        Last updated -
        4
        928
        TypeScript
        MIT License
      • -
        security
        A
        license
        -
        quality
        A lightweight FastAPI server that allows remote execution of shell commands on Windows, with real-time output streaming and security features like API key authentication and rate limiting.
        Last updated -
        1
        Python
        MIT License

      View all related MCP servers

      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/jakenuts/mcp-cli-exec'

      If you have feedback or need assistance with the MCP directory API, please join our Discord server