Fire in da houseTop Tip:Paying $100+ per month for Perplexity, MidJourney, Runway, ChatGPT is crazy - get all your AI tools in one site starting at $15 per month with Galaxy AIFire in da houseCheck it out free

mcp_on_ruby

MCP.Pizza Chef: nagstler

mcp_on_ruby is a Ruby-based server implementation of the Model Context Protocol (MCP), enabling standardized interactions between AI models and external tools or data sources. It supports Ruby 3.0+ and provides a robust, open-source foundation for building AI applications that require real-time context sharing and tool integration. This server facilitates seamless AI workflows by adhering to MCP specifications, making it ideal for developers working within Ruby environments.

Use This MCP server To

Implement MCP server in Ruby applications for AI context sharing Expose Ruby-based data sources and tools to AI models Build AI-enhanced workflows with real-time context in Ruby Integrate external APIs and services into AI workflows using Ruby Develop custom MCP servers tailored to Ruby ecosystems

README

MCP on Ruby

Gem Version License: MIT Ruby Version Build Status

A Ruby implementation of the Model Context Protocol (MCP) specification, enabling standardized AI application interactions with external tools and data sources.

Documentation | Examples | Contributing

πŸ“‹ Table of Contents

✨ Features

  • Full MCP Protocol Support - Implements the latest MCP specification
  • Multiple Transport Options - HTTP and STDIO transports
  • Comprehensive Capabilities
    • πŸ› οΈ Tools (model-controlled actions)
    • πŸ“š Resources (application-controlled context)
    • πŸ’¬ Prompts (user-controlled interactions)
    • πŸ“ Roots (filesystem integration)
  • Security First
    • OAuth 2.1 Authentication
    • JWT Implementation
    • Scope-based Authorization
  • Real-time Communication
    • Bidirectional messaging
    • Streaming support
    • JSON-RPC 2.0 standard

πŸš€ Installation

Add to your Gemfile:

gem 'mcp_on_ruby'

Then run:

bundle install

Or install directly:

gem install mcp_on_ruby

🏁 Quick Start

Server Setup

Create a basic MCP server with tools:

require 'mcp_on_ruby'

server = MCP::Server.new do |s|
  # Define a tool
  s.tool "weather.get_forecast" do |params|
    location = params[:location]
    { forecast: "Sunny", temperature: 72, location: location }
  end
  
  # Add a resource
  s.resource "user.profile" do
    { name: "John", email: "john@example.com" }
  end
end

server.start

Client Setup

Connect to an MCP server:

require 'mcp_on_ruby'

client = MCP::Client.new(url: "http://localhost:3000")
client.connect

# List available tools
tools = client.tools.list

# Call a tool
result = client.tools.call("weather.get_forecast", 
  { location: "San Francisco" }
)

🎯 Core Concepts

1. Tools

Model-controlled functions with JSON Schema-defined parameters:

server.tools.define('example') do
  parameter :name, :string
  
  execute do |params|
    "Hello, #{params[:name]}!"
  end
end

2. Resources

Application-controlled data sources:

server.resource "user.profile" do
  { name: "John", email: "john@example.com" }
end

3. Authentication

Secure your server with OAuth 2.1:

oauth_provider = MCP::Server::Auth::OAuth.new(
  client_id: 'your-client-id',
  client_secret: 'your-client-secret',
  token_expiry: 3600,
  jwt_secret: 'your-jwt-secret',
  issuer: 'your-server'
)

πŸ”’ Security

OAuth 2.1 Implementation

  • Token-based authentication
  • JWT validation
  • Automatic token refresh
  • Scope-based authorization

Permission Management

  • Method-level permissions
  • Scope requirements
  • Middleware architecture

πŸ“š Advanced Usage

Check out our examples directory for complete implementations:

For more advanced topics, visit our Wiki.

πŸ’» Development

# Clone the repository
git clone https://github.com/nagstler/mcp_on_ruby.git

# Install dependencies
bundle install

# Run tests
bundle exec rspec

# Start console
bundle exec bin/console

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Please read our Contributing Guide for details on our code of conduct and the process for submitting pull requests.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


Made with ❀️ for the Ruby community

mcp_on_ruby FAQ

How do I install mcp_on_ruby?
You can install mcp_on_ruby via RubyGems using `gem install mcp_on_ruby`.
What Ruby versions does mcp_on_ruby support?
It supports Ruby 3.0 and above.
Where can I find documentation for mcp_on_ruby?
Comprehensive documentation is available at https://rubydoc.info/gems/mcp_on_ruby.
Can mcp_on_ruby be used to expose custom data sources?
Yes, it allows you to create MCP servers that expose any Ruby-accessible data or tools.
Is mcp_on_ruby open source?
Yes, it is licensed under the MIT License and available on GitHub.
Does mcp_on_ruby support integration with multiple LLM providers?
Yes, it is designed to work with any MCP-compatible LLM provider, including OpenAI, Claude, and Gemini.
How do I contribute to mcp_on_ruby?
Contributions are welcome via GitHub; see the contributing guide in the repository.