mcp2cli
mcp2cli
Convert MCP servers to CLI tools
Usage · Architecture · Development · Guidelines · Testing · PR Workflow · Porting Parity
This is a Crystal port of github.com/thellimist/clihub.
Turn any MCP server into a compiled CLI binary. One command. Designed for agents.
mcp2cli generate --url https://api.githubcopilot.com/mcp/
# → ./out/api (Crystal binary with all MCP tools)
Every tool the server exposes becomes a subcommand with flags derived from its JSON Schema. Auth is handled automatically — bearer tokens, API keys, and more.
Install
# Clone and build
git clone https://github.com/dsisnero/mcp2cli.git
cd mcp2cli
shards install
shards build
# Install to your PATH
install -m 755 bin/mcp2cli ~/.local/bin/mcp2cli
If ~/.local/bin is not in your PATH, add it in your shell config (for example ~/.zshrc):
export PATH="$HOME/.local/bin:$PATH"
Requires Crystal 1.14+.
Quick Start
HTTP MCP server
mcp2cli generate --url https://api.githubcopilot.com/mcp/
./out/api list-tools
Authentication
Generated CLIs handle auth at runtime. For HTTP servers, the auth subcommand manages credentials:
# Manual bearer token
./out/api auth --token $TOKEN
# Check status
./out/api auth status
# Logout
./out/api auth logout
Auth is resolved in this order:
--auth-tokenflagMCP2CLI_AUTH_TOKENenvironment variable~/.config/mcp2cli/credentials.json(persisted from previous auth)~/.mcp2cli/credentials.json(fallback)- Unauthenticated
Pass tool input as JSON
Generated CLIs include a --from-json flag on each tool command. This lets you pass the full tool input object directly.
./out/api search-code --from-json '{"query":"function definition","language":"python"}'
Rules:
--from-jsonbypasses typed tool flags.--from-jsoncannot be combined with typed flags in the same call.
How It Works
- Connect to the MCP server (HTTP or stdio)
- Discover all tools via
tools/list - Generate a Crystal CLI with one subcommand per tool
- Compile to a binary for your target platform
The generated binary is standalone — no runtime dependencies, no config files, no mcp2cli needed.
Features
- Convert MCP servers to CLI tools
- Single binary output
- Agent-friendly interface
- XDG-compliant credential storage (
~/.config/mcp2cli/credentials.json) - Support for HTTP MCP servers
- Generated CLIs actually call MCP tools (not just placeholders)
- Compatible with GitHub Copilot's MCP server (handles
initializednotification gracefully)
Development
# Install dependencies
shards install
# Run tests
crystal spec
# Format code
crystal tool format src spec
# Run linter
ameba src spec
# Build project
shards build
# Run in development
bin/mcp2cli
See Development Guide for full setup instructions.
Documentation
| Document | Purpose |
|---|---|
| Usage | Generate binaries with verified examples |
| Architecture | System design and data flow |
| Development | Setup and daily workflow |
| Coding Guidelines | Code style and conventions |
| Testing | Test commands and patterns |
| PR Workflow | Commits, PRs, and review process |
| Porting Parity | Upstream source and port status |
Contributing
- Create an issue:
/forge-create-issue - Implement:
/forge-implement-issue <number> - Self-review:
/forge-reflect-pr - Address feedback:
/forge-address-pr-feedback - Update changelog:
/forge-update-changelog
Commits
Format: <type>(<scope>): <description>
Types: feat, fix, docs, refactor, test, chore, perf
Examples:
- feat(cli): add basic MCP server connection
- fix(parser): handle missing required arguments
- docs(readme): update installation instructions
Crystal Code Gates
crystal tool format --check src spec
ameba src spec
crystal spec
Porting Conventions
This is a Crystal port of github.com/thellimist/clihub.
Source of Truth
- Go code in
vendor/mcp2cli/is the authoritative source - Preserve behavior exactly from upstream
- Use Crystal idioms without changing semantics
Porting Workflow
- Use
go-to-crystal-parityto generate inventory - Use
porting-to-crystalfor code translation - Verify against Go tests and behavior
- Run Crystal quality gates before committing
Dependency Strategy
- Map Go dependencies to Crystal shards where possible
- Preserve API contracts and behavior
- Document any unavoidable deviations
License
mcp2cli
- 1
- 0
- 0
- 0
- 6
- about 13 hours ago
- March 7, 2026
MIT License
Wed, 25 Mar 2026 05:30:36 GMT