Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
F

fast-mcp

> AI 编程
Open source

A Ruby Implementation of the Model Context Protocol

1.2K stars0 likes2 views
WebsiteGitHub

About

A Ruby Implementation of the Model Context Protocol

Fast MCP

Interface your Servers with LLMs in minutes

AI models are powerful, but they need to interact with your applications to be truly useful. Traditional approaches mean wrestling with:

  • Complex communication protocols and custom JSON formats
  • Integration challenges with different model providers
  • Compatibility issues between your app and AI tools
  • Managing the state between AI interactions and your data

Fast MCP solves all these problems by providing a clean, Ruby-focused implementation of the Model Context Protocol, making AI integration a joy, not a chore.

✨ Features

  • ️ Tools API - Let AI models call your Ruby functions securely, with in-depth argument validation through Dry-Schema.
  • Resources API - Share data between your app and AI models
  • Multiple Transports - Choose from STDIO, HTTP, or SSE based on your needs
  • Framework Integration - Works seamlessly with Rails, Sinatra or any Rack app.
  • Authentication Support - Secure your AI-powered endpoints with ease
  • Real-time Updates - Subscribe to changes for interactive applications
  • Dynamic Filtering - Control tool/resource access based on request context (permissions, API versions, etc.)

What Makes FastMCP Great

…

Dynamic Tool Filtering

Control which tools and resources are available based on request context:

ruby
# Tag your tools for easy filtering
class AdminTool < FastMcp::Tool
  tags :admin, :dangerous
  description "Perform admin operations"

  def call
    # Admin only functionality
  end
end

# Filter tools based on user permissions
server.filter_tools do |request, tools|
  user_role = request.params['role']

  case user_role
  when 'admin'
    tools # Admins see all tools
  when 'user'
    tools.reject { |t| t.tags.include?(:admin) }
  else
    tools.select { |t| t.tags.include?(:public) }
  end
end

Fast Ruby on Rails implementation

bash
bundle add fast-mcp
bin/rails generate fast_mcp:install

This will add a configurable fast_mcp.rb initializer

…

The install script will also:

  • add app/resources folder
  • add app/tools folder
  • add app/tools/sample_tool.rb
  • add app/resources/sample_resource.rb
  • add ApplicationTool to inherit from
  • add ApplicationResource to inherit from as well

Rails-friendly class naming conventions

For Rails applications, FastMCP provides Rails-style class names to better fit with Rails conventions:

  • ActionTool::Base - An alias for FastMcp::Tool
  • ActionResource::Base - An alias for FastMcp::Resource

These are automatically set up in Rails applications. You can use either naming convention in your code:

ruby
# Using Rails-style naming:
class MyTool < ActionTool::Base
  description "My awesome tool"

  arguments do
    required(:input).filled(:string)
  end

  def call(input:)
    # Your implementation
  end
end

# Using standard FastMcp naming:
class AnotherTool < FastMcp::Tool
  # Both styles work interchangeably in Rails apps
end

When creating new tools or resources, the generators will use the Rails naming convention by default:

ruby
# app/tools/application_tool.rb
class ApplicationTool < ActionTool::Base
  # Base methods for all tools
end

# app/resources/application_resource.rb
class ApplicationResource < ActionResource::Base
  # Base methods for all resources
end

Easy Sinatra setup

I'll let you check out the dedicated sinatra integration docs.

Quick Start

Create a Server with Tools and Resources and STDIO transport

…

Testing with the inspector

MCP has developed a very useful inspector. You can use it to validate your implementation. I suggest you use the examples I provided with this project as an easy boilerplate. Clone this project, then give it a go !

bash
npx @modelcontextprotocol/inspector examples/server_with_stdio_transport.rb

Or to test with an SSE transport using a rack middleware:

bash
npx @modelcontextprotocol/inspector examples/rack_middleware.rb

Or to test over SSE with an authenticated rack middleware:

bash
npx @modelcontextprotocol/inspector examples/authenticated_rack_middleware.rb

