Command-line Interface for MCP Clients
The cli-mcp-server library (version 0.2.5) provides a secure Model Context Protocol (MCP) server that enables controlled execution of command-line operations with extensive security features. It allows AI agents and clients to interact with the system via CLI commands, enforcing policies like command whitelisting, path validation, shell operator blocking, and execution timeouts. The library appears to be actively maintained, with ongoing development and contributions to the Model Context Protocol ecosystem.
Warnings
- breaking The underlying Model Context Protocol (MCP) Python SDK is migrating from v1 (using `FastMCP`) to v2 (using `MCPServer`). This change introduces breaking changes for server implementations. `cli-mcp-server` may require updates to remain compatible with future versions of the MCP SDK and clients.
- gotcha Security configuration is paramount. `cli-mcp-server` is designed for secure command execution, but misconfiguring environment variables like `ALLOWED_DIR`, `ALLOWED_COMMANDS`, `ALLOWED_FLAGS`, and `ALLOW_SHELL_OPERATORS` can lead to severe security vulnerabilities, allowing unintended or malicious command execution.
- gotcha Debugging MCP servers running over standard I/O (stdio) can be challenging due to the nature of process communication.
- gotcha Many quickstart and deployment examples for MCP servers (including `cli-mcp-server`) rely on `uv` or `uvx` for execution. Users might expect a standard `python -m` command.
Install
-
pip install cli-mcp-server
Imports
- cli-mcp-server
This library is primarily run as a server process and does not typically expose symbols for direct Python import into other applications. It is configured and interacted with by an MCP client.
Quickstart
import os
# These environment variables are critical for security and functionality.
# Adjust values to your specific needs.
os.environ['ALLOWED_DIR'] = '/tmp'
os.environ['ALLOWED_COMMANDS'] = 'ls,cat,pwd,echo'
os.environ['ALLOWED_FLAGS'] = '-l,-a,--help,--version'
os.environ['MAX_COMMAND_LENGTH'] = '1024'
os.environ['COMMAND_TIMEOUT'] = '30'
os.environ['ALLOW_SHELL_OPERATORS'] = 'false'
print('Configuring MCP client to connect to cli-mcp-server...')
print('Example MCP client configuration snippet (e.g., for Augment Code):')
print("""
{
"mcpServers": {
"cli-mcp-server": {
"command": "uvx",
"args": ["cli-mcp-server"],
"env": {
"ALLOWED_DIR": "/path/to/your/projects",
"ALLOWED_COMMANDS": "git,npm,python,ls,cat,grep,find,pytest",
"ALLOWED_FLAGS": "-l,-a,--help,--version,--oneline,run,test,status,log"
}
}
}
}
""")
print('Ensure `uv` is installed and in your PATH, and adjust `ALLOWED_DIR` and `ALLOWED_COMMANDS` for your environment.')
print('The actual cli-mcp-server application would be started via `uvx cli-mcp-server` or similar, listening for MCP client connections.')