A Ruby gem that adds Model Context Protocol (MCP) server capabilities to Rails applications, exposing comprehensive Rails introspection methods through a standardized MCP interface. This enables AI assistants to understand and interact with Rails application structure, models, routes, database schema, and configuration.
- Complete Rails Introspection: Models, routes, controllers, database schema, gems, and configuration
- MCP Protocol Compliance: Full support for MCP 2025-06-18 specification
- Multiple Transport Options: stdio and HTTP transports
- Security First: Configurable access controls, data filtering, and audit logging
- Development Friendly: Easy integration with existing Rails applications
- AI Assistant Ready: Works with Claude Desktop, VSCode, Cursor, WindSurf, and other MCP clients
Add this line to your Rails application's Gemfile:
gem 'rails-introspec-mcp', group: [:development, :test]And then execute:
$ bundle installOr install it yourself as:
$ gem install rails-introspec-mcp$ rails generate rails_introspec_mcp:installThis creates config/initializers/rails_introspec_mcp.rb with default configuration.
# config/initializers/rails_introspec_mcp.rb
RailsIntrospecMcp.configure do |config|
# Enable/disable MCP server
config.enabled = Rails.env.development?
# Server configuration
config.transport = :stdio # or :http
config.port = 3001 # for HTTP transport
# Security settings
config.allowed_environments = [:development, :test]
config.filter_secrets = true
config.mask_credentials = true
# Feature toggles
config.enable_models = true
config.enable_routes = true
config.enable_database = true
end$ rails-introspec-mcp-server --rails-app /path/to/your/rails/app$ rails server # MCP server runs alongside RailsThe gem provides comprehensive introspection tools:
list_models- List all ActiveRecord modelsdescribe_model- Get detailed model informationmodel_associations- Get model associations and relationshipsmodel_attributes- Get model attributes and typesmodel_validations- Get model validationsmodel_callbacks- Get model callbacks
list_routes- List all application routesfind_route- Find routes by pattern or nameroute_details- Get detailed route informationcontroller_routes- Get routes for specific controllernamed_routes- Get named routes and helpers
list_tables- List database tablestable_schema- Get table schema and columnstable_indexes- Get table indexesmigration_status- Get migration statusdatabase_config- Get database configurationforeign_keys- Get foreign key relationships
- Application structure and configuration
- Gem dependencies and versions
- Controller actions and filters
- And more...
- Add to your Claude Desktop configuration (
~/Library/Application Support/Claude/claude_desktop_config.jsonon macOS):
{
"mcpServers": {
"rails-introspec": {
"command": "rails-introspec-mcp-server",
"args": ["--rails-app", "/path/to/your/rails/app"],
"env": {
"RAILS_ENV": "development"
}
}
}
}- Restart Claude Desktop
- Start chatting with Claude about your Rails application!
- Install the MCP extension for VSCode
- Add server configuration to VSCode settings:
{
"mcp.servers": [
{
"name": "rails-introspec",
"command": "rails-introspec-mcp-server",
"args": ["--rails-app", "/path/to/your/rails/app"],
"transport": "stdio"
}
]
}- Open Cursor settings
- Navigate to MCP Servers section
- Add new server:
- Name:
rails-introspec - Command:
rails-introspec-mcp-server - Args:
["--rails-app", "/path/to/your/rails/app"]
- Name:
- Open WindSurf preferences
- Go to Extensions → MCP
- Add server configuration:
servers:
rails-introspec:
command: rails-introspec-mcp-server
args:
- --rails-app
- /path/to/your/rails/app
transport: stdioRailsIntrospecMcp.configure do |config|
# Basic settings
config.enabled = true
config.transport = :stdio # :stdio or :http
config.port = 3001
# Security
config.allowed_environments = [:development, :test]
config.require_authentication = false
config.auth_token = ENV['MCP_AUTH_TOKEN']
config.allowed_ips = ['127.0.0.1', '::1']
# Features
config.enable_models = true
config.enable_routes = true
config.enable_controllers = true
config.enable_database = true
config.enable_gems = true
config.enable_configuration = true
config.enable_application = true
# Data filtering
config.filter_secrets = true
config.mask_credentials = true
config.anonymize_user_data = false
# Performance
config.max_results_per_query = 1000
config.timeout_seconds = 30
# Logging
config.audit_logging = true
config.log_level = :info
endThis gem provides powerful introspection capabilities that could expose sensitive information. Please consider:
- Environment Restrictions: Only enable in development/test environments
- Access Control: Use authentication tokens and IP restrictions
- Data Filtering: Enable secret filtering and credential masking
- Audit Logging: Monitor tool usage and access patterns
- Network Security: Use stdio transport or secure HTTP endpoints
After checking out the repo, run:
$ bin/setup
$ bundle install
$ bundle exec rspec
$ bundle exec cucumberTo install this gem onto your local machine:
$ bundle exec rake installTo release a new version:
$ bundle exec rake releaseThe gem includes comprehensive test coverage:
# Run RSpec tests
$ bundle exec rspec
# Run Cucumber features
$ bundle exec cucumber
# Run all tests with coverage
$ bundle exec rake test:allBug reports and pull requests are welcome on GitHub at https://github.com/rails-introspec-mcp/rails-introspec-mcp.
- Fork the repository
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
The gem is available as open source under the terms of the MIT License.
See CHANGELOG.md for version history and changes.
- GitHub Issues: https://github.com/rails-introspec-mcp/rails-introspec-mcp/issues
- Documentation: https://github.com/rails-introspec-mcp/rails-introspec-mcp/wiki
- Discussions: https://github.com/rails-introspec-mcp/rails-introspec-mcp/discussions