Skip to content

Conversation

jjmata
Copy link
Collaborator

@jjmata jjmata commented Aug 5, 2025

Summary

  • integrate fast-mcp gem and mount MCP endpoints
  • add base classes for MCP tools and resources
  • document how to interact with MCP

Testing

  • bundle exec rails test (fails: ActiveRecord::DatabaseConnectionError: There is an issue connecting with your hostname: 127.0.0.1)

https://chatgpt.com/codex/tasks/task_e_6891a4e9a218833284588e9f072ae5db

@jjmata jjmata added the codex Touched by OpenAI Codex somehow label Aug 5, 2025 — with ChatGPT Codex Connector
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @jjmata, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request integrates the fast-mcp gem to add Model Context Protocol (MCP) support to the application. This enables the application to expose JSON-RPC and Server-Sent Events (SSE) endpoints for interacting with defined tools and resources, facilitating external communication and real-time updates.

Highlights

  • MCP Integration: I've added the fast-mcp gem to the project, which provides a Ruby implementation of the Model Context Protocol.
  • Endpoint Exposure: The PR configures and mounts the MCP middleware in the Rails application, exposing /mcp/messages for JSON-RPC requests and /mcp/sse for Server-Sent Events.
  • Base Classes for MCP Components: I've introduced ApplicationTool and ApplicationResource as base classes for defining custom MCP tools and resources, respectively, ensuring automatic registration with the MCP server.
  • Documentation: Comprehensive documentation (docs/MCP.md) has been added to explain how to define tools and resources, and how to interact with the new MCP endpoints.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request successfully integrates the fast-mcp gem to add Model Context Protocol (MCP) support. The changes include adding the gem, creating base classes for resources and tools, providing documentation, and setting up an initializer. The implementation is solid, but I have a couple of suggestions for the initializer file to improve maintainability and ensure correct behavior in the development environment.

Comment on lines +36 to +37
server.register_tools(*ApplicationTool.descendants)
server.register_resources(*ApplicationResource.descendants)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

In the development environment, Rails lazy-loads classes, so ApplicationTool.descendants and ApplicationResource.descendants will likely be empty when this initializer runs. This will prevent your tools and resources from being registered. You should explicitly eager-load these directories to ensure all tool and resource classes are loaded before registration.

    # Eager-load tools and resources to ensure they are discovered, especially in development.
    Rails.autoloaders.main.eager_load_dir(Rails.root.join("app/tools"))
    Rails.autoloaders.main.eager_load_dir(Rails.root.join("app/resources"))

    server.register_tools(*ApplicationTool.descendants)
    server.register_resources(*ApplicationResource.descendants)

Comment on lines 17 to 20
FastMcp.mount_in_rails(
Rails.application,
name: Rails.application.class.module_parent_name.underscore.dasherize,
version: '1.0.0',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve maintainability and avoid using a 'magic string', it's a good practice to define the version as a constant. This makes it easier to manage and update the version number, especially if it's referenced elsewhere in the application.

MCP_VERSION = '1.0.0'

FastMcp.mount_in_rails(
  Rails.application,
  name: Rails.application.class.module_parent_name.underscore.dasherize,
  version: MCP_VERSION,

@jjmata jjmata self-assigned this Aug 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex Touched by OpenAI Codex somehow

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant