mcp-rb
A lightweight Ruby framework for building MCP servers with a Sinatra-like DSL
Documentation
MCP-RB
A lightweight Ruby framework for implementing MCP (Model Context Protocol) servers with a Sinatra-like DSL.
Installation
Add this line to your application's Gemfile:
gem 'mcp-rb'Usage
Here's a simple example of how to create an MCP server:
require 'mcp'
name "hello-world"
version "1.0.0"
# Define a resource
resource "hello://world" do
name "Hello World"
description "A simple hello world message"
call { "Hello, World!" }
end
# Define a resource template
resource_template "hello://{user_name}" do
name "Hello User"
description "A simple hello user message"
call { |args| "Hello, #{args[:user_name]}!" }
end
# Define a tool
tool "greet" do
description "Greet someone by name"
argument :name, String, required: true, description: "Name to greet"
call do |args|
"Hello, #{args[:name]}!"
end
end
# Define a tool with nested arguments
tool "greet_full_name" do
description "Greet someone by their full name"
argument :person, required: true, description: "Person to greet" do
argument :first_name, String, required: false, description: "First name"
argument :last_name, String, required: false, description: "Last name"
end
call do |args|
"Hello, First: #{args[:person][:first_name]} Last: #{args[:person][:last_name]}!"
end
end
# Define a tool with an Array argument
tool "group_greeting" do
description "Greet multiple people at once"
argument :people, Array, required: true, items: String, description: "People to greet"
call do |args|
args[:people].map { |person| "Hello, #{person}!" }.join(", ")
end
endSupported specifications
Reference: MCP 2024-11-05
- Base Protocol
- ping
- stdio transport
- Server features
- Resources
- resources/read
- resources/list
- resources/templates/list
- Tools
- tools/list
- tools/call
- Resources
Any capabilities are not supported yet.
Testing
rake test
rake test:unit # run only the unit tests, skipping tests that test a running serverTest with MCP Inspector
bunx @modelcontextprotocol/inspector $(pwd)/examples/hello_world.rbFormatting
bundle exec standardrb --fixYou can also use rake tasks:
rake lint # Run standardrb to check code style
rake lint:fix # Auto-fix standardrb issuesRelease
To release a new version:
1. Update version in `lib/mcp/version.rb`
2. Update `CHANGELOG.md`
3. Create a git tag
git add .
git commit -m "Release vx.y.z"
git tag vx.y.z
git push --tags1. Build and push to RubyGems
gem build mcp-rb.gemspec
gem push mcp-rb-*.gemChangelog
See CHANGELOG.md
Frequently asked questions
What is mcp-rb?
mcp-rb is A lightweight Ruby framework for building MCP servers with a Sinatra-like DSL
How do I install mcp-rb?
Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.
Is mcp-rb open source?
Yes — it is hosted on GitHub at https://github.com/funwarioisii/mcp-rb and has 205 stars.
Related MCP tools
A Minecraft MCP Server powered by Mineflayer API. It allows to control a Minecraft character in real-time, allowing AI assistants to build structures, explor...
Model Context Protocol server for GraphQL TypeScript-based implementation.
Expose your FastAPI endpoints as Model Context Protocol (MCP) tools, with Auth! Python-based implementation. Trusted by 11000+ developers.
AI-powered reverse engineering assistant that bridges IDA Pro with language models through MCP. Python-based implementation. Trusted by 4100+ developers.
A command-line interface for interacting with MCP (Model Context Protocol) servers using both stdio and HTTP transport. Go-based implementation.
An MCP server that autonomously evaluates web applications. Python-based implementation. Trusted by 1100+ developers. Trusted by 1100+ developers.
Run your own MCP server? See who uses it and what to fix.
Measure it with TrackMCP