Python CLI MCP Server for Local Apps
Interact with local Python CLI apps using an MCP server to run, monitor, and automate command-line workflows securely.
npx -y @ofek/pycli-mcpOverview
This project provides a lightweight Python MCP (Model Context Protocol) server that exposes local command-line applications to local apps and agents. It lets programs orchestrate, run, monitor and automate CLI workflows through an MCP-compliant interface, so tools or language models can interact with shell programs in a controlled, observable way.
The server is intended for local development and automation: you can run commands, stream output, capture exit codes, and enforce security policies (such as command allowlists, working directories and timeouts). This makes it easier to integrate existing CLI tools into higher-level automation, testing, or agent workflows without embedding shell logic directly into those systems.
Features
- Run arbitrary CLI commands and capture stdout/stderr and exit status
- Stream live output to clients so interactive or long-running jobs can be monitored
- Enforce security controls: command allowlists/deny-lists, working directory constraints, environment overrides, and timeouts
- Task management: start, list, inspect, and stop running commands
- Simple JSON-based request/response model compatible with MCP-style clients
- Lightweight Python implementation suitable for local or single-user setups
- CLI and Python client examples to help integrate with other tools
Installation / Configuration
Install directly from the GitHub repository or from a local copy:
# Install from GitHub
# Or clone and install editable for development
Start the MCP server (example command; your installed entrypoint may vary):
# Start server on the default port (e.g. 8080)
# Or specify a port and config file
Example configuration (YAML) — adjust paths, command allowlist, timeouts and environment as needed:
# mcp-config.yml
server:
host: 127.0.0.1
port: 9090
security:
allow_commands:
- ls
- git
- python
deny_commands:
allowed_workdirs:
- /home/user/projects
max_runtime_seconds: 300
environment:
PATH: /usr/local/bin:/usr/bin:/bin
Common CLI management commands (after installing the package):
| Command | Description |
|---|---|
| pycli-mcp serve [–port N] | Start the MCP server |
| pycli-mcp run – cmd args… | Run a command via the local CLI client |
| pycli-mcp list | Show running and recent tasks |
pycli-mcp stop | Stop a running task | (Replace these examples with the actual entrypoint names if different in your installation.) Available Resources
Example: run a command with the Python client (HTTP-style pseudocode): Adjust the endpoint path according to the server’s actual API (e.g., /run, /tasks, /stop). Use Cases
Security and Best Practices
Next Steps
Common Issues & SolutionsA Spark listing has been created for your repo and you're being prompted to claim it; you're unsure if it's legitimate or how to complete the claim process. ✓ Solution I ran into this too! I clicked the claim URL (https://spark.entire.vc/claim/vb-python-cli-mcp), signed in with GitHub, and authorized Spark to verify my push access. After authorizing, Spark detected my maintainer rights, awarded the "Maintainer Verified" badge, and let me edit the title, description, and tags. I copied the README badge markdown they provided and pasted it into my README. Note: for org repos an org owner must approve the OAuth app or confirm push rights. If you prefer no listing, revoke Spark's GitHub access in Settings → Applications and email their support. |