# cli-mcp-server

> MCP Server

This repository provides a secure Model Context Protocol (MCP) server for controlled command-line execution, featuring command whitelisting, path validation, and protection against shell operator injection, ensuring secure LLM application integration.

## Overview

- **Category:** Developer Tools
- **Language:** Python
- **Stars:** 177
- **Forks:** 11
- **Owner:** MladenSU
- **GitHub:** https://github.com/MladenSU/cli-mcp-server
- **Created:** 2024-12-08T23:01:54+00:00
- **Updated:** 2025-03-28T19:10:21+00:00
- **Source:** https://model-context-protocol.com/servers/cli-mcp-server-secure-command-execution

## Setup

## Setup
To install CLI MCP Server for Claude Desktop automatically via [Smithery](https://smithery.ai/protocol/cli-mcp-server):

```bash
npx @smithery/cli install cli-mcp-server --client claude
```

Add to your `~/Library/Application\ Support/Claude/claude_desktop_config.json`:

> Development/Unpublished Servers Configuration

```json
{
  "mcpServers": {
    "cli-mcp-server": {
      "command": "uv",
      "args": [
        "--directory",
        "<path/to/the/repo>/cli-mcp-server",
        "run",
        "cli-mcp-server"
      ],
      "env": {
        "ALLOWED_DIR": "</your/desired/dir>",
        "ALLOWED_COMMANDS": "ls,cat,pwd,echo",
        "ALLOWED_FLAGS": "-l,-a,--help,--version",
        "MAX_COMMAND_LENGTH": "1024",
        "COMMAND_TIMEOUT": "30"
      }
    }
  }
}
```

> Published Servers Configuration

```json
{
  "mcpServers": {
    "cli-mcp-server": {
      "command": "uvx",
      "args": [
        "cli-mcp-server"
      ],
      "env": {
        "ALLOWED_DIR": "</your/desired/dir>",
        "ALLOWED_COMMANDS": "ls,cat,pwd,echo",
        "ALLOWED_FLAGS": "-l,-a,--help,--version",
        "MAX_COMMAND_LENGTH": "1024",
        "COMMAND_TIMEOUT": "30"
      }
    }
```
> In case it's not working or showing in the UI, clear your cache via `uv clean`.


## Tools

## Available Tools

1.  run_command (Executes whitelisted CLI commands within allowed directories.)
2.  show_security_rules (Displays current security configuration and restrictions.)
