Cover image
Try Now
2025-03-28

一个最小的导轨API模板,用于创建具有强大的工具执行功能和示例的MCP(模型上下文协议)服务器。

3 years

Works with Finder

2

Github Watches

5

Github Forks

28

Github Stars

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-version for 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, or default). The resource URI follows the pattern gemfile://{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 the Gemfile and Gemfile.lock. It also checks for a .gemspec file for runtime dependencies. It outputs separate JSON resources for production, test, and runtime dependencies.
  • 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 .rb files. 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! ✨🚀

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Callycode Limited
  • A geek-themed horoscope generator blending Bitcoin prices, tech jargon, and astrological whimsy.

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Beniyam Berhanu
  • Therapist adept at identifying core issues and offering practical advice with images.

  • Khalid kalib
  • Write professional emails

  • https://tovuti.be
  • Oede knorrepot die vasthoudt an de goeie ouwe tied van 't boerenleven

  • INFOLAB OPERATIONS 2
  • A medical specialist offering assistance grounded in clinical guidelines. Disclaimer: This is intended for research and is NOT safe for clinical use!

  • ANGEL LEON
  • A world class elite tech co-founder entrepreneur, expert in software development, entrepreneurship, marketing, coaching style leadership and aligned with ambition for excellence, global market penetration and worldy perspectives.

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • OffchainLabs
  • 进行以太坊的实施

  • huahuayu
  • 统一的API网关,用于将多个Etherscan样区块链Explorer API与对AI助手的模型上下文协议(MCP)支持。

  • deemkeen
  • 用电源组合控制您的MBOT2:MQTT+MCP+LLM

  • jae-jae
  • MCP服务器使用剧作《无头浏览器》获取网页内容。

  • HiveNexus
  • 一个适用于中小型团队的AI聊天机器人,支持DeepSeek,Open AI,Claude和Gemini等车型。 专为中小团队设计的ai聊天应用,支持deepSeek,打开ai,claude,双子座等模型。

    Reviews

    4 (1)
    Avatar
    user_p219jYyt
    2025-04-15

    I have been thoroughly impressed with the SQLite MCP Server by dubydu. Its seamless integration and smooth performance make it an essential tool for managing SQLite databases. The server's reliability and ease of use are unparalleled. Highly recommend! Check it out here: https://mcp.so/server/sqlite-mcp/dubydu.