ruby-mcp-client

MCP.Pizza Chef: simonx1

ruby-mcp-client is a Ruby gem implementing the Model Context Protocol (MCP) client, allowing Ruby applications to integrate with external AI tools and services via a standardized protocol. It supports multiple transport mechanisms like Standard I/O and Server-Sent Events (SSE) for real-time communication. The client includes helper methods to format tools for popular AI providers such as OpenAI, Anthropic Claude, and Google Vertex AI, facilitating easy interoperability and multi-provider support in AI workflows.

Use This MCP client To

Integrate Ruby applications with MCP-compliant AI tools and services Streamline communication with AI tools using Standard I/O or SSE transports Format and convert tools for OpenAI, Anthropic Claude, and Google Vertex AI APIs Build AI assistants that invoke external tools via MCP protocol Enable multi-provider AI workflows in Ruby environments

README

ruby-mcp-client

A Ruby client for the Model Context Protocol (MCP), enabling integration with external tools and services via a standardized protocol.

Installation

# Gemfile
gem 'ruby-mcp-client'
bundle install
# or
gem install ruby-mcp-client

Overview

MCP enables AI assistants to discover and invoke external tools via different transport mechanisms:

  • stdio - Local processes implementing the MCP protocol
  • SSE - Server-Sent Events with streaming support
  • HTTP - Simple request/response (non-streaming)
  • Streamable HTTP - HTTP POST with SSE-formatted responses

Built-in API conversions: to_openai_tools(), to_anthropic_tools(), to_google_tools()

MCP Protocol Support

Implements the MCP 2025-11-25 specification. The client negotiates the protocol version during initialize and disconnects if the server answers with a revision it cannot speak (supported: 2025-11-25, 2025-06-18, 2025-03-26, 2024-11-05):

  • Tools: list, call, streaming, annotations (hint-style), structured outputs, title
  • Prompts: list, get with parameters
  • Resources: list, read, templates, subscriptions, pagination, ResourceLink content
  • Elicitation: Server-initiated user interactions (stdio, SSE, Streamable HTTP)
  • Roots: Filesystem scope boundaries with change notifications
  • Sampling: Server-requested LLM completions with modelPreferences
  • Completion: Autocomplete for prompts/resources with context
  • Logging: Server log messages with level filtering
  • Tasks: Task-augmented tools/call — create with a ttl, poll tasks/get, retrieve via tasks/result, plus tasks/list and tasks/cancel
  • Audio: Audio content type support
  • Progress & Cancellation: progressToken plumbing with per-call callbacks; automatic notifications/cancelled for abandoned requests
  • Metadata: icons, title and _meta parsed on tools, prompts and resources
  • OAuth 2.1: PKCE (S256 required), RFC 8414/9728 discovery, dynamic registration, Client ID Metadata Documents, scope step-up challenges

Transports treat the server as untrusted input — see Treating the Server as Untrusted for the limits applied to peer-controlled data.

Quick Connect API (Recommended)

The simplest way to connect to an MCP server:

ruby-mcp-client FAQ

How do I install ruby-mcp-client?
Add `gem 'ruby-mcp-client'` to your Gemfile and run `bundle install`, or install directly with `gem install ruby-mcp-client`.
What transport mechanisms does ruby-mcp-client support?
It supports Standard I/O for local processes and Server-Sent Events (SSE) for remote MCP servers over HTTP with streaming.
Can ruby-mcp-client format tools for different AI providers?
Yes, it provides helper methods to format tools for OpenAI, Anthropic Claude, and Google Vertex AI APIs.
Is ruby-mcp-client suitable for building AI assistants?
Yes, it enables Ruby applications to discover and invoke external tools via MCP, ideal for AI assistant development.
Does ruby-mcp-client support real-time streaming?
Yes, through Server-Sent Events (SSE) it supports streaming from remote MCP servers.
Where is the core client class located?
The core client resides in `MCPClient::Client` providing main integration methods.
Can ruby-mcp-client be used with multiple LLM providers?
Yes, it supports interoperability with OpenAI, Anthropic Claude, and Google Vertex AI among others.