Command Line

by andresthor

Not rated
GitHub

About

A secure MCP server for executing terminal commands with controlled directory access and command permissions.

Details

Author
andresthor
Repository
andresthor/cmd-line-mcp
License
MIT License
Categories
Developer Tools, Infrastructure, Other, Security, AI, Design, File Management, Search

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Command Line
    Command (node, npx, python, etc.) /path/to/venv/bin/cmd-line-mcp
    Arguments
    • Argument 1 --config
    • Argument 2 /path/to/config.json
    Environment
    • CMD_LINE_MCP_SECURITY_REQUIRE_SESSION_ID false
    • CMD_LINE_MCP_SECURITY_AUTO_APPROVE_DIRECTORIES_IN_DESKTOP_MODE true

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

The server works out of the box with sensible defaults. Customize via JSON config, environment variables, or .env files:


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

json
{
"mcpServers": {
"cmd-line": {
"command": "/path/to/venv/bin/cmd-line-mcp",
"args": ["--config", "/path/to/config.json"],
"env": {
"CMD_LINE_MCP_SECURITY_REQUIRE_SESSION_ID": "false",
"CMD_LINE_MCP_SECURITY_AUTO_APPROVE_DIRECTORIES_IN_DESKTOP_MODE": "true"
}
}
}
}
``

Restart Claude Desktop after saving.

> [!TIP]
> Set
require_session_id: false` to prevent approval loops in Claude Desktop.

---

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "command line": {
            "env": {
                "CMD_LINE_MCP_SECURITY_REQUIRE_SESSION_ID": "false",
                "CMD_LINE_MCP_SECURITY_AUTO_APPROVE_DIRECTORIES_IN_DESKTOP_MODE": "true"
            },
            "args": [
                "--config",
                "/path/to/config.json"
            ],
            "command": "/path/to/venv/bin/cmd-line-mcp"
        }
    }
}

Linux

{
    "env": {
        "CMD_LINE_MCP_SECURITY_REQUIRE_SESSION_ID": "false",
        "CMD_LINE_MCP_SECURITY_AUTO_APPROVE_DIRECTORIES_IN_DESKTOP_MODE": "true"
    },
    "args": [
        "--config",
        "/path/to/config.json"
    ],
    "command": "/path/to/venv/bin/cmd-line-mcp"
}

Macos

{
    "env": {
        "CMD_LINE_MCP_SECURITY_REQUIRE_SESSION_ID": "false",
        "CMD_LINE_MCP_SECURITY_AUTO_APPROVE_DIRECTORIES_IN_DESKTOP_MODE": "true"
    },
    "args": [
        "--config",
        "/path/to/config.json"
    ],
    "command": "/path/to/venv/bin/cmd-line-mcp"
}

Windows

{
    "env": {
        "CMD_LINE_MCP_SECURITY_REQUIRE_SESSION_ID": "false",
        "CMD_LINE_MCP_SECURITY_AUTO_APPROVE_DIRECTORIES_IN_DESKTOP_MODE": "true"
    },
    "args": [
        "--config",
        "/path/to/config.json"
    ],
    "command": "/path/to/venv/bin/cmd-line-mcp"
}

Command-Line MCP Server

PyPI version
Python Versions
License: MIT

An MCP server that lets AI assistants run terminal commands safely. Commands are categorized (read/write/system), directories are whitelisted, and dangerous patterns are blocked automatically.

---

Quick Start

pip install cmd-line-mcp

Or from source

git clone https://github.com/andresthor/cmd-line-mcp.git cd cmd-line-mcp pip install -e .

Run the server:

cmd-line-mcp                        # default config
cmd-line-mcp --config config.json   # custom config

---

Claude Desktop Setup

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

{
  "mcpServers": {
    "cmd-line": {
      "command": "/path/to/venv/bin/cmd-line-mcp",
      "args": ["--config", "/path/to/config.json"],
      "env": {
        "CMD_LINE_MCP_SECURITY_REQUIRE_SESSION_ID": "false",
        "CMD_LINE_MCP_SECURITY_AUTO_APPROVE_DIRECTORIES_IN_DESKTOP_MODE": "true"
      }
    }
  }
}

Restart Claude Desktop after saving.

> [!TIP]
> Set require_session_id: false to prevent approval loops in Claude Desktop.

---

How It Works

Commands go through a validation pipeline before execution:

1. Pattern matching — blocks dangerous constructs (system(), shell escapes, etc.)
2. Command classification — each command must be in the read, write, system, or blocked list
3. Directory check — target directory must be whitelisted or session-approved
4. Approval check — write/system commands require session approval

Pipes, semicolons, and & are supported — each segment is validated independently.

What's Allowed

| Category | Commands | Approval |
|:------------|:---------------------------------------------------------------|:--------------:|
| Read | ls, cat, grep, find, head, tail, sort, wc, … | Auto |
| Write | cp, mv, rm, mkdir, touch, chmod, awk, sed, … | Required |
| System | ps, ping, curl, ssh, xargs, … | Required |
| Blocked | sudo, bash, sh, python, eval, … | Always denied |

What's Blocked

Shells, scripting interpreters, and known command-execution vectors are blocked — including indirect execution through awk system(), sed /e, find -exec, tar --checkpoint-action, env, and xargs. See docs/SECURITY.md for the full list.

---

Configuration

The server works out of the box with sensible defaults. Customize via JSON config, environment variables, or .env files:

# Whitelist directories
export CMD_LINE_MCP_SECURITY_WHITELISTED_DIRECTORIES="/projects,/var/data"

Add commands (merges with defaults)

export CMD_LINE_MCP_COMMANDS_READ="jq,rg"

See docs/CONFIGURATION.md for full configuration reference, MCP tool documentation, and directory security details.

---

License

MIT

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.