rails-mcp-server

alkevintan/rails-mcp-server

3.1

If you are the rightful owner of rails-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

This template provides a robust foundation for creating Model Context Protocol (MCP) servers, specifically designed for UI libraries and component registries.

Tools
3
Resources
0
Prompts
0

Rails Guides MCP Server

A Model Context Protocol (MCP) server that provides access to Ruby on Rails documentation and guides. This server allows AI assistants like Claude to access, search, and reference Rails Guides content programmatically, making it easier to get Rails development help and documentation.

🚀 Features

  • Complete Rails Guides access - All official Rails documentation categories
  • Version support - Support for multiple Rails versions (8.0, 7.1, 4.2, etc.)
  • Categorized organization - Guides organized by topic (Models, Views, Controllers, etc.)
  • Dynamic version switching - Environment variable support for different Rails versions
  • TypeScript implementation with Zod schema validation
  • Development tools including hot reload and inspector
  • Ready for Claude integration with simple setup commands

📋 Prerequisites

  • Node.js 18 or higher
  • npm, yarn, or pnpm
  • Claude desktop app (for integration)

🤝 Intended Use Cases

This MCP server is perfect for:

  • Rails developers seeking quick access to official documentation
  • AI-assisted Rails development with Claude or other MCP-compatible tools
  • Learning Rails with contextual documentation access
  • Code review and debugging with instant access to Rails conventions
  • Teams wanting consistent Rails documentation access across projects

🚀 Quick Start with Claude

Option 1: Add to Claude Project (Recommended)

# Navigate to your Rails project directory
cd your-rails-project

# Add the Rails Guides MCP server to your project
claude mcp add rails-guides npx rails-mcp-server

# For specific Rails version
claude mcp add rails-guides npx rails-mcp-server -e RAILS_VERSION=7.1

Option 2: Add Globally

# Add globally for all Claude sessions
claude mcp add rails-guides npx rails-mcp-server --scope user

# With specific Rails version
claude mcp add rails-guides npx rails-mcp-server --scope user -e RAILS_VERSION=7.1

Option 3: Add Locally

# Add for local Claude sessions only
claude mcp add rails-guides npx rails-mcp-server --scope local

🔧 Rails Version Support

The server defaults to Rails 8.0 documentation but supports multiple versions:

Supported Versions

  • Rails 8.0 (default) - https://guides.rubyonrails.org
  • Rails 7.1 - https://guides.rubyonrails.org/v7.1
  • Rails 4.2 - https://guides.rubyonrails.org/v4.2
  • Other versions - Follow the pattern v{major}.{minor}

Setting Rails Version

Use the RAILS_VERSION environment variable:

# Default (Rails 8.0)
claude mcp add rails-guides npx rails-mcp-server

# Rails 7.1
claude mcp add rails-guides npx rails-mcp-server -e RAILS_VERSION=7.1

# Rails 4.2
claude mcp add rails-guides npx rails-mcp-server -e RAILS_VERSION=4.2

# Rails 6.0
claude mcp add rails-guides npx rails-mcp-server -e RAILS_VERSION=6.0

Alternative Environment Variable

You can also use RAILS_GUIDES_VERSION:

claude mcp add rails-guides npx rails-mcp-server -e RAILS_GUIDES_VERSION=7.1

🛠️ Manual Installation (Development)

If you want to modify or contribute to this server:

  1. Clone the repository:
git clone https://github.com/your-username/rails-mcp-server.git
cd rails-mcp-server
  1. Install dependencies:
npm install
  1. Build the project:
npm run build
  1. Test locally:
node dist/server.js

🏃‍♂️ Development

Start Development Server

npm run dev

Build for Production

npm run build

Inspect MCP Server

npm run inspect

This opens the MCP Inspector to test your server tools interactively.

📚 Available Tools

The Rails Guides MCP server provides the following tools:

Core Tools

  • getRailsGuides - Returns a comprehensive list of all Rails Guides with categories and metadata
  • getGuideRegistry - Complete registry with all guides, categories, and version info
  • getGuideContent - Fetches the full HTML content of a specific Rails Guide

Category-specific Tools

Dynamic tools are created for each Rails Guide category:

  • getStartHereGuides - Getting Started, Installation guides
  • getModelsGuides - Active Record, Migrations, Validations, Associations, etc.
  • getViewsGuides - Action View, Layouts, Helpers, Form Helpers
  • getControllersGuides - Action Controller, Routing, Advanced Topics
  • getOtherComponentsGuides - Active Support, Action Mailer, Active Job, etc.
  • getDiggingDeeperGuides - I18n, Testing, Debugging, Configuration, etc.
  • getGoingToProductionGuides - Caching, Security, Performance
  • getAdvancedActiveRecordGuides - PostgreSQL, Multiple DBs, Encryption
  • getExtendingRailsGuides - Plugins, Rack, Generators, Engines
  • getContributingGuides - Contributing, API docs, Development setup

Example Usage

Once added to Claude, you can ask questions like:

  • "Show me the Rails guides for Models"
  • "Get the Getting Started guide content"
  • "What Rails guides are available for testing?"
  • "Fetch the Active Record associations guide"

🏗️ Project Structure

rails-mcp-server/
├── src/
│   ├── server.ts              # Main Rails Guides MCP server
│   ├── lib/
│   │   ├── config.ts          # Configuration with version support
│   │   └── categories.ts      # Rails Guides categories
│   └── utils/
│       ├── api.ts             # Rails Guides fetching utilities
│       ├── formatters.ts      # Data formatting helpers
│       ├── schemas.ts         # Zod validation schemas
│       └── index.ts           # Utility exports
├── dist/                      # Built files
├── package.json
└── README.md

🔧 Customization

Adding New Rails Guide Categories

To add new guide categories, update src/lib/categories.ts:

export const guideCategories = {
  // Existing categories...
  "Custom Category": [
    "custom_guide_1",
    "custom_guide_2", 
  ],
};

The server will automatically create category-specific tools.

Supporting Different Rails Versions

The server automatically handles different Rails versions through URL patterns:

  • Rails 8.0+: https://guides.rubyonrails.org/{guide}.html
  • Older versions: https://guides.rubyonrails.org/v{version}/{guide}.html

Customizing Guide Processing

Modify src/utils/api.ts to customize how guides are processed:

export async function fetchGuideDetails(guideName: string) {
  // Add custom processing logic
  // Parse HTML sections, extract code examples, etc.
}

🚀 Deployment

Publishing as NPM Package

To make this server available via npx, publish it to npm:

  1. Update package.json with your details:
{
  "name": "rails-mcp-server",
  "version": "1.0.0",
  "description": "MCP server for Rails Guides documentation",
  "bin": {
    "rails-mcp-server": "./dist/server.js"
  }
}
  1. Build and publish:
npm run build
npm publish
  1. Then users can add it with:
claude mcp add rails-guides npx rails-mcp-server

Manual Installation

For development or custom deployments:

# Clone and build
git clone https://github.com/your-username/rails-mcp-server.git
cd rails-mcp-server
npm install && npm run build

# Add to Claude with local path
claude mcp add rails-guides node /path/to/rails-mcp-server/dist/server.js

🤝 Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes and add tests if applicable
  4. Commit your changes: git commit -m 'feat: add amazing feature'
  5. Push to the branch: git push origin feature/amazing-feature
  6. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the file for details.

🙏 Acknowledgments

📞 Support


✨ Happy Rails development with AI assistance!