Command-line Interface for MCP Clients

0.2.5 · active · verified Wed Apr 15

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

Install

Imports

Quickstart

This quickstart illustrates how an MCP client (like 'Augment Code') would be configured to connect to the `cli-mcp-server`. The Python code demonstrates setting crucial environment variables programmatically, which are then picked up by the `cli-mcp-server` process when launched. The server is typically run using `uvx cli-mcp-server` or a similar command, and clients communicate with it over the Model Context Protocol. Remember to replace placeholder paths and commands with your actual requirements and ensure `uv` is installed to run the server as per common examples.

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.')

view raw JSON →