You can test your custom implementation with the official MCP inspector by using:

bash
# Test with a stdio transport:
npx @modelcontextprotocol/inspector path/to/your_ruby_file.rb

# Test with an HTTP / SSE server. In the UI select SSE and input your address.
npx @modelcontextprotocol/inspector

Sinatra

ruby
# app.rb
require 'sinatra'
require 'fast_mcp'

use FastMcp::RackMiddleware.new(name: 'my-ai-server', version: '1.0.0') do |server|
  # Register tools and resources here
  server.register_tool(SummarizeTool)
end

get '/' do
  'Hello World!'
end

Integrating with Claude Desktop

Add your server to your Claude Desktop configuration at:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
json
{
  "mcpServers": {
    "my-great-server": {
      "command": "ruby",
      "args": ["/Users/path/to/your/awesome/fast-mcp/server.rb"]
    }
  }
}

How to add a MCP server to Claude, Cursor, or other MCP clients?

Please refer to configuring_mcp_clients

Supported Specifications

Feature Status
✅ JSON-RPC 2.0 Full implementation for communication
✅ Tool Definition & Calling Define and call tools with rich argument types
✅ Resource & Resource Templates Management Create, read, update, and subscribe to resources
✅ Transport Options STDIO, HTTP, and SSE for flexible integration
✅ Framework Integration Rails, Sinatra, Hanami, and any Rack-compatible framework
✅ Authentication Secure your AI endpoints with token authentication
✅ Schema Support Full JSON Schema for tool arguments with validation

️ Use Cases

  • AI-powered Applications: Connect LLMs to your Ruby app's functionality
  • Real-time Dashboards: Build dashboards with live AI-generated insights
  • Microservice Communication: Use MCP as a clean protocol between services
  • Interactive Documentation: Create AI-enhanced API documentation
  • Chatbots and Assistants: Build AI assistants with access to your app's data

Security Features

Fast MCP includes built-in security features to protect your applications:

DNS Rebinding Protection

The HTTP/SSE transport validates the Origin header on all incoming connections to prevent DNS rebinding attacks, which could allow malicious websites to interact with local MCP servers.

ruby
# Configure allowed origins (defaults to ['localhost', '127.0.0.1'])
FastMcp.rack_middleware(app,
  allowed_origins: ['localhost', '127.0.0.1', 'your-domain.com', /.*\.your-domain\.com/],
  localhost_only: false,
  allowed_ips: ['192.168.1.1', '10.0.0.1'],
  # other options...
)

Authentication

Fast MCP supports token-based authentication for all connections:

ruby
# Enable authentication
FastMcp.authenticated_rack_middleware(app,
  auth_token: 'your-secret-token',
  # other options...
)

Documentation

  • Getting Started Guide
  • Integration Guide
  • ️ Rails Integration
  • Sinatra Integration
  • Resources
  • ️ Tools
  • Security
  • Dynamic Filtering

Examples

Check out the examples directory for more detailed examples:

  • ** Basic Examples**:

    • Simple Server
    • Tool Examples
  • ** Web Integration**:

    • Rack Middleware
    • Authenticated Endpoints

Requirements

  • Ruby 3.2+

Contributing

We welcome contributions to Fast MCP! Here's how you can help:

  1. Fork the repository
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Please read our Contributing Guide for more details.

License

This project is available as open source under the terms of the MIT License.

Acknowledgments

  • The Model Context Protocol team for creating the specification
  • The Dry-Schema team for the argument validation.
  • All contributors to this project

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rubyaillmmcprack

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
CategoryAI 编程
PricingOpen source

> Related tools

G
GitHub Copilot
GitHub 官方 AI 编程助手,覆盖补全、Chat 与 Agent 模式。
C
Cursor
AI 原生代码编辑器,对话改代码、多文件 Agent 与规则体系是其核心。
S
skills
Skills for Real Engineers. Straight from my .agents directory.