
一个用于 Rails 项目的 Ruby 宝石实现的模型上下文协议(MCP)服务器。该服务器允许大型语言模型(LLM)通过模型上下文与 Rails 项目交互。
概览
一个用于 Rails 项目的模型上下文协议(MCP)服务器的 Ruby 实现。该服务器允许大型语言模型(LLM)通过模型上下文协议与 Rails 项目交互,提供代码分析、探索和开发协助的能力。 模型上下文协议(MCP)是人工智能模型与环境交互的标准化方式。它定义了一种结构化的方法,用于模型请求和使用工具、访问资源以及在交互过程中保持上下文。 该 Rails MCP 服务器实现了 MCP 规范,使 AI 模型能够访问 Rails 项目,以便代码分析、探索和协助。
概述(AI 翻译)
一个用于 Rails 项目的模型上下文协议(MCP)服务器的 Ruby 实现。该服务器允许大型语言模型(LLM)通过模型上下文协议与 Rails 项目交互,提供代码分析、探索和开发协助的能力。
什么是MCP?
模型上下文协议(MCP)是人工智能模型与环境交互的标准化方式。它定义了一种结构化的方法,用于模型请求和使用工具、访问资源以及在交互过程中保持上下文。
该 Rails MCP 服务器实现了 MCP 规范,使 AI 模型能够访问 Rails 项目,以便代码分析、探索和协助。
特色
- 管理多个Rails项目
- 浏览项目文件和结构
- 查看带有筛选选项的Rails路线
- 检查模型信息和关系(配合棱镜静态分析)
- 获取数据库模式信息
- 分析控制器-视图关系
- 分析环境配置
- 访问全面的Rails、Turbo、Stimulus和Kamal文档
- 具备渐进式工具发现的上下文高效架构
- 与LLM客户端无缝集成
安装
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
Rails MCP Server
A Ruby implementation of a Model Context Protocol (MCP) server for Rails projects. This server allows LLMs (Large Language Models) to interact with Rails projects through the Model Context Protocol, providing capabilities for code analysis, exploration, and development assistance.
What is MCP?
The Model Context Protocol (MCP) is a standardized way for AI models to interact with their environment. It defines a structured method for models to request and use tools, access resources, and maintain context during interactions.
This Rails MCP Server implements the MCP specification to give AI models access to Rails projects for code analysis, exploration, and assistance.
Features
- Manage multiple Rails projects
- Browse project files and structures
- View Rails routes with filtering options
- Inspect model information and relationships (with Prism static analysis)
- Get database schema information
- Analyze controller-view relationships
- Analyze environment configurations
- Access comprehensive Rails, Turbo, Stimulus, and Kamal documentation
- Context-efficient architecture with progressive tool discovery
- Seamless integration with LLM clients
Installation
Install the gem:
gem install rails-mcp-server
After installation, the following executables will be available in your PATH:
rails-mcp-server- The MCP server itselfrails-mcp-config- Interactive configuration tool (recommended)rails-mcp-setup-claude- Legacy Claude Desktop setup scriptrails-mcp-server-download-resources- Legacy resource download script
Configuration
Using the Configuration Tool (Recommended)
The easiest way to configure the Rails MCP Server is using the interactive configuration tool:
rails-mcp-config
This provides a user-friendly TUI (Terminal User Interface) for:
- Managing Projects: Add, edit, remove, and validate Rails projects
- Downloading Guides: Download Rails, Turbo, Stimulus, and Kamal documentation
- Importing Custom Guides: Add your own markdown documentation
- Claude Desktop Integration: Automatically configure Claude Desktop
The tool uses Gum for an enhanced experience if installed, but works with a basic terminal fallback.
# Install Gum for best experience (optional)
brew install gum # macOS
sudo apt install gum # Debian/Ubuntu
yay -S gum # Arch Linux
Manual Configuration
The Rails MCP Server follows the XDG Base Directory Specification for configuration files:
- On macOS:
$XDG_CONFIG_HOME/rails-mcpor~/.config/rails-mcpif XDG_CONFIG_HOME is not set - On Windows:
%APPDATA%\rails-mcp
The server will automatically create these directories and an empty projects.yml file the first time it runs.
To configure your projects manually:
- Edit the
projects.ymlfile in your config directory to include your Rails projects:
store: "~/projects/store"
安装
npx mcp-remote http://localhost:6029/mcp/sse配置
{
"mcpServers": {
"railsMcpServer": {
"command": "ruby",
"args": ["/full/path/to/rails-mcp-server/exe/rails-mcp-server"]
}
}
}