cli2mcp -- Turn any CLI into an MCP Server
An educational Python library that bridges the gap between traditional command-line tools and the Model Context Protocol (MCP).
cli2mcp scans a CLI tool's --help output, extracts its arguments and
subcommands, and generates a JSON descriptor file. It can then serve that
file as a fully functional MCP server -- letting AI assistants call the CLI
tool through a standard protocol.
Quick start
uv sync
1. Scan a CLI tool
uv run cli2mcp scan curl
This runs curl --help, parses the output, and writes curl.tools.json.
For tools with subcommands (like git):
uv run cli2mcp scan git -o git.tools.json
Each subcommand becomes its own MCP tool.
2. Serve as an MCP server
uv run cli2mcp serve curl.tools.json
This starts an MCP server (stdio transport) that exposes every entry in the JSON file as a callable tool.
To use HTTP transport instead:
uv run cli2mcp serve curl.tools.json -t streamable-http
3. Connect to an AI assistant
Add the server to your assistant's MCP configuration.
{
"mcpServers": {
"curl": {
"command": "cli2mcp",
"args": ["serve", "curl.tools.json"]
}
}
}
How it works
MCP client
|
cli2mcp scan curl --> curl.tools.json |
| |
cli2mcp serve <---+
|
subprocess.run(["curl", ...])
The JSON schema
The generated file looks like this:
{
"command": "curl",
"tools": [
{
"name": "curl",
"description": "transfer a URL",
"args": [
{
"name": "url",
"description": "URL to transfer",
"type": "string",
"required": true
},
{
"name": "--output",
"description": "Write output to file instead of stdout",
"type": "string",
"required": false
}
]
}
]
}
command-- the base CLI binary to run.tools-- one entry per tool (or per subcommand).args-- each argument has aname,description,type(always"string"), andrequiredflag.- Argument names starting with
--are flags; others are positional. - You can hand-edit this file to add, remove, or rename tools.
How arguments map back to CLI commands
When the MCP server receives a tool call like:
{"name": "git_commit", "arguments": {"message": "fix bug", "all": "true"}}
It reconstructs the CLI command:
git commit --message "fix bug" --all true
Flags (names starting with --) are emitted as --flag value.
Positional arguments are appended at the end.
Supported help styles
Different CLI frameworks produce different --help formats.
cli2mcp auto-detects the style and uses the right parser:
| Style | Frameworks | Flag format |
|---|---|---|
| GNU | argparse, click, GNU | --flag description (one line) |
| Cobra | kubectl, oc, docker, gh | --flag=default: + next line |
| Plain | curl, busybox | flags listed without section headers |
Requirements
- Python 3.10+
- uv (recommended) or pip
mcp[cli](the official MCP Python SDK, installed automatically)
Metadata
Release files for cli2mcp 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| cli2mcp-0.1.1.tar.gz | 87.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cli2mcp-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 113.2 kB
Release files / cli2mcp-0.1.1.tar.gz
| Download URL | cli2mcp-0.1.1.tar.gz |
|---|---|
| Size | 87.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f1f5e6bd68dd5278db1d0d86f5465e87e7b4e557d16a229fe127d4f39e2ddb74
|
|
BLAKE2b-256 checksum How to use checksums |
bc3039ebadacbc1d42e56ab797a047bc9fa33abb23479376a8a5a1b6b6d1ab66
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / cli2mcp-0.1.1-py3-none-any.whl
| Download URL | cli2mcp-0.1.1-py3-none-any.whl |
|---|---|
| Size | 25.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9546220891518375dfb66186b93f88f7296f8c1f3ea2b61778088e434e593128
|
|
BLAKE2b-256 checksum How to use checksums |
d7a02c14fc6643f16d1ffec09d9a2c983902d7d14816f93dc065519054b676c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for cli2mcp 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.