mcp cli exec
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.
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.
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.
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
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.
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
Simple command execution:
{
"command": "echo Hello World"
}
With timeout:
{
"command": "long-running-script.sh",
"timeout": 300000
}
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"
]
}
Optionally install from npm:
npm install -g mcp-cli-exec
# or with pnpm
pnpm add -g mcp-cli-exec
Or just use npx in your configuration
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"]
}
}
}
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"]
}
}
}
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:UsersjimAppDataRoamingnvmv22.1.0node.exe",
"args": [
"C:UsersjimAppDataRoamingnpmnode_modulesnpmbinnpx-cli.js",
"-y",
"mcp-cli-exec"
]
}
}
}
Install dependencies:
pnpm install
Build the server:
pnpm run build
For development with auto-rebuild:
pnpm run watch
Since MCP servers communicate over stdio, debugging can be challenging. The MCP Inspector provides helpful debugging tools:
pnpm run inspector
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
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
[
{
"description": "Execute a raw CLI command and return structured output",
"inputSchema": {
"properties": {
"command": {
"description": "The CLI command to execute",
"type": "string"
},
"timeout": {
"description": "Optional timeout in milliseconds (default: 5 minutes)",
"minimum": 0,
"type": "number"
}
},
"required": [
"command"
],
"type": "object"
},
"name": "cli-exec-raw"
},
{
"description": "Execute one or more CLI commands in a specific working directory",
"inputSchema": {
"properties": {
"commands": {
"description": "Commands to execute",
"oneOf": [
{
"description": "Single command or && separated commands",
"type": "string"
},
{
"description": "Array of commands to execute sequentially",
"items": {
"type": "string"
},
"type": "array"
}
]
},
"timeout": {
"description": "Optional timeout in milliseconds per command (default: 5 minutes)",
"minimum": 0,
"type": "number"
},
"workingDirectory": {
"description": "Working directory to execute commands in",
"type": "string"
}
},
"required": [
"workingDirectory",
"commands"
],
"type": "object"
},
"name": "cli-exec"
}
]