mcp-cli-exec
Documentation
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"
]
}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
Frequently asked questions
What is mcp-cli-exec?
mcp-cli-exec is a Model Context Protocol (MCP) server listed in the TrackMCP directory.
How do I install mcp-cli-exec?
Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.
Is mcp-cli-exec open source?
Yes — it is hosted on GitHub at https://github.com/jakenuts/mcp-cli-exec and has 8 stars.
Related MCP tools
The official TypeScript SDK for Model Context Protocol servers and clients Trusted by 10500+ developers. Trusted by 10500+ developers.
Visual testing tool for MCP servers TypeScript-based implementation. Trusted by 7300+ developers. Trusted by 7300+ developers.
It's like v0 but in your Cursor/WindSurf/Cline. 21st dev Magic MCP server for working with your frontend like Magic TypeScript-based implementation.
Model Context Protocol Server for Mobile Automation and Scraping (iOS, Android, Emulators, Simulators and Real Devices) TypeScript-based implementation.
Https://github.com/user-attachments/assets/364b6705-14d4-4e6d-bea7-fb9f12664fab for the Model Context Protocol. Enhance AI assistants with powerful integrations
MCP server that provides tools and resources for interacting with n8n API TypeScript-based implementation. Trusted by 1400+ developers.
Run your own MCP server? See who uses it and what to fix.
Measure it with TrackMCP