Skip to content

Experiment: MCP server#36

Draft
rm-hull wants to merge 15 commits into
mainfrom
feat/mcp-tools
Draft

Experiment: MCP server#36
rm-hull wants to merge 15 commits into
mainfrom
feat/mcp-tools

Conversation

@rm-hull

@rm-hull rm-hull commented Apr 18, 2025

Copy link
Copy Markdown
Collaborator

No description provided.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hello @rm-hull, 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!

Summary of Changes

This pull request introduces an experimental MCP (Micro Control Plane) server to the application. It adds a new command mcp-server to the CLI, which starts an SSE (Server-Sent Events) based MCP server on a specified port. The server exposes two tools: get_weather and gps_routes, with corresponding handlers that return mock data. The pull request also updates the .vscode/launch.json to include a launch configuration for the new MCP server, and updates the go.mod and go.sum files to include the github.com/mark3labs/mcp-go dependency and other indirect dependencies.

Highlights

  • MCP Server Implementation: Implements a new MCP server using Server-Sent Events (SSE) to expose tools.
  • CLI Command: Adds a new mcp-server command to the CLI for starting the MCP server.
  • Tool Definitions: Defines two example tools: get_weather and gps_routes with mock handlers.
  • VS Code Configuration: Adds a new launch configuration to .vscode/launch.json for debugging the MCP server.
  • Dependency Management: Updates go.mod and go.sum to include the github.com/mark3labs/mcp-go dependency and other indirect dependencies.

Changelog

Click here to see the changelog
  • .vscode/launch.json
    • Added a new launch configuration for the MCP server, allowing to run it on port 8081.
  • cmds/sse_mcp_server.go
    • Created a new file cmds/sse_mcp_server.go to implement the MCP server logic.
    • Implemented the NewSseMcpServer function to create and start the MCP server.
    • Defined two example tools: get_weather and gps_routes with descriptions and parameters.
    • Implemented mock handlers for the get_weather and gps_routes tools.
    • Added McpMiddleware function which is currently unused.
  • go.mod
    • Added github.com/mark3labs/mcp-go v0.21.1 as a dependency.
    • Updated github.com/beevik/etree from v1.5.0 to v1.5.1.
    • Added github.com/yosida95/uritemplate/v3 v3.0.2 as an indirect dependency.
    • Updated github.com/gabriel-vasile/mimetype from v1.4.8 to v1.4.9.
  • go.sum
    • Updated checksums for dependencies, including github.com/mark3labs/mcp-go, github.com/beevik/etree, github.com/yosida95/uritemplate/v3, and github.com/gabriel-vasile/mimetype.
  • main.go
    • Added a new command mcpServerCmd to the CLI for starting the MCP server.
    • Updated the Long description of the root command to include MCP server.
    • Refactored variable declarations to use short variable declaration form (:=).
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 is currently in preview and 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 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.


A server of tools,
Routes and weather, it rules,
SSE streams flow,
Data starts to glow,
MCP's wisdom pools.

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.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

The pull request introduces an MCP (Managed Control Plane) server to the application, allowing for remote management and control of GPS routes. The changes include adding a new command to start the MCP server, defining tools for weather and GPS route information, and setting up the server with appropriate handlers. The code appears well-structured and addresses the intended functionality.

Summary of Findings

  • Error Handling in Server Startup: The NewSseMcpServer function uses log.Fatalf which will terminate the program if the server fails to start. While this is appropriate for a critical failure, it might be better to handle the error more gracefully, allowing the application to potentially recover or log the error and continue running other services. Consider using log.Printf and returning an error to allow the caller to handle the failure.
  • Middleware Usage: The McpMiddleware function is defined but commented out. It's unclear if this middleware is intended to be used. If it is, ensure it's properly integrated into the Gin router. If not, consider removing the unused function to avoid confusion.
  • Tool Descriptions: The description for the gps_routes tool's query parameter is empty. Providing a meaningful description would improve the usability and clarity of the tool.

Merge Readiness

The pull request introduces significant new functionality with the MCP server. While the code appears well-structured, the error handling in server startup and the unclear usage of the middleware function raise concerns. I recommend addressing these issues before merging. I am unable to approve this pull request, and other reviewers should also review and approve this code before merging.

@github-actions

github-actions Bot commented Apr 18, 2025

