Get the FREE Ultimate OpenClaw Setup Guide →

mcp_on_ruby

💎 A Ruby implementation of the Model Context Protocol

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio rubyonai-mcp_on_ruby docker run -i rubyonai/mcp_on_ruby

How to use

MCP on Ruby exposes your Rails application as an AI-friendly interface. You define Tools as callable DSL components and Resources to expose data via templated URIs. The server validates inputs with JSON Schema and can be secured with token authentication, rate limiting, and CORS controls. To start using it, install the gem in your Rails project, generate the MCP server scaffolding, and begin exposing tools and resources that your AI clients can invoke over HTTP using standard MCP endpoints. The README describes examples for creating a UserManager tool and a UserStats resource, wiring them into your Rails app, and starting the Rails server with MCP routing available at /mcp. You can configure authentication, auto-registration of tools/resources, and origin whitelisting to fit your security needs. Clients such as Claude, OpenAI, or other MCP-enabled agents can then call your JSON-RPC based MCP surface to perform actions or fetch data via the defined tools and resources.

How to install

Prerequisites:

  • Ruby 2.7+ and Rails 6.0+ installed
  • Bundler available
  • A Rails app project to integrate MCP

Step 1: Add the gem to your Gemfile

# Gemfile
gem 'mcp_on_ruby'

Step 2: Install dependencies

bundle install

Step 3: Install MCP integration within Rails

rails generate mcp_on_ruby:install

Step 4: Create a sample Tool and Resource (examples from README)

# Generate a tool
rails generate mcp_on_ruby:tool UserManager --description "Manage application users"

# Generate a resource
rails generate mcp_on_ruby:resource UserStats --uri "users/{id}/stats" --template

Step 5: Configure MCP server (example shown in README)

# config/initializers/mcp_on_ruby.rb
McpOnRuby.configure do |config|
  config.authentication_required = true
  config.authentication_token = ENV['MCP_AUTH_TOKEN']
  config.rate_limit_per_minute = 60
  config.allowed_origins = [/\.yourdomain\.com$/]
end

Rails.application.configure do
  config.mcp.enabled = true
  config.mcp.auto_register_tools = true
  config.mcp.auto_register_resources = true
end

Step 6: Start the Rails server

rails server
# MCP server available at http://localhost:3000/mcp

Step 7: Verify access using an MCP client or curl with the generated endpoints.

Additional notes

Notes and tips:

  • If you enable authentication, set MCP_AUTH_TOKEN in your environment to guard MCP endpoints.
  • Use config.allowed_origins to limit where requests can originate to prevent DNS rebinding and CSRF concerns.
  • The Tools and Resources rely on JSON Schema validation; ensure your input/output contracts align with your defined schemas.
  • For real-time features, the README notes SSE groundwork; if you need live updates, plan for a compatible transport layer or wait for full SSE support.
  • When using Docker deployment, consider mounting a persistent config and ensuring your Rails app credentials are available inside the container.
  • If you upgrade Rails or Ruby versions, re-run bundle install and run your test suite to catch compatibility issues.

Related MCP Servers

Sponsor this space

Reach thousands of developers