npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tronsfey/mcp2cli

v1.2.0

Published

Command-line proxy for any MCP server — call tools directly from the terminal

Downloads

538

Readme

mcp2cli

Command-line proxy for any MCP (Model Context Protocol) server — call tools directly from the terminal.

A Node.js/TypeScript CLI tool that connects to MCP servers and exposes their tools as command-line commands. Supports both HTTP/SSE and stdio transports, with tool list caching and named server shortcuts ("bakes").

Inspired by knowsuchagency/mcp2cli.


Installation

npm install -g @tronsfey/mcp2cli
# or run directly
npx @tronsfey/mcp2cli --help

Quick Start

Connect to an HTTP/SSE MCP server

# List all available tools
mcp2cli --mcp https://server.example.com/mcp --list

# Call a tool
mcp2cli --mcp https://server.example.com/mcp search --query "hello world"

Connect to a local stdio MCP server

# Spawn a local server and list its tools
mcp2cli --mcp-stdio "npx -y @modelcontextprotocol/server-filesystem /" --list

# Call a tool on the local server
mcp2cli --mcp-stdio "npx -y @modelcontextprotocol/server-filesystem /" \
  list-directory --path /tmp

Usage

mcp2cli [options] [tool-name] [tool-options]

Options:
  --mcp <url>              MCP HTTP/SSE server URL
  --mcp-stdio <command>    MCP stdio server command (spawns local process)
  --env <KEY=VALUE...>     Extra environment variables for stdio server
  --header <Header:Value>  Custom HTTP headers (can repeat)
  -l, --list               List available tools and exit
  --pretty                 Pretty-print output (default)
  --raw                    Output raw JSON
  --jq <expression>        Filter output with JMESPath expression
  --no-cache               Bypass tool list cache
  --cache-ttl <seconds>    Cache TTL in seconds (default: 3600)
  -V, --version            Output version
  -h, --help               Show help

Commands:
  bake                     Manage saved server configurations
  completion [shell]       Output shell completion script (bash|zsh|fish)

Bake — Save Server Shortcuts

Save a server configuration once and reference it with @name:

# Save an HTTP server
mcp2cli bake create myserver --mcp https://server.example.com/mcp
mcp2cli bake create myserver --mcp https://server.example.com/mcp \
  --header "Authorization: Bearer TOKEN"

# Save a local stdio server
mcp2cli bake create localfs --mcp-stdio "npx -y @modelcontextprotocol/server-filesystem /"

# List saved bakes
mcp2cli bake list

# Delete a bake
mcp2cli bake delete myserver

# Use a saved bake
mcp2cli @myserver --list
mcp2cli @localfs list-directory --path /tmp

Bakes are stored in ~/.mcp2cli/bakes.json.


Output Formatting

# Default: pretty-print text content from tool result
mcp2cli --mcp <url> <tool> [args]

# Raw JSON output
mcp2cli --mcp <url> <tool> [args] --raw

# Filter with JMESPath
mcp2cli --mcp <url> <tool> [args] --jq 'results[*].name'

Caching

Tool lists are cached per server (default TTL: 1 hour) to speed up repeated invocations.

# Bypass cache
mcp2cli --mcp <url> --list --no-cache

# Custom TTL (5 minutes)
mcp2cli --mcp <url> --list --cache-ttl 300

Cache files are stored in ~/.mcp2cli/cache/.


Authentication

HTTP server with Bearer token

mcp2cli --mcp https://server.example.com/mcp \
  --header "Authorization: Bearer YOUR_TOKEN" \
  --list

stdio server with environment variables

mcp2cli --mcp-stdio "node server.js" \
  --env "API_KEY=secret" \
  --env "DB_URL=postgres://localhost/mydb" \
  <tool-name> [args]

Shell Completion

# Bash
mcp2cli completion bash >> ~/.bashrc
source ~/.bashrc

# Zsh
mcp2cli completion zsh >> ~/.zshrc
source ~/.zshrc

# Fish
mcp2cli completion fish > ~/.config/fish/completions/mcp2cli.fish

Architecture

CLI invocation
    │
    ▼
Resolve @name shortcut (bake lookup)
    │
    ▼
Parse global options (Commander.js)
    │
    ├─► --list ──► Connect → listTools() → print → exit
    │
    └─► tool-name
            │
            ▼
        createMcpClient()         [src/client/]
        (HTTP Streamable → SSE fallback | stdio)
            │
            ▼
        getTools()                [src/runner/ + src/cache.ts]
        (cache lookup → listTools() → cache write)
            │
            ▼
        schemaToParams()          [JSON Schema → ToolParam[]]
            │
            ▼
        Parse tool-specific args  [dynamic Commander subcommand]
            │
            ▼
        client.callTool()
            │
            ▼
        Format & print result     [--raw / --jq / pretty]

Development

git clone https://github.com/tronsfey928/mcp2cli.git
cd mcp2cli
npm install
npm run build
npm test

# Run directly without building
npm run dev -- --help

License

MIT