Copy link
Copy Markdown
TestsPassed ✅SkippedFailed
JUnit Test Report44 ran44 passed0 skipped0 failed
TestResult
JUnit Test Report
com/rm-hull/gps-routes-api/db.TestQueryBuilder_Build/empty_query✅ passed
com/rm-hull/gps-routes-api/db.TestQueryBuilder_Build/single_word_query✅ passed
com/rm-hull/gps-routes-api/db.TestQueryBuilder_Build/multiple_word_query✅ passed
com/rm-hull/gps-routes-api/db.TestQueryBuilder_Build/bounding_box✅ passed
com/rm-hull/gps-routes-api/db.TestQueryBuilder_Build/nearest✅ passed
com/rm-hull/gps-routes-api/db.TestQueryBuilder_Build/with_where_clause✅ passed
com/rm-hull/gps-routes-api/db.TestQueryBuilder_Build/with_multiple_where_clauses✅ passed
com/rm-hull/gps-routes-api/db.TestQueryBuilder_Build/with_group_by✅ passed
com/rm-hull/gps-routes-api/db.TestQueryBuilder_Build/with_order_by✅ passed
com/rm-hull/gps-routes-api/db.TestQueryBuilder_Build/with_limit✅ passed
com/rm-hull/gps-routes-api/db.TestQueryBuilder_Build/with_no_limit✅ passed
com/rm-hull/gps-routes-api/db.TestQueryBuilder_Build/with_offset✅ passed
com/rm-hull/gps-routes-api/db.TestQueryBuilder_Build/with_truncated_fields✅ passed
com/rm-hull/gps-routes-api/db.TestQueryBuilder_Build/with_all✅ passed
com/rm-hull/gps-routes-api/db.TestQueryBuilder_Build/with_facets✅ passed
com/rm-hull/gps-routes-api/db.TestQueryBuilder_Build/with_empty_facets✅ passed
com/rm-hull/gps-routes-api/db.TestQueryBuilder_Build/with_excluded_facets✅ passed
com/rm-hull/gps-routes-api/db.TestQueryBuilder_Build/with_array_fields✅ passed
com/rm-hull/gps-routes-api/db.TestQueryBuilder_Build✅ passed
com/rm-hull/gps-routes-api/middlewares.TestAuthMiddleware/No_API_Key✅ passed
com/rm-hull/gps-routes-api/middlewares.TestAuthMiddleware/Invalid_API_Key✅ passed
com/rm-hull/gps-routes-api/middlewares.TestAuthMiddleware/Valid_API_Key✅ passed
com/rm-hull/gps-routes-api/middlewares.TestAuthMiddleware/Excluded_Path✅ passed
com/rm-hull/gps-routes-api/middlewares.TestAuthMiddleware/OPTIONS_Request✅ passed
com/rm-hull/gps-routes-api/middlewares.TestAuthMiddleware/API_Key_Not_Set✅ passed
com/rm-hull/gps-routes-api/middlewares.TestAuthMiddleware✅ passed
com/rm-hull/gps-routes-api/services/osdatahub.TestToWSG84/London_-_Trafalgar_Square✅ passed
com/rm-hull/gps-routes-api/services/osdatahub.TestToWSG84/Edinburgh_Castle✅ passed
com/rm-hull/gps-routes-api/services/osdatahub.TestToWSG84/Cardiff_Castle✅ passed
com/rm-hull/gps-routes-api/services/osdatahub.TestToWSG84/Belfast_City_Hall✅ passed
com/rm-hull/gps-routes-api/services/osdatahub.TestToWSG84/Zero_values✅ passed
com/rm-hull/gps-routes-api/services/osdatahub.TestToWSG84/Nil_values✅ passed
com/rm-hull/gps-routes-api/services/osdatahub.TestToWSG84✅ passed
com/rm-hull/gps-routes-api/services/osdatahub.TestNewNamesApi✅ passed
com/rm-hull/gps-routes-api/services/osdatahub.TestFind_Success✅ passed
com/rm-hull/gps-routes-api/services/osdatahub.TestFind_NoResults✅ passed
com/rm-hull/gps-routes-api/services/osdatahub.TestFind_Error✅ passed
com/rm-hull/gps-routes-api/services/osdatahub.TestFind_InvalidJSON✅ passed
com/rm-hull/gps-routes-api/services/osdatahub.TestFind_ErrorResponse✅ passed
com/rm-hull/gps-routes-api/services/osdatahub.TestFind_RequestError✅ passed
com/rm-hull/gps-routes-api/tests.TestHealthEndpoint✅ passed
com/rm-hull/gps-routes-api/tests.TestMetricsEndpoint✅ passed
com/rm-hull/gps-routes-api/tests.TestImportData✅ passed
com/rm-hull/gps-routes-api/tests.TestDbPing✅ passed

@coveralls

coveralls commented Apr 18, 2025

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 17035241308

Details

  • 0 of 214 (0.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-6.4%) to 40.053%

Changes Missing Coverage Covered Lines Changed/Added Lines %
main.go 0 19 0.0%
cmds/sse_mcp_server.go 0 195 0.0%
Totals Coverage Status
Change from base Build 16994783397: -6.4%
Covered Lines: 600
Relevant Lines: 1498

💛 - Coveralls

rm-hull added 14 commits April 18, 2025 16:53
…p-tools

* 'main' of github.com:rm-hull/gps-routes-api:
  Fix missing/erroneous excluded field configs
…p-tools

* 'main' of github.com:rm-hull/gps-routes-api:
  Treat empty facet values as if not set (#39)
…p-tools

* 'main' of github.com:rm-hull/gps-routes-api:
  Set correct SRID (4326) when sorting by nearest point (#41)
  Specify whether to truncate text in search results (#40)
…p-tools

* 'main' of github.com:rm-hull/gps-routes-api:
  Update dependencies
  Bump github.com/testcontainers/testcontainers-go from 0.36.0 to 0.37.0 (#43)
  Update dependencies
  Bump github.com/golang-migrate/migrate/v4 from 4.18.2 to 4.18.3 (#42)
…p-tools

* 'main' of github.com:rm-hull/gps-routes-api:
  Update docker-compose.yml
  Bump github.com/gin-gonic/gin from 1.10.0 to 1.10.1 (#47)
  Bump github.com/jackc/pgx/v5 from 5.7.4 to 5.7.5 (#46)
  Bump github.com/JGLTechnologies/gin-rate-limit from 1.5.4 to 1.5.6 (#45)
  Bump golangci/golangci-lint-action from 7 to 8 (#44)
…p-tools

* 'main' of github.com:rm-hull/gps-routes-api:
  Allow caller to skip facet counts in the result if they are not interested in them (#49)
  Update dependences
  Regenerate facets using llama.cpp (#32)
…p-tools

* 'main' of github.com:rm-hull/gps-routes-api:
  Add simple auth middleware (#50)
  Update deps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants