Project

mcp_cli

0.0
No release in over 3 years
Command-line interface for interacting with MCP (Model Context Protocol) servers. Supports stdio and HTTP transports.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

MCP CLI

Gem Version on RubyGems.org

A zero-dependency command-line interface for interacting with Model Context Protocol (MCP) servers. MCP enables AI assistants to securely connect to local and remote resources through a standardized protocol.

Perfect for developers who need to:

  • Test MCP server implementations
  • Debug server responses
  • Integrate MCP servers into scripts and workflows
  • Explore available tools and resources

Supports both stdio and HTTP transports with automatic configuration discovery.

Note

Read about the reason I built this and what you can use it to do: Making MCP Tool Calls Scriptable with mcp_cli

Requirements

  • Ruby 2.7 or higher
  • RubyGems 3.0 or higher
  • Compatible with macOS, Linux, and Windows

Quick Start (No Installation)

The fastest way to use MCP CLI is with gem exec - no installation required:

gem exec mcp_cli list
gem exec mcp_cli tools my-server
gem exec --silent mcp_cli call my-server my-tool --arg value | grep "foobar"

This is perfect for trying out the tool or using it in scripts without adding dependencies. gem exec supports fast software.

Installation (Optional)

If you prefer to install the gem:

gem install mcp_cli

Then use it directly:

mcp list
mcp tools my-server

Configuration

MCP CLI looks for server configurations in these locations (in order):

  1. ~/.claude.json
  2. ~/.cursor/mcp.json
  3. ~/.vscode/mcp.json

You can also specify a custom config file:

gem exec mcp_cli --mcp-config /path/to/config.json list

Or use shortcuts for default configs:

gem exec mcp_cli --mcp-config claude list
gem exec mcp_cli --mcp-config cursor list
gem exec mcp_cli --mcp-config vscode list

Configuration Format

Your config file should follow this structure:

{
  "mcpServers": {
    "my-server": {
      "type": "stdio",
      "command": "node",
      "args": ["/path/to/server.js"],
      "env": {
        "API_KEY": "your-key"
      }
    },
    "http-server": {
      "type": "http",
      "url": "https://example.com/mcp",
      "headers": {
        "Authorization": "Bearer token"
      }
    }
  }
}

Usage

List Available Servers

gem exec mcp_cli list

List Tools

# List all tools on a server
gem exec mcp_cli tools my-server

# Show details for a specific tool
gem exec mcp_cli tools my-server search_all

Call a Tool

# With JSON arguments
gem exec mcp_cli call my-server search_all '{"query": "example"}'

# With flag-style arguments
gem exec mcp_cli call my-server search_all --query example

# Boolean flags
gem exec mcp_cli call my-server sync --force

List Prompts

gem exec mcp_cli prompts my-server

Get a Prompt

gem exec mcp_cli prompt my-server explain '{"topic": "MCP servers"}'

List Resources

gem exec mcp_cli resources my-server

Server Information

# Full server info
gem exec mcp_cli info my-server

# Just the version
gem exec mcp_cli version my-server

# Show configuration
gem exec mcp_cli config my-server

Options

# Use a specific protocol version
gem exec mcp_cli --protocol-version 2025-06-18 tools my-server

# Use a custom config file
gem exec mcp_cli --mcp-config /path/to/config.json list

# Show help
gem exec mcp_cli --help

# Show version
gem exec mcp_cli --version

Features

  • Zero dependencies - Uses only Ruby standard library
  • Fast startup - Minimal overhead for quick commands
  • Flexible arguments - Supports both JSON and flag-style arguments
  • Multiple transports - Works with stdio and HTTP MCP servers
  • Config auto-discovery - Finds your existing MCP configurations

Troubleshooting

Server not found

Ensure your server name matches exactly what's in your config file. Server names are case-sensitive.

Connection timeout

For stdio servers, verify the command path exists and is executable. Check that all required dependencies are installed.

Authentication errors

Check that environment variables and headers are properly set in your config. For HTTP servers, ensure your authentication tokens are valid.

No config file found

MCP CLI looks for configs in ~/.claude.json, ~/.cursor/mcp.json, or ~/.vscode/mcp.json. Create one of these files or specify a custom path with --mcp-config.

Development

# Clone the repo
git clone https://github.com/joshbeckman/mcp_cli.git
cd mcp_cli

# Install dependencies (just development tools)
bundle install

# Run tests
bundle exec rspec

# Test locally without installing
ruby -Ilib exe/mcp list

License

MIT

Contributing

Bug reports and pull requests welcome on GitHub at https://github.com/joshbeckman/mcp_cli.