mcp-cli-exec MCP Server

mcp-cli-exec MCP Server

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.

jakenuts

OS Automation
Developer Tools
Visit Server

Tools

cli-exec-raw

Execute a raw CLI command and return structured output

cli-exec

Execute one or more CLI commands in a specific working directory

README

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-exec

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:

{
  "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 install

Build the server:

pnpm run build

For development with auto-rebuild:

pnpm run watch

Debugging

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

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

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
MCP Package Docs Server

MCP Package Docs Server

Facilitates LLMs to efficiently access and fetch structured documentation for packages in Go, Python, and NPM, enhancing software development with multi-language support and performance optimization.

Featured
Local
TypeScript
Claude Code MCP

Claude Code MCP

An implementation of Claude Code as a Model Context Protocol server that enables using Claude's software engineering capabilities (code generation, editing, reviewing, and file operations) through the standardized MCP interface.

Featured
Local
JavaScript
@kazuph/mcp-taskmanager

@kazuph/mcp-taskmanager

Model Context Protocol server for Task Management. This allows Claude Desktop (or any MCP client) to manage and execute tasks in a queue-based system.

Featured
Local
JavaScript
Linear MCP Server

Linear MCP Server

Enables interaction with Linear's API for managing issues, teams, and projects programmatically through the Model Context Protocol.

Featured
JavaScript
mermaid-mcp-server

mermaid-mcp-server

A Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images.

Featured
JavaScript
Jira-Context-MCP

Jira-Context-MCP

MCP server to provide Jira Tickets information to AI coding agents like Cursor

Featured
TypeScript
Linear MCP Server

Linear MCP Server

A Model Context Protocol server that integrates with Linear's issue tracking system, allowing LLMs to create, update, search, and comment on Linear issues through natural language interactions.

Featured
JavaScript
Sequential Thinking MCP Server

Sequential Thinking MCP Server

This server facilitates structured problem-solving by breaking down complex issues into sequential steps, supporting revisions, and enabling multiple solution paths through full MCP integration.

Featured
Python