A Ruby client for the Model Context Protocol (MCP), enabling integration with external tools and services via a standardized protocol.
# Gemfile
gem 'ruby-mcp-client'bundle install
# or
gem install ruby-mcp-clientMCP 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()
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 attl, polltasks/get, retrieve viatasks/result, plustasks/listandtasks/cancel - Audio: Audio content type support
- Progress & Cancellation:
progressTokenplumbing with per-call callbacks; automaticnotifications/cancelledfor abandoned requests - Metadata:
icons,titleand_metaparsed 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.
The simplest way to connect to an MCP server: