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.
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:
With timeout:
cli-exec
Single command in specific directory:
Multiple commands (all run in the same working directory):
Installation
Optionally install from npm:
Or 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
:
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
Special Windows Configuration
If you encounter the ENOENT spawn npx issue on Windows, use this alternative configuration that specifies the full paths:
Development
Install dependencies:
Build the server:
For development with auto-rebuild:
Debugging
Since MCP servers communicate over stdio, debugging can be challenging. The MCP Inspector provides helpful debugging tools:
This 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
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
A CLI command execution server that enables running shell commands with structured output, providing detailed execution results including stdout, stderr, exit code, and execution duration.
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 -483PythonApache 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 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
- Transferring a Dockerized Website from Local to Remote Server Using Cursor AI