cmd-line-mcp
Documentation
Command-Line MCP Server
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 configClaude 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
Frequently asked questions
What is cmd-line-mcp?
cmd-line-mcp is a Model Context Protocol (MCP) server listed in the TrackMCP directory.
How do I install cmd-line-mcp?
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 cmd-line-mcp open source?
Yes — it is hosted on GitHub at https://github.com/andresthor/cmd-line-mcp and has 6 stars.
Related MCP tools
5. Update .env file in the root directory with your mem0 API key: for the Model Context Protocol. Enhance AI assistants with powerful integrations.
Model Context Protocol integration for Python. Enhance AI assistants with powerful Python-based capabilities and integration support.
This repository contains Model Context Protocol (MCP) servers that enable MCP clients (like Claude Desktop or the cline.
🙌 OpenHands: Code Less, Make More for the Model Context Protocol. Enhance AI assistants with powerful integrations. Python-based implementation.
Universal memory layer for AI Agents; Announcing OpenMemory MCP - local and secure memory management. Python-based implementation.
基于大模型搭建的聊天机器人,同时支持 微信公众号、企业微信应用、飞书、钉钉 等接入,可选择ChatGPT/Claude/DeepSeek/文心一言/讯飞星火/通义千问/ Gemini/GLM-4/Kimi/LinkAI,能处理文本、语音和图片,访问操作系统和互联网,支持基于自有知识库进行定制企业智能客服。
Run your own MCP server? See who uses it and what to fix.
Measure it with TrackMCP