mcp-cli-exec MCP Server
This server allows you to execute command-line interface (CLI) commands with structured output and specific configurations.
Execute commands: Run single or multiple CLI commands sequentially with structured results (stdout, stderr, exit code, execution duration)
Configuration options: Specify working directory and set optional timeouts per command
Cross-platform support: Works on both Windows and Unix-like systems
Clean output: Automatically strips ANSI escape codes from stdout and stderr
Error handling: Provides graceful error management with structured error responses
Command isolation: Each command runs independently in the initially specified working directory
Enables running shell commands with structured output, including support for single commands, chained commands, or arrays of commands in specified working directories. Returns detailed execution results with stdout, stderr, exit codes, and execution duration.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-cli-exec MCP Server list files in my current directory"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-cli-exec MCP Server
A powerful CLI command execution MCP server that enables running shell commands with structured output. This package focuses specifically on command execution functionality, differentiating it from other MCP CLI tools.
Features
Tools
cli-exec-raw
Execute a raw CLI command and return structured output
Takes a command string and optional timeout (default: 5 minutes)
Returns detailed execution results including stdout, stderr, exit code
Handles errors gracefully with structured error responses
cli-exec
Execute one or more CLI commands in a specific working directory
Supports single commands, && chained commands, or array of commands
All commands execute in the specified working directory
Returns detailed results for each command:
Success/failure status
Exit code
stdout and stderr (ANSI codes stripped)
Execution duration
Working directory
Stops on first command failure
Optional timeout per command (default: 5 minutes)
Note: Due to execution context limitations, each command runs independently. Directory changes (cd) within commands do not affect subsequent commands. All commands execute in the initially specified working directory.
Output Format
Commands return structured results including:
Success/failure status
Exit code
stdout and stderr (with ANSI codes stripped)
Execution duration
Working directory
Detailed error information if applicable
Example Usage
cli-exec-raw
Simple command execution:
{
"command": "echo Hello World"
}With timeout:
{
"command": "long-running-script.sh",
"timeout": 300000
}cli-exec
Single command in specific directory:
{
"workingDirectory": "/path/to/project",
"commands": "npm install"
}Multiple commands (all run in the same working directory):
{
"workingDirectory": "C:\\project",
"commands": [
"dir /b",
"npm run build"
]
}Related MCP server: MCP Server
Installation
Optionally install from npm:
npm install -g mcp-cli-exec
# or with pnpm
pnpm add -g mcp-cli-execOr just use npx in your configuration
For Cline VSCode Extension
Add to %APPDATA%/Code - Insiders/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json:
{
"mcpServers": {
"mcp-cli-exec": {
"command": "npx",
"args": ["-y", "mcp-cli-exec"]
}
}
}For Claude Desktop
Add to the appropriate config file:
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"]
}
}
}Special Windows Configuration
If you encounter the ENOENT spawn npx issue on Windows, use this alternative configuration that specifies the full paths:
{
"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"
]
}
}
}Development
Install dependencies:
pnpm installBuild the server:
pnpm run buildFor development with auto-rebuild:
pnpm run watchDebugging
Since MCP servers communicate over stdio, debugging can be challenging. The MCP Inspector provides helpful debugging tools:
pnpm run inspectorThis will provide a URL to access the inspector in your browser, where you can:
View all MCP messages
Inspect request/response payloads
Test tools interactively
Monitor server state
Error Handling
The server includes comprehensive error handling:
Input validation for all tool parameters
Structured error responses
Command timeout handling
Working directory validation
ANSI code stripping for clean output
Technical Details
Built with TypeScript and the MCP SDK
Uses execa for reliable command execution
Default command timeout: 5 minutes
Supports Windows and Unix-like systems (use appropriate commands for your OS, e.g., 'dir' vs 'ls')
Executes commands sequentially, stopping on first failure
Each command runs independently in the specified working directory
Available Tools
2 toolscli-execC
Execute one or more CLI commands in a specific working directory
Inputs: commands (required), workingDirectory (required), timeout.
cli-exec-rawC
Execute a raw CLI command and return structured output
Inputs: command (required), timeout.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 2 tools
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.
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.
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.
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
Related MCP Connectors
I run shell commands on your private cloud environment (bash, sh, zsh)
Use your own Windows, Mac or Linux computer from ChatGPT, Claude, Cursor or Gemini CLI: run commands, read, write and search files, run long processes. Your computer only makes an outgoing connection (no open ports or VPN). Read-only mode, allowed folders, blocked commands and an action log keep you in control. Free plan available.
Linux server administration over OAuth MCP: shell, Docker, systemd, files and monitoring.
Remote shell and detached long-running jobs on your own machines — no SSH, open ports or VPN.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that allows LLMs to execute shell commands and receive their output in a controlled manner.7MIT
- FlicenseNot gradedqualityDmaintenanceA 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.-
- FlicenseBqualityNot gradedmaintenanceEnables 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-
- FlicenseBqualityDmaintenanceAn 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-