Secure, robust CLI MCP server with customizable security features for controlled command execution
CLI MCP Server is a secure Model Context Protocol (MCP) implementation designed to facilitate controlled command-line operations within robust security frameworks. This server ensures that AI applications, such as Claude Desktop, can execute commands while maintaining stringent security controls. By integrating the power of MCP with enhanced security features, this server offers a robust solution for providing controlled CLI access to LLMs and other AI tools.
CLI MCP Server boasts a range of core features that make it an indispensable tool for developers working on AI applications:
Strict Command Whitelisting: Commands must be explicitly allowed, with the option to control the entire command set using all
.
Path Validation and Traversal Prevention: All commands are validated against a root directory, ensuring that no harmful paths can be accessed.
Shell Operator Injection Protection: The server guards against malicious shell commands by preventing operators such as && and | from being used.
Execution Timeouts and Length Limits: Commands are subject to time-limited execution to prevent long-running or infinite loops.
Detailed Error Reporting: Comprehensive error messages help identify issues quickly, improving the troubleshooting process.
Asynchronous Operation Support: Ensures smooth operation even when multiple commands are running concurrently.
Working Directory Restrictions: Processes can only access predefined directories, adding another layer of security.
By leveraging these features within an MCP framework, CLI MCP Server ensures that AI applications like Claude Desktop remain secure and operational in a controlled environment. Each feature contributes to the overall security posture, making this server ideal for use with sensitive LLMs or critical infrastructure components.
MCP (Model Context Protocol) is designed as an adapter layer between AI applications and their underlying resources, enabling seamless integration through standardized interfaces. The CLI MCP Server adheres to these principles by implementing the necessary protocol mechanisms to ensure proper interaction with various AI clients.
The server's architecture is built around the following key components:
graph TD
A[AI Application] -->|MCP Client| B[MCP Protocol]
B --> C[MCP Server]
C --> D[Data Source/Tool]
style A fill:#e1f5fe
style C fill:#f3e5f5
style D fill:#e8f5e8
This diagram illustrates the flow of communication between an AI application (A), the MCP client, the protocol layer (B), the MCP server (C), and finally to the actual data source or tool (D). Each step is carefully managed to ensure that only authorized commands are executed.
MCP Client | Resources | Tools | Prompts | Status |
---|---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ | Full Support |
Continue | ✅ | ✅ | ✅ | Full Support |
Cursor | ❌ | ✅ | ❌ | Tools Only |
This matrix provides a clear view of the compatibility levels across different MCP clients, highlighting full support for resources and tools while noting limitations with prompts.
To get started with CLI MCP Server, follow these steps:
Install via Smithery:
npx @smithery/cli install cli-mcp-server --client claude
Manual Setup: For custom servers or development work, you can build and run the server locally.
Configuration: Set environment variables to control security features according to your needs.
By following these straightforward steps, developers can quickly integrate the server into their existing infrastructure or testing environments.
In a typical workflow, an AI developer might use CLI MCP Server alongside Claude Desktop for data preprocessing tasks. For instance, the following command demonstrates how to securely run a script that merges multiple CSV files:
run_command "cat file1.csv file2.csv > merged_file.csv"
This operation is executed within the confines of predefined security rules, ensuring that no unauthorized commands can be run.
For organizations conducting security audits involving LLMs, CLI MCP Server provides a robust environment. By integrating with tools like AuditBot (from Continue), developers can perform detailed scans and evaluations without risking the system's integrity:
run_command "AuditBot check --tool /path/to/security_tool"
This command is executed securely within the server’s constraints, providing a safer context for sensitive operations.
Integrating CLI MCP Server into your AI application involves configuring both the MCP client and the server to ensure seamless communication. The following sample configuration demonstrates how to set up a server compatible with multiple MCP clients:
{
"mcpServers": {
"cli-mcp-server-123": {
"command": "uv",
"args": [
"--directory",
"/path/to/repository/cli-mcp-server",
"run",
"cli-mcp-server"
],
"env": {
"ALLOWED_DIR": "/desired/directory/path",
"ALLOWED_COMMANDS": "ls,cat,pwd,echo",
"ALLOWED_FLAGS": "-l,-a,--help,--version",
"MAX_COMMAND_LENGTH": "1024",
"COMMAND_TIMEOUT": "30"
}
}
}
}
This JSON snippet is a common configuration for setting up the server to work with clients like Claude Desktop and Continue. It ensures that all commands and flags are securely validated according to the defined rules.
Below is a detailed matrix outlining system performance and compatibility:
Feature | Performance Impact | MCP Compatibility | Supported Clients |
---|---|---|---|
Command Whitelisting | Low | ✅ | ❌ |
Path Validation | Moderate | ✅ | ❌ |
Shell Operator Blocking | High | ✅ | ✅ |
Execution Timeouts | Moderate to High | ✅ | ✅ |
This matrix illustrates that while shell operator blocking can impact performance by increasing overhead, it is critical for maintaining security across all supported clients.
Advanced configuration options and security practices are essential for ensuring the server operates within secure parameters. Developers should pay close attention to:
show_security_rules
allows administrators to verify current configurations.A1: Commands are strictly whitelisted by default. You can allow a complete set using the 'all' option, but this reduces the server's security posture.
A2: Use the MCP Inspector for detailed debugging sessions. Launch with npx @modelcontextprotocol/inspector uv --directory {local path}
to access a web interface.
A3: Commands exceeding their allocated time are automatically terminated, ensuring no process can run indefinitely and potentially crash the server.
A4: Yes, configure tools within your JSON setup to ensure they adhere to security protocols. Use run_command
for external tool integration where necessary.
This documentation positions CLI MCP Server as a powerful tool for developers working on secure and efficient AI applications. By leveraging its features within an MCP framework, it provides robust security while enhancing functionality.
RuinedFooocus is a local AI image generator and chatbot image server for seamless creative control
Learn to set up MCP Airflow Database server for efficient database interactions and querying airflow data
Simplify MySQL queries with Java-based MysqlMcpServer for easy standard input-output communication
Build stunning one-page websites track engagement create QR codes monetize content easily with Acalytica
Access NASA APIs for space data, images, asteroids, weather, and exoplanets via MCP integration
Explore CoRT MCP server for advanced self-arguing AI with multi-LLM inference and enhanced evaluation methods