maquina_app_rails_mcp_server

maquina_app_rails_mcp_server

by maquina-app
A Ruby gem implementation of a Model Context Protocol (MCP) server that enables LLMs to interact with Rails projects.

Rails MCP Server for Large Language Models

Overview

The Rails MCP Server is a Ruby gem implementation of a Model Context Protocol (MCP) server designed for Rails projects. It enables Large Language Models (LLMs) to interact with Rails applications through the Model Context Protocol, facilitating code analysis, exploration, and assistance.

What is MCP?

The Model Context Protocol (MCP) is a standardized method for AI models to interact with their environment. It allows models to request tools, access resources, and maintain context during interactions. This Rails MCP Server implements the MCP specification to provide AI models with access to Rails projects.

Features

  • Manage multiple Rails projects
  • Browse project files and structures
  • View Rails routes
  • Inspect model information
  • Get database schema information
  • Follow the Model Context Protocol standard

Installation

Install the gem using the following command:

gem install rails-mcp-server

After installation, the rails-mcp-server and rails-mcp-setup-claude executables will be available in your PATH.

Configuration

The Rails MCP Server follows the XDG Base Directory Specification for configuration files:
- macOS: $XDG_CONFIG_HOME/rails-mcp or ~/.config/rails-mcp if XDG_CONFIG_HOME is not set
- Windows: %APPDATA%\rails-mcp

To configure your projects, edit the projects.yml file in your config directory:

store: "~/projects/store"
blog: "~/projects/rails-blog"

Claude Desktop Integration

The Rails MCP Server can be integrated with Claude Desktop. There are two setup options:

Option 1: Use the Setup Script (Recommended)

Run the setup script to automatically configure Claude Desktop:

rails-mcp-setup-claude

Option 2: Manual Configuration

  1. Create the appropriate config directory.
  2. Create a projects.yml file.
  3. Update the Claude Desktop configuration file with the MCP server details:
{
  "mcpServers": {
    "railsMcpServer": {
      "command": "ruby",
      "args": ["/full/path/to/rails-mcp-server/exe/rails-mcp-server"] 
    }
  }
}

Ruby Version Manager Users

For users of Ruby version managers like rbenv or RVM, create a symbolic link to ensure the correct Ruby version is used:

sudo ln -s /home/your_user/.rbenv/shims/ruby /usr/local/bin/ruby

Usage

Start the server with:

rails-mcp-server

Logging Options

Customize logging with the following options:

rails-mcp-server --log-level debug

How the Server Works

The Rails MCP Server implements the Model Context Protocol over standard input/output (stdio). It reads JSON-RPC 2.0 requests, processes them using the appropriate tools, and returns JSON-RPC 2.0 responses.

Available Tools

The server provides the following tools for interacting with Rails projects:

1. switch_project

Switch the active Rails project.

{
  "jsonrpc": "2.0",
  "id": "123",
  "method": "tools/call",
  "params": {
    "name": "switch_project",
    "arguments": {
      "project_name": "blog"
    }
  }
}

2. get_project_info

Get information about the current Rails project.

{
  "jsonrpc": "2.0",
  "id": "124",
  "method": "tools/call",
  "params": {
    "name": "get_project_info",
    "arguments": {}
  }
}

3. list_files

List files in the Rails project.

{
  "jsonrpc": "2.0",
  "id": "125",
  "method": "tools/call",
  "params": {
    "name": "list_files",
    "arguments": {
      "directory": "app/models",
      "pattern": "*.rb"
    }
  }
}

4. get_file

Get the content of a file in the Rails project.

{
  "jsonrpc": "2.0",
  "id": "126",
  "method": "tools/call",
  "params": {
    "name": "get_file",
    "arguments": {
      "path": "app/models/user.rb"
    }
  }
}

5. get_routes

Get the routes defined in the Rails project.

{
  "jsonrpc": "2.0",
  "id": "127",
  "method": "tools/call",
  "params": {
    "name": "get_routes",
    "arguments": {}
  }
}

6. get_models

Get information about the models in the Rails project.

{
  "jsonrpc": "2.0",
  "id": "128",
  "method": "tools/call",
  "params": {
    "name": "get_models",
    "arguments": {
      "model_name": "User"
    }
  }
}

7. get_schema

Get the database schema for the Rails project.

{
  "jsonrpc": "2.0",
  "id": "129",
  "method": "tools/call",
  "params": {
    "name": "get_schema",
    "arguments": {
      "table_name": "users"
    }
  }
}

Integration with LLM Clients

The Rails MCP Server is designed to integrate with LLM clients that support the Model Context Protocol, such as Claude Desktop or other MCP-compatible applications.

Manual Testing

You can manually test the server by sending JSON-RPC requests to its standard input:

echo '0 {"jsonrpc":"2.0","id":"test-123","method":"ping"}' | rails-mcp-server

License

This Rails MCP Server is released under the MIT License.

Contributing

Bug reports and pull requests are welcome on GitHub.

About

A Ruby gem implementation of a Model Context Protocol (MCP) server for Rails projects. This server allows LLMs to interact with Rails projects through the Model Context Protocol.

Features & Capabilities

Categories
mcp_server model_context_protocol ruby rails llm api_integration code_analysis

Implementation Details

Stats

0 Views
62 GitHub Stars

Repository Info

maquina-app Organization

Similar MCP Servers

continuedev_continue by continuedev
25049
21423
9300