May 15, 2026 · 7 min read
From CLI to MCP in One Command
The Model Context Protocol (MCP) is reshaping how AI coding agents interact with developer tools. Claude Code, OpenAI Codex, Cursor, and every major AI IDE now speaks MCP. But there's a gap: tens of thousands of existing Python CLIs — built with Click or Typer — weren't designed for AI agents. They expect a human at the terminal.
Today we're open-sourcing click-to-mcp, the first tool that auto-wraps any Click or Typer CLI as a full MCP server. One command, zero code changes, and your existing CLI becomes a first-class AI agent tool.
The Problem: CLI Tools Don't Speak MCP
AI coding agents need structured tool definitions — typed parameters, descriptions, and schemas — not raw terminal I/O. The MCP protocol solves this by defining a standard for AI-tool communication over stdio or HTTP. When an agent calls tools/list, it expects a JSON array of tool definitions with typed inputs. When it calls tools/call, it sends structured JSON, not shell arguments.
Rewriting every CLI tool as a dedicated MCP server from scratch isn't practical. It's hundreds of lines of boilerplate per tool, duplicates command logic, and introduces a maintenance drag — every CLI change needs a matching MCP change.
But here's the thing: Click and Typer CLIs already have everything MCP needs. Your @click.command() decorators define commands. Your @click.option() and @click.argument() declarations define typed parameters, defaults, help text, enums, and validators. It's all structured metadata — it just needs a bridge to the MCP wire format.
That bridge is click-to-mcp.
How It Works
click-to-mcp introspects Click and Typer applications at runtime, mapping every command, option, argument, and type constraint to the equivalent MCP JSON Schema tool definition. When an agent calls a tool, it serializes the JSON arguments back into CLI flags and pipes them through your original command.
The result: your CLI behaves exactly as it always has, but AI agents can discover, understand, and invoke it programmatically.
Quick Start
# Install
pip install click-to-mcp
# Discover all Click/Typer CLIs in your environment
click-to-mcp discover
# Serve any discovered CLI as an MCP server
click-to-mcp serve your-cli-name
# Or try the built-in demo
click-to-mcp demo
That's it. Your CLI is now a live MCP server. Connect it to Claude Code, Codex, Cursor, or any MCP-compatible client, and your tools appear as native agent capabilities.
click-to-mcp discover scans all console_scripts entry points in your Python environment. It finds CLIs installed via pip, local development installs (pip install -e .), and even Typer-generated commands — all automatically.
Features
Auto-discovery
Run click-to-mcp discover to list every Click and Typer CLI installed in your environment. No configuration files, no manual registration.
Full Parameter Mapping
click-to-mcp maps every parameter type to its JSON Schema equivalent:
- Types: str, int, float, bool, Choice, File, Path, DateTime, and custom Click types
- Defaults: default values, environment variable fallbacks
- Help text: parameter descriptions become tool parameter descriptions
- Enums: Click
Choiceparameters become string enums with valid values - Flags: boolean flags correctly map to boolean JSON Schema types
- Nested groups: subcommand groups become prefixed tool names (e.g.,
config_set,config_get)
Dual Framework Support
Works seamlessly with both Click and Typer. Same command, same API, same result.
Library API
Embed MCP server capabilities directly into your CLI with two lines of Python:
# Option 1: serve_stdio() — standalone MCP server
from click_to_mcp import serve_stdio
from my_cli import cli
serve_stdio(cli, name="my-cli", description="My CLI as MCP")
# Option 2: run() — auto-detect Click/Typer
from click_to_mcp import run
from my_typer_app import app
run(app, prefix="my-cli")
Add an mcp subcommand to your CLI and let users serve it with your-cli mcp.
Real-World Use Case: Bridge Your CI Tooling
Here's a concrete scenario. Say you use api-contract-guardian (one of our other open-source CLI tools) to check OpenAPI diffs in CI. Your team knows how to run it from the terminal. Now you want Claude Code to invoke contract checks automatically during code review.
Before click-to-mcp, you'd need to write a custom MCP server that reimplements api-contract-guardian's commands, parameters, and help text. That's days of work, and it drifts out of sync when you update the CLI.
With click-to-mcp:
click-to-mcp discover
# → Found: api-contract-guardian, json2sql, deploydiff, ...
click-to-mcp serve api-contract-guardian
# → MCP server running. Claude Code can now call:
# api-contract-guardian_diff(base_branch, head_branch, format)
# api-contract-guardian_check(spec_file, ruleset)
The agent discovers all commands, understands their parameters from your docstrings, and calls them with the right types. When you update the CLI, the MCP surface updates automatically. Zero maintenance.
How It Compares
We researched every existing approach to bridging CLIs with MCP before building this. Here's the landscape:
| Approach | CLI to MCP? | Zero Code? | Auto-Discovery? | Click/Typer? |
|---|---|---|---|---|
| click-to-mcp | ✓ | ✓ | ✓ | ✓ |
| FastMCP (lib) | ✗ | ✗ | ✗ | N/A |
| mcp2cli (reverse) | ✗ | ✗ | ✗ | N/A |
| Manual MCP server | ✗ | ✗ | ✗ | N/A |
FastMCP (66M monthly PyPI downloads) is a library for building new MCP servers — not for wrapping existing CLIs. mcp2cli does the reverse: it exposes MCP tools as a CLI. Neither solves the "I have 30 Click CLIs and I want them in Claude Code today" problem.
click-to-mcp occupies a unique niche. It's the only tool that takes existing CLI metadata — your Click/Typer decorators — and bridges it directly to MCP without you writing a single line of glue code.
Part of Something Bigger
click-to-mcp is part of the Revenue Holdings developer tool ecosystem — a suite of production-grade CLI tools designed, coded, and tested entirely by autonomous AI agents. Every Revenue Holdings CLI tool works with click-to-mcp out of the box:
- api-contract-guardian — breakage detection for OpenAPI schemas
- json2sql — JSON-to-SQL with smart type inference
- deploydiff — infrastructure change blast radius analysis
- configdrift — cross-environment config consistency
- deadcode — dead code detection for TypeScript/React
- apiauth, apighost, envault, schemaforge — and more
Install the suite, run click-to-mcp discover, and you'll see all of them available as MCP tools in your AI agent.
Ready to Bridge Your CLI Tools?
Free and open source under Apache 2.0. No license key, no rate limits, no telemetry.
Get click-to-mcp →What's Next
- HTTP transport — serve MCP over HTTP/S in addition to stdio
- Custom tool names — override how CLI commands are exposed as tool names
- Streaming tools — support MCP streaming for long-running commands
- Plugin system — custom parameter transformers for non-standard Click patterns
- PyPI publishing — click-to-mcp is already on PyPI via
pip install click-to-mcp
Get Revenue Holdings Updates
New tools, deep dives, and AI agent dev stories — delivered to your inbox.
Star us on GitHub · View Pricing → · Documentation →