Skip to main content
Glama
jakenuts

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"
  ]
}

Related MCP server: MCP Server

安装

可选择从 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”)

  • 按顺序执行命令,第一次失败时停止

  • 每个命令在指定的工作目录中独立运行

Available Tools

2 tools
cli-execC

Execute one or more CLI commands in a specific working directory

ParametersJSON Schema
NameRequiredDescriptionDefault
commandsYesCommands to execute
timeoutNoOptional timeout in milliseconds per command (default: 5 minutes)
workingDirectoryYesWorking directory to execute commands in

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only states basic functionality. It doesn't disclose critical behavioral traits like execution safety (potential for destructive commands), authentication needs, error handling, output format, or rate limits. The mention of 'timeout' in the schema isn't reinforced in the description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose without unnecessary words. Every element ('Execute', 'CLI commands', 'specific working directory') earns its place, making it optimally concise.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a CLI execution tool with no annotations and no output schema, the description is insufficient. It lacks details on execution behavior (e.g., sequential vs. parallel), error propagation, security implications, or return values, leaving significant gaps for an agent to understand tool usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents all parameters. The description adds no additional parameter semantics beyond what's in the schema, maintaining the baseline score of 3 for adequate coverage through structured data alone.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Execute') and resource ('CLI commands') with additional context about working directory. It distinguishes from sibling 'cli-exec-raw' by specifying 'in a specific working directory', though the distinction isn't fully explicit about what makes the sibling different.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus the sibling 'cli-exec-raw'. It mentions the working directory context but doesn't explain alternative scenarios, prerequisites, or exclusions for tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

cli-exec-rawC

Execute a raw CLI command and return structured output

ParametersJSON Schema
NameRequiredDescriptionDefault
commandYesThe CLI command to execute
timeoutNoOptional timeout in milliseconds (default: 5 minutes)

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the tool executes commands and returns structured output, but fails to address critical behavioral aspects such as security implications, execution environment, error handling, or potential side effects. This is inadequate for a tool that executes arbitrary CLI commands.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise and front-loaded in a single sentence that captures the core functionality. Every word earns its place with no wasted text, making it easy for an agent to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of executing arbitrary CLI commands (which involves security, environment, and side-effect considerations), no annotations, and no output schema, the description is insufficiently complete. It doesn't explain what 'structured output' means, execution constraints, or safety warnings, leaving significant gaps for agent understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with clear parameter descriptions in the schema. The description adds no additional parameter semantics beyond what the schema provides, such as command syntax examples or timeout behavior details. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Execute a raw CLI command and return structured output'. It specifies the verb ('execute'), resource ('raw CLI command'), and outcome ('return structured output'). However, it doesn't explicitly differentiate from its sibling 'cli-exec', which likely has similar functionality, preventing a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus its sibling 'cli-exec' or other alternatives. It lacks context about appropriate use cases, prerequisites, or exclusions, leaving the agent with minimal direction beyond the basic purpose.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 2 tool updatesv1.0.0
    • First observedcli-exec
    • First observedcli-exec-raw

TDQS

C2.9/5.0

Scored across 2 tools

Disambiguation2/5

The two tools have significant overlap in purpose, both executing CLI commands. While cli-exec-raw specifies 'raw' and 'structured output', the distinction is subtle and could easily lead to confusion about which to use for basic command execution. The descriptions don't clearly delineate when to choose one over the other.

Naming Consistency4/5

Both tools follow a consistent cli-exec prefix pattern with hyphenated suffixes. The naming is predictable and readable, though the suffix conventions differ slightly (one has no suffix, the other uses '-raw'). This minor deviation keeps it from a perfect score.

Tool Count3/5

With only 2 tools, the server feels thin for a CLI execution domain. While it covers basic execution, more operations like command validation, history tracking, or batch processing might be expected. The count is borderline minimal but functional for core tasks.

Completeness2/5

For a CLI execution server, there are notable gaps. Missing tools for command chaining, environment variable management, output parsing beyond 'structured', or error handling make the surface incomplete. Agents will hit dead ends when needing advanced CLI interactions beyond simple execution.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    A Model Context Protocol server that allows LLMs to execute shell commands and receive their output in a controlled manner.
    7
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    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.
    48 npm
    MIT
  • F
    license
    B
    quality
    D
    maintenance
    Enables safe execution of system shell commands with real-time streaming output and rich metadata capture. Provides configurable command execution with timeout controls, environment management, and extensible plugin architecture for monitoring command lifecycles.
    4
    -
  • F
    license
    B
    quality
    D
    maintenance
    An MCP server that enables users to execute arbitrary shell commands on their local machine and receive the output. It provides a terminal tool for running system commands through MCP-compatible clients using the Python SDK.
    1
    -