NM

nagstler/mcp_on_ruby

Developer tools

Эта страница переведена автоматически. Технические детали смотрите в оригинале. Открыть оригинал

96 stars 9 forks Качество 85 Тренд 14MIT

nagstler/mcp_on_ruby — это кандидат на сервер MCP, импортированный из https://github.com/nagstler/mcp_on_ruby.

Обзор

nagstler/mcp_on_ruby — это кандидат на сервер MCP, импортированный из https://github.com/nagstler/mcp_on_ruby.

Обзор (машинный перевод)

Сервер Model Context Protocol (MCP) для приложений Rails

Покажите своё приложение Rails как интерфейс, доступный для ИИ — определите инструменты и ресурсы в стиле Rails.


Особенности

🚀 Готово к производству - Аутентификация, ограничение скорости, обработка ошибок, безопасность 🔧 Интеграция рельсов — генераторы, автозагрузка, промежуточное программное обеспечение, Railtie 🛠️ Tools System - Вызываемые функции с проверкой JSON Schema 📊 Система ресурсов - Экспозиция данных с использованием URI-шаблонирования 🔒 Безопасность — защита от пересвязывания DNS, CORS, аутентификация токенов ⚡ В реальном времени - основа Server Events (SSE) (полная реализация скоро появится) 🎯 Дружелюбно для разработчиков - Чистый DSL, генераторы, поддержка тестирования

Установка

Добавьте к своему Gemfile:

Затем беги:

Быстрый старт

1. Установка и настройка

2. Настройка MCP Server

3. Создавайте инструменты

4. Создавайте ресурсы

5. Запустите свой сервер

Архитектура

Примеры

Подключите ваш MCP-сервер Rails с разными AI-клиентами:

👉 Claude Desktop — полное руководство по настройке с скриптом моста

👉 MCP-регистры и управляющие плоскости - Регистрировать конечную точку MCP Rails с

Эта страница переведена автоматически. Технические детали смотрите в оригинале.

README

Показан фрагмент оригинального README. Открыть оригинал.


class OrdersController < ApplicationController
  before_action :authenticate_user!

  mcp_tool :index, description: "Search the current user's orders",
                   params: { status: { type: :string, enum: %w[pending paid shipped] } }
  mcp_tool :show,  description: "Fetch one order by id"

  def index
    render json: current_user.orders.where(params.permit(:status))
  end

  def show
    render json: current_user.orders.find(params[:id])
  end
end

That’s the whole integration. Claude, Cursor, or any MCP client can now search and read orders as the signed-in user. Your before_action authenticates the agent, your scopes and policies decide what it can see, and your existing JSON comes back to it. You don’t write new tool classes or a second permission system.

Why MCP on Ruby

Most MCP libraries ask you to build a parallel API for agents: new tool classes, new argument parsing, new authorization checks. Over time that second API drifts from the real one, and every rule has to be secured twice.

MCP on Ruby takes the opposite approach. Your app already has an API: your controllers. MCP on Ruby makes it callable by agents.

  • One source of truth. Agents go through the same routes, filters, policies, validations, and serializers as your users.
  • Real identity. Every tool call runs as a real user, using the auth you already have: API tokens, Devise, or Warden.
  • Safe by default. Actions that change data must be marked write: true, and every tool tells the client whether it is read-only or destructive.
  • Local and remote. Serve Streamable HTTP in production, and stdio for Claude Code, Claude Desktop, and Cursor on your machine.
Открыть полный README на GitHub

Установка

npx @modelcontextprotocol/inspector bin/rails mcp:stdio
Новичок в MCP? Начните с руководства на mcpskill.org →

Конфигурация

{ "mcpServers": { "my-app": { "command": "/Users/you/.rbenv/versions/3.4.7/bin/ruby", "args": ["-C", "/path/to/my-app", "bin/rails", "mcp:stdio"], "env": { "MCP_USER": "[email protected]" } } } }