About
MCP Ruby SDK is the official Ruby framework for building Model Context Protocol servers and clients. It provides a complete implementation of the MCP specification for handling JSON-RPC 2.0 communications between AI assistants and external services. Key capabilities: - Core `MCP::Server` class that manages protocol initialization, capability negotiation, and message handling - Full support for stdio and Streamable HTTP transports (including Server-Sent Events) - Tool registration and invocation with schema validation - Prompt management for templated interactions - Resource registration and retrieval with URI template support - Notifications for real-time updates when tools, prompts, or resources change - Custom method definitions beyond standard MCP protocol methods - Built-in instrumentation callbacks for monitoring and observability Install via RubyGems (`gem 'mcp'`) to add MCP server capabilities to Ruby applications.
README
MCP Ruby SDK [](https://rubygems.org/gems/mcp) [](https://github.com/modelcontextprotocol/ruby-sdk/blob/main/LICENSE) [](https://github.com/modelcontextprotocol/ruby-sdk/actions/workflows/ci.yml)
The official Ruby SDK for Model Context Protocol servers and clients.
Installation
Add this line to your application's Gemfile:
gem 'mcp'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install mcp
You may need to add additional dependencies depending on which features you wish to access.
Building an MCP Server
The MCP::Server class is the core component that handles JSON-RPC requests and responses.
It implements the Model Context Protocol specification, handling model context requests and responses.
Key Features
Supported Methods
initialize - Initializes the protocol and returns server capabilitiesping - Simple health checktools/list - Lists all registered tools and their schemastools/call - Invokes a specific tool with provided argumentsprompts/list - Lists all registered prompts and their schemasprompts/get - Retrieves a specific prompt by nameresources/list - Lists all registered resources and their schemasresources/read - Retrieves a specific resource by nameresources/templates/list - Lists all registered resource templates and their schemasCustom Methods
The server allows you to define custom JSON-RPC methods beyond the standard MCP protocol methods using the define_custom_method method:
server = MCP::Server.new(name: "my_server")Define a custom method that returns a result
server.define_custom_method(method_name: "add") do |params|
params[:a] + params[:b]
endDefine a custom notification method (returns nil)
server.define_custom_method(method_name: "notify") do |params|
# Process notification
nil
end
Key Features:
Usage Example:
# Client request
{
"jsonrpc": "2.0",
"id": 1,
"method": "add",
"params": { "a": 5, "b": 3 }
}Server response
{
"jsonrpc": "2.0",
"id": 1,
"result": 8
}
Error Handling:
MCP::Server::MethodAlreadyDefinedError if trying to override an existing methodNotifications
The server supports sending notifications to clients when lists of tools, prompts, or resources change. This enables real-time updates without polling.
#### Notification Methods
The server provides the following notification methods:
notify_tools_list_changed - Send a notification when the tools list changesnotify_prompts_list_changed - Send a notification when the prompts list changesnotify_resources_list_changed - Send a notification when the resources list changesnotify_progress - Send a progress notification for long-running operationsnotify_log_message - Send a structured logging notification message#### Notification Format
Notifications follow the JSON-RPC 2.0 specification and use these method names:
notifications/tools/list_changednotifications/prompts/list_changednotifications/resources/list_changednotifications/progressnotifications/messageProgress
The MCP Ruby SDK supports progress tracking for long-running tool operations, following the MCP Progress specification.
#### How Progress Works
1. Client Request: The client sends a progressToken in the _meta field when calling a tool
2. Server Notification: The server sends notifications/progress messages back to the client during tool execution
3. Tool Integration: Tools call server_context.report_progress to report incremental progress
#### Server-Side: Tool with Progress
Tools that accept a server_context: parameter can call report_progress on it.
The server automatically wraps the context in an MCP::ServerContext instance that provides this method:
```ruby class LongRunningTool < MCP::Tool description "A tool that reports progress during execution"
Related MCP Servers
AI Research Assistant
hamid-vakilzadeh
AI Research Assistant provides comprehensive access to millions of academic papers through the Semantic Scholar and arXiv databases. This MCP server enables AI coding assistants to perform intelligent literature searches, citation network analysis, and paper content extraction without requiring an API key. Key features include: - Advanced paper search with multi-filter support by year ranges, citation thresholds, field of study, and publication type - Title matching with confidence scoring for finding specific papers - Batch operations supporting up to 500 papers per request - Citation analysis and network exploration for understanding research relationships - Full-text PDF extraction from arXiv and Wiley open-access content (Wiley TDM token required for institutional access) - Rate limits of 100 requests per 5 minutes with options to request higher limits through Semantic Scholar
Linkup
LinkupPlatform
Linkup is a real-time web search and content extraction service that enables AI assistants to search the web and retrieve information from trusted sources. It provides source-backed answers with citations, making it ideal for fact-checking, news gathering, and research tasks. Key features of Linkup: - Real-time web search using natural language queries to find current information, news, and data - Page fetching to extract and read content from any webpage URL - Search depth modes: Standard for direct-answer queries and Deep for complex research across multiple sources - Source-backed results with citations and context from relevant, trustworthy websites - JavaScript rendering support for accessing dynamic content on JavaScript-heavy pages
Math-MCP
EthanHenrickson
Math-MCP is a computation server that enables Large Language Models (LLMs) to perform accurate numerical calculations through the Model Context Protocol. It provides precise mathematical operations via a simple API to overcome LLM limitations in arithmetic and statistical reasoning. Key features of Math-MCP: - Basic arithmetic operations: addition, subtraction, multiplication, division, modulo, and bulk summation - Statistical analysis functions: mean, median, mode, minimum, and maximum calculations - Rounding utilities: floor, ceiling, and nearest integer rounding - Trigonometric functions: sine, cosine, tangent, and their inverses with degrees and radians conversion support