- Explore MCP Servers
- mcp_rails_template
Mcp Rails Template
What is Mcp Rails Template
mcp_rails_template is a minimal Ruby on Rails API template designed for creating MCP (Model Context Protocol) servers, featuring robust tool execution capabilities.
Use cases
Use cases for mcp_rails_template include developing APIs that leverage the Model Context Protocol for various applications, such as data processing, web services, and microservices architecture.
How to use
To use mcp_rails_template, clone the repository, set up the environment by copying and editing the .env file, configure the PostgreSQL database, and then run the Rails server to start the application.
Key features
Key features include a simple setup process, integration with ActionMCP for tool execution, and the ability to lint Ruby code using RuboCop.
Where to use
undefined
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Overview
What is Mcp Rails Template
mcp_rails_template is a minimal Ruby on Rails API template designed for creating MCP (Model Context Protocol) servers, featuring robust tool execution capabilities.
Use cases
Use cases for mcp_rails_template include developing APIs that leverage the Model Context Protocol for various applications, such as data processing, web services, and microservices architecture.
How to use
To use mcp_rails_template, clone the repository, set up the environment by copying and editing the .env file, configure the PostgreSQL database, and then run the Rails server to start the application.
Key features
Key features include a simple setup process, integration with ActionMCP for tool execution, and the ability to lint Ruby code using RuboCop.
Where to use
undefined
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Content
Action MCP Example 🚀
A simple Ruby on Rails application demonstrating how to integrate and use the ActionMCP gem. The gem source code can be found on GitHub at https://github.com/seuros/action_mcp.
This application showcases how to define and use MCP components within a Rails project.
Requirements
- Ruby (see
.ruby-versionfor recommended version) - PostgreSQL (or Docker)
Getting Started
1. Clone and Setup
git clone https://github.com/seuros/mcp_rails_template.git
cd mcp_rails_template
bin/setup
2. Environment Configuration
Copy the provided .env.example file:
cp .env.example .env
Edit .env and fill in necessary values according to your setup (especially any required API keys for tools like fetch_weather_by_location_tool).
3. Database Setup
You can quickly spin up a temporary PostgreSQL instance using Docker:
make up
This will start PostgreSQL on port 5466.
Alternatively, configure your own PostgreSQL database by editing config/database.yml.
4. Run the Application
Launch the Rails server:
bin/rails s
The app will be available at http://localhost:3002.
ActionMCP Engine
The ActionMCP engine is mounted at /action_mcp. Feel free to mount it at a custom location by modifying the routes in your application.
MCP Components (app/mcp/)
This application includes several examples of ActionMCP components:
Prompts (app/mcp/prompts/)
epic_adventure_prompt.rb: Generates a short, narrative adventure story based on a provided hero name and adventure type (fantasy, sci-fi, mystery). It can optionally include a placeholder image data string.
Resource Templates (app/mcp/resource_templates/)
gemfile_template.rb: Provides access to the project’s Gemfile dependencies as a JSON resource. It uses Bundler to fetch gems based on the specified environment (production,test,development, ordefault). The resource URI follows the patterngemfile://{environment}.
Tools (app/mcp/tools/)
Tools define specific actions that a language model can request to be executed.
dependency_info_tool.rb: Retrieves dependency information using Bundler from theGemfileandGemfile.lock. It also checks for a.gemspecfile for runtime dependencies. It outputs separate JSON resources forproduction,test, andruntimedependencies.fetch_weather_by_location_tool.rb: Fetches weather forecast data from the Open-Meteo API (https://api.open-meteo.com) based on provided latitude and longitude coordinates. It returns the raw JSON response from the API.rubocop_tool.rb: Analyzes a provided Ruby code snippet using the RuboCop gem’s API. It reports any detected style or code quality offenses, including the rule name, message, line, and column number.ruby_code_analyzer_tool.rb: Performs basic static analysis of Ruby code within the project directory. It indexes classes, modules, and methods by parsing.rbfiles. It can be queried to list all found classes, modules, or methods, or to get details (including source snippets) for a specific class/module (constant) or method (method_details).
Usage
To test and inspect MCP functionality interactively, you can use the MCP Inspector:
npx @modelcontextprotocol/inspector --url http://localhost:3002/action_mcp
Make sure your Rails server (bin/rails s) is running before executing the inspector command.
Contributing
Feel free to contribute! Open issues or submit pull requests to help improve this example.
Happy Coding! ✨🚀
Dev Tools Supporting MCP
The following are the main code editors that support the Model Context Protocol. Click the link to visit the official website for more information.










