
tonksthebear/mcp-rails
Developer toolsこのページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る
mcp-rails は、mcp-rb ライブラリの上部にある Ruby on Rails の gem で、MCP (Model Context Protocol) サーバを Rails アプリケーションにシームレスに統合します.
概要
mcp-rails は、mcp-rb ライブラリの上部にある Ruby on Rails の gem で、MCP (Model Context Protocol) サーバを Rails アプリケーションにシームレスに統合します。 MCP 固有のメタデータでタグ付けして、LLM エージェントの有効な Ruby MCP サーバー (tmp/mcp/server.rb) を、Goose などの LLM エージェントが接続できるようにすることで、Rails のルートを強化します。 さらに、MCPサーバーの設定とRailsの強力なパラメーターの執行と2倍のコントローラーで強力なパラメータを定義し、管理する強力な方法を提供します。 ガグルの制作に触発されました。 - : タグ・レールは、mcp: true または特定のアクション (例: mcp: [:index, :create]) で行い、MCP サーバーにそれらを露出します。 - : LLM エージェントの tmp/mcp/server.rb で Ruby MCP サーバーを生成し、アプリケーションとやり取りします。 - : MCP サーバーの生成とRailsの強力なパラメーターの両方に使用できる、豊富なメタデータ(タイプ、例、必須フラグ)を持つコントローラーで許可されたパラメーターを定義します.
概要(AI 翻訳)
MCP(Model Context Protocol)の統合でLMエージェントのEnhance Railsのルーティングとパラメーター処理を行います。
[mcp-rails は、mcp-rb ライブラリの上部にある Ruby で、MCP (Model Context Protocol) サーバーを Rails アプリケーションにシームレスに統合します。 MCP 固有のメタデータをタグ付けし、Goose などの LLM エージェントが接続できる有効な Ruby MCP サーバー (tmp/mcp/server.rb) を生成することで、Rails のルートを強化します。 さらに、MCPサーバーの設定とRailsの強力なパラメーターの執行と2倍のコントローラーで強力なパラメータを定義し、管理する強力な方法を提供します。
ガグルの制作に触発されました。
お問い合わせ
##特徴
-Tagged Routes:タグレールは[mcp: true]]または特定のアクション([mcp: [:index, :create]])で、MCPサーバーにそれらを露出します。
- 自動 MCP サーバー生成:LLM エージェントがアプリケーションとやり取りするために
tmp/mcp/server.rbで Ruby MCP サーバーを生成します。 -Parameterの定義:豊富なメタデータを持つコントローラーで許可されたパラメーターを定義します(例:.
このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。
README
以下は原文 README の抜粋です。原文を見る。
MCP-Rails
Enhance Rails routing and parameter handling for LLM agents with MCP (Model Context Protocol) integration.
mcp-rails is a Ruby on Rails gem that builds on top of the mcp-rb library to seamlessly integrate MCP (Model Context Protocol) servers into your Rails application. It enhances Rails routes by allowing you to tag them with MCP-specific metadata and generates a valid Ruby MCP server (in tmp/mcp/server.rb) that LLM agents, such as Goose, can connect to. Additionally, it provides a powerful way to define and manage strong parameters in your controllers, which doubles as both MCP server configuration and Rails strong parameter enforcement.
This was inspired during the creation of Gaggle.
Features
- Tagged Routes: Tag Rails routes with
mcp: trueor specific actions (e.g.,mcp: [:index, :create]) to expose them to an MCP server. - Automatic MCP Server Generation: Generates a Ruby MCP server in
tmp/mcp/server.rbfor LLM agents to interact with your application. - Parameter Definition: Define permitted parameters in controllers with rich metadata (e.g., types, examples, required flags) that are used for both MCP server generation and Rails strong parameters.
- HTTP Bridge for LLM Agents: Generates a ruby based MCP server to interact with your application through HTTP requests, ensuring LLM agents follow the same paths as human users.
- Environment Variable Integration: Automatically includes specified environment variables in MCP tool calls.
Installation
Add this line to your application’s Gemfile:
gem 'mcp-rails'
Then run:
bundle install
Ensure you also have the mcp-rb gem installed, as mcp-rails depends on it:
gem 'mcp-rb'
Configuration
MCP-Rails can be configured in an initializer file. Create config/initializers/mcp_rails.rb:
MCP::Rails.configure do |config|
# Server Configuration
config.server_name = "my-app-server" # Default: 'mcp-server'
config.server_version = "2.0.0" # Default: '1.0.0'
# Output Configuration
config.output_directory = Rails.root.join("tmp/mcp") # Default: Rails.root.join('tmp', 'mcp')
config.bypass_key_path = Rails.root.join("tmp/mcp/bypass_key.txt") # Default: Rails.root.join('tmp', 'mcp', 'bypass_key.txt')
# Environment Variables
config.env_vars = ["API_KEY", "ORGANIZATION_ID"] # Default: ['API_KEY', 'ORGANIZATION_ID']
# Base URL Configuration
config.base_url = "http://localhost:3000" # Default: Uses action_mailer.default_url_options
end
If you are an engine developer, you can register your engine’s configuration with MCP-Rails:
MCP::Rails.configure do |config|
config.register_engine(YourEngine, env_vars: ["YOUR_ENGINE_KEY"])
end
Environment Variables
インストール
This server does not publish a one-line install command.
Open the repository installation guide MCP 初心者?mcpskill.org のガイドから始めましょう →