CLI MCP Server
About
A secure MCP server for executing controlled command-line operations with comprehensive security features.
Details
- Author
- mladensu
- GitHub stars
- 173
- Downloads
- 279
- Categories
- Developer Tools, Infrastructure, Other, Security
- Tags
- #ssh
Jump to
- Secure command execution with strict validation
- Configurable command and flag whitelisting with 'all' option
- Path traversal prevention and validation
- Shell operator injection protection (opt‑in)
- Execution timeouts and command length limits
- Async operation support
- Working directory restriction and validation
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:
- Download and install Highlight from highlightai.com/download
- Navigate to the plugins tab and select "Add Custom Plugin"
-
Configure the plugin with the settings below
Plugin Name
CLI MCP ServerCommand (node, npx, python, etc.)Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.
- Enable "Start Automatically" if you want the plugin to start when Highlight launches
From the repository
Install via Smithery (npx @smithery/cli install cli-mcp-server --client claude) or manually with uv/uvx. Configure required environment variable ALLOWED_DIR; optional variables set allowed commands/flags, timeouts, and shell operator behaviour. Add the server to Claude Desktop’s claude_desktop_config.json. The server exposes two tools: run_command and show_security_rules.
Claude Desktop / Cursor
Paste into your MCP client config file to install this server.
{
"mcpServers": {
"cli mcp server": {
"cli-mcp-server": {
"command": "npx",
"args": [
"@smithery/cli",
"install",
"cli-mcp-server",
"--client",
"claude"
]
}
}
}
}
McpServers
{
"cli-mcp-server": {
"command": "npx",
"args": [
"@smithery/cli",
"install",
"cli-mcp-server",
"--client",
"claude"
]
}
}
A secure Model Context Protocol (MCP) server implementation for executing controlled command-line operations with comprehensive security features.
- Overview
- Features
- Configuration
- Available Tools
- run_command
- show_security_rules
- Development/Unpublished Servers Configuration
- Published Servers Configuration
- Prerequisites
- Building and Publishing
- Debugging
This MCP server enables secure command-line execution with robust security measures including command whitelisting, path validation, and execution controls. Perfect for providing controlled CLI access to LLM applications while maintaining security.
- 🔒 Secure command execution with strict validation
- ⚙️ Configurable command and flag whitelisting with 'all' option
- 🛡️ Path traversal prevention and validation
- 🚫 Shell operator injection protection
- ⏱️ Execution timeouts and length limits
- 📝 Detailed error reporting
- 🔄 Async operation support
- 🎯 Working directory restriction and validation
Configure the server using environment variables:
Note: SettingALLOWED_COMMANDSorALLOWED_FLAGSto 'all' will allow any command or flag respectively.
To install CLI MCP Server for Claude Desktop automatically viaSmithery:
npx @smithery/cli install cli-mcp-server --client claude
Executes whitelisted CLI commands within allowed directories.
{ "command": { "type": "string", "description": "Single command to execute (e.g., 'ls -l' or 'cat file.txt')" } }
- Shell operators (&&, |, >, >>) are not supported by default, but can be enabled withALLOW_SHELL_OPERATORS=true
- Commands must be whitelisted unless ALLOWED_COMMANDS='all'
- Flags must be whitelisted unless ALLOWED_FLAGS='all'
- All paths are validated to be within ALLOWED_DIR
Displays current security configuration and restrictions, including:
- Working directory
- Allowed commands
- Allowed flags
- Security limits (max command length and timeout)
Add to your~/Library/Application\ Support/Claude/claude_desktop_config.json:
Development/Unpublished Servers Configuration
{ "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", "ALLOW_SHELL_OPERATORS": "false" } } } }
{ "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", "ALLOW_SHELL_OPERATORS": "false" } } } }
In case it's not working or showing in the UI, clear your cache viauv clean.
- ✅ Command whitelist enforcement with 'all' option
- ✅ Flag validation with 'all' option
- ✅ Path traversal prevention and normalization
- ✅ Shell operator blocking (with opt-in support viaALLOW_SHELL_OPERATORS=true)
- ✅ Command length limits
- ✅ Execution timeouts
- ✅ Working directory restrictions
- ✅ Symlink resolution and validation
The server provides detailed error messages for:
- Security violations (CommandSecurityError)
- Command timeouts (CommandTimeoutError)
- Invalid command formats
- Path security violations
- Execution failures (CommandExecutionError)
- General command errors (CommandError)
To prepare the package for distribution:
This will create source and wheel distributions in thedist/directory.
uv publish --token {{YOUR_PYPI_API_TOKEN}}
Since MCP servers run over stdio, debugging can be challenging. For the best debugging experience, we strongly recommend using theMCP Inspector.
You can launch the MCP Inspector vianpmwith this command:
npx @modelcontextprotocol/inspector uv --directory {{your source code local directory}}/cli-mcp-server run cli-mcp-server
Upon launching, the Inspector will display a URL that you can access in your browser to begin debugging.
This project is licensed under the MIT License - see theLICENSEfile for details.
For more information or support, please open an issue on the project repository.
This is a web browser that enables your coding agent, such as Claude Code, to visit websites on your behalf and assist you in identifying bugs or creating UI test cases.
Execute pre-approved shell commands securely on a server.
A secure MCP server for executing terminal commands with controlled directory access and command permissions.
A secure bridge for LLMs to safely execute command-line tools via the Model Context Protocol (MCP).
Securely execute shell commands with whitelisting, resource limits, and timeout controls for LLMs.
Executes secure shell commands with configurable directory, shell, and timeout validation.
Boost security in your dev lifecycle via SAST, SCA, Secrets & IaC scanning with Cycode.
Enable AI agents to secure code with Semgrep.
An engineering governance and safety control plane for AI coding agents to enforce strict SDLC discipline, quality gates, and security branch protections.
AI-powered security scanning. Scans code, files, and git diffs for vulnerabilities in real-time using the Armis scanning API.
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.





