0.0
The project is in a healthy, maintained state
A Ruby gem that provides tooling for connecting to and inspecting MCP servers, allowing you to list and execute tools, resources, and prompts with JSON output.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 2.0
~> 13.0
~> 3.12

Runtime

>= 0
~> 2.6
~> 1.3
~> 2.6
 Project Readme

MCP Inspector

A Ruby gem that provides a command-line tool for connecting to and inspecting MCP (Model Context Protocol) servers. The tool allows you to list and execute tools, read resources, and get prompts from MCP servers with JSON output by default.

Features

  • Multi-transport support: Connect to MCP servers via stdio, SSE, or WebSocket
  • Command-based CLI: Execute operations without persistent sessions
  • JSON configuration: Configure multiple servers in a single JSON file
  • Structured output: All output in JSON format for easy parsing and automation
  • Three-layer architecture: Designed for future web adaptation

Installation

Install the gem by executing:

gem install mcp-inspector

Or add it to your Gemfile:

gem 'mcp-inspector'

Then execute:

bundle install

Quick Start

  1. Create a configuration file:
mcp-inspector config init

This creates ~/.mcp-inspector.json with example server configurations.

  1. List available servers:
mcp-inspector config list
  1. List tools from a server:
mcp-inspector list tools --server filesystem-server
  1. Execute a tool:
mcp-inspector execute read_file --server filesystem-server --args '{"path": "/tmp/test.txt"}'

Configuration

The tool looks for configuration files in this order:

  1. Custom path via --config flag
  2. ./.mcp-inspector.json (project config)
  3. ~/.mcp-inspector.json (user config)

Configuration Format

{
  "servers": [
    {
      "name": "filesystem-server",
      "transport": "stdio",
      "command": ["npx", "-y", "@modelcontextprotocol/server-filesystem"],
      "args": ["/tmp"],
      "env": {}
    },
    {
      "name": "github-server",
      "transport": "stdio",
      "command": ["npx", "-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_TOKEN": "${GITHUB_TOKEN}"
      }
    },
    {
      "name": "http-server",
      "transport": "sse",
      "url": "http://localhost:8080/sse"
    }
  ],
  "defaults": {
    "output": "json",
    "pretty": true
  }
}

Transport Types

  • stdio: Run a command and communicate via stdin/stdout
  • sse: Connect to Server-Sent Events endpoint
  • websocket: Connect to WebSocket endpoint

Usage

Global Options

  • --config PATH: Path to config file
  • --server NAME: Server name from config (required)
  • --output FORMAT: Output format (json)
  • --pretty: Pretty print output (default: true)
  • --no-pretty: Disable pretty printing

Commands

List Resources

# List all tools
mcp-inspector list tools --server myserver

# List all resources  
mcp-inspector list resources --server myserver

# List all prompts
mcp-inspector list prompts --server myserver

Execute Operations

# Execute a tool
mcp-inspector execute tool_name --server myserver --args '{"key": "value"}'

# Read a resource
mcp-inspector read file:///path/to/file --server myserver

# Get a prompt
mcp-inspector prompt prompt_name --server myserver --args '{"key": "value"}'

Server Information

# Show server info and capabilities
mcp-inspector info --server myserver

Configuration Management

# List configured servers
mcp-inspector config list

# Show server configuration
mcp-inspector config show myserver

# Create example config file
mcp-inspector config init [path]

Output Format

All commands return JSON with a consistent structure:

{
  "status": "success",
  "data": {
    "tools": [...],
    "count": 3
  },
  "metadata": {
    "operation": "list_tools",
    "server": "filesystem-server",
    "timestamp": "2024-01-01T12:00:00Z"
  }
}

Error responses:

{
  "status": "error",
  "error": {
    "type": "ConnectionError", 
    "message": "Failed to connect to server"
  },
  "metadata": {
    "operation": "list_tools",
    "server": "filesystem-server",
    "timestamp": "2024-01-01T12:00:00Z"
  }
}

Examples

Filesystem Server

# List files in a directory
mcp-inspector list tools --server filesystem-server

# Read a file
mcp-inspector execute read_file --server filesystem-server --args '{"path": "/tmp/example.txt"}'

# Write to a file
mcp-inspector execute write_file --server filesystem-server --args '{"path": "/tmp/output.txt", "content": "Hello World"}'

GitHub Server

# List repository information
mcp-inspector list resources --server github-server

# Search repositories
mcp-inspector execute search_repositories --server github-server --args '{"query": "ruby mcp"}'

Architecture

The gem uses a three-layer architecture:

  1. Transport Layer: Handles connections to MCP servers
  2. Data Layer: Manages configuration and input/output processing
  3. Presentation Layer: Formats output for display

This design makes it easy to add new output formats or adapt for web interfaces in the future.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests.

To install this gem onto your local machine, run bundle exec rake install.

Running Tests

bundle exec rspec

Building the Gem

gem build mcp-inspector.gemspec

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/anthropics/mcp-inspector.

License

The gem is available as open source under the terms of the MIT License.