MCP on Rails
MCP on Rails provides pre-configured Model Context Protocol (MCP) settings, specialized prompts, and templates for Rails development with AI assistants like Claude, GitHub Copilot, and other MCP-compatible tools.
🙏 Acknowledgments: This project is inspired by and adapted from claude-on-rails by Obie Fernandez. The original prompts and swarm configuration have been restructured for broader MCP compatibility.
Features
- 🧠 Specialized AI Prompts - Context-aware prompts for different Rails components (models, controllers, views, etc.)
- ⚙️ MCP Configuration - Ready-to-use MCP server configuration for Rails projects
- 🚀 Quick Setup - One command to set up AI assistance for your Rails project
- 🔧 Customizable - Templates that adapt to your project structure
- 📚 Best Practices - Built-in Rails conventions and best practices
Installation
Add this line to your application's Gemfile:
gem 'mcp-on-rails'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install mcp-on-rails
Usage
Quick Setup
In your Rails project directory, run:
$ mcp-on-rails
This will create:
-
.mcp-on-rails/
directory with configuration and prompts -
bin/mcp-setup
executable for project-specific setup - MCP configuration file optimized for Rails development
Manual Setup
You can also set up programmatically:
require 'mcp/on/rails'
Mcp::On::Rails.setup(
project_name: "MyRailsApp",
project_path: "/path/to/rails/project"
)
What Gets Created
your-rails-project/
├── .mcp-on-rails/
│ ├── mcp-config.yml # MCP server configuration
│ ├── context.md # Project context for AI
│ └── prompts/ # Specialized prompts for each area
│ ├── architect.md # Overall architecture guidance
│ ├── models.md # ActiveRecord and database
│ ├── controllers.md # HTTP handling and routing
│ ├── views.md # Templates and frontend
│ ├── stimulus.md # JavaScript and Turbo
│ ├── jobs.md # Background processing
│ ├── tests.md # Testing strategies
│ └── devops.md # Deployment and infrastructure
└── bin/
└── mcp-setup # Project setup script
Using with AI Assistants
GitHub Copilot (VS Code)
GitHub Copilot doesn't directly read MCP configuration files, but you can leverage the specialized prompts by:
-
Reference prompts in your requests:
"Please check .mcp-on-rails/prompts/models.md for Rails model best practices and help me with this ActiveRecord model"
-
Use context-aware requests:
"Looking at .mcp-on-rails/prompts/controllers.md, help me implement this API endpoint"
-
Add to VS Code workspace settings (optional):
{ "files.associations": { ".mcp-on-rails/**/*.md": "markdown" }, "explorer.fileNesting.patterns": { ".mcp-on-rails": "mcp-config.yml,context.md" } }
Claude Desktop (Native MCP Support)
Add to your Claude Desktop configuration:
{
"mcpServers": {
"rails": {
"command": "rails-mcp-server",
"env": {
"RAILS_ENV": "development"
}
}
}
}
Other AI Assistants
For any AI assistant, you can reference the specialized prompts manually:
- Models: "Use .mcp-on-rails/prompts/models.md as context"
- Controllers: "Reference .mcp-on-rails/prompts/controllers.md"
- Views: "Check .mcp-on-rails/prompts/views.md for guidance"
- Tests: "Follow .mcp-on-rails/prompts/tests.md best practices"
Context Areas
MCP on Rails organizes your Rails project into specialized context areas:
- Architect - Overall project coordination and architecture decisions
- Models - ActiveRecord models, migrations, database design
- Controllers - HTTP handling, routing, authentication, APIs
- Views - Templates, layouts, partials, frontend components
- Stimulus - JavaScript behavior, Turbo integration
- Jobs - Background processing, queues, scheduled tasks
- Tests - Testing strategies, factories, test coverage
- DevOps - Deployment, infrastructure, environment configuration
Each area includes specialized prompts that help AI assistants understand the context and provide more relevant suggestions.
Customization
After running the setup, you can customize:
-
Project-specific prompts - Edit files in
.mcp-on-rails/prompts/
-
MCP configuration - Modify
.mcp-on-rails/mcp-config.yml
-
Context information - Update
.mcp-on-rails/context.md
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run rake test
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and the created tag, and push the .gem
file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/GoCoder7/mcp-on-rails.
License
The gem is available as open source under the terms of the MIT License.