-
Notifications
You must be signed in to change notification settings - Fork 1k
implement mcp logging #8846
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement mcp logging #8846
Conversation
There was a problem hiding this 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 @antholeole, 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 Model Context Protocol (MCP) logging specification into the server. It enables the server to emit structured log messages to connected MCP clients and allows clients to dynamically control the server's logging verbosity. The changes include adding new types, capabilities, a logging API, and a private method for handling log message formatting and filtering.
Highlights
- MCP Logging Protocol Implementation: I've implemented the Model Context Protocol (MCP) logging specification, enabling the server to send structured log messages to connected MCP clients. This includes adding necessary types (
LoggingLevel
,SetLevelRequestSchema
) and registering thelogging
capability with the MCP server. - Dynamic Log Level Management: The server now supports dynamic adjustment of its logging verbosity. A new
currentLogLevel
property stores the active log level, which can be updated by the client via aSetLevelRequestSchema
handler. Log messages are filtered based on this configured level. - Convenient Logging API: I've exposed a
public readonly logger
object on theFirebaseMcpServer
class, providing a convenient API for sending log messages at various levels (e.g.,server.logger.warn('my warning')
). This abstracts away the underlying MCP message sending. - Structured Log Message Formatting: A private
log
method handles the actual sending of log messages. It automatically formats string messages into JSON objects ({ message: '...' }
) to comply with the MCP protocol's requirement for JSON data, and applies log level filtering before sending.
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.
Footnotes
-
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 review |
There was a problem hiding this 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 implements the MCP logging protocol. The changes include adding capabilities for logging, handling log level setting from the client, and providing a logger utility for internal use. The implementation correctly filters logs based on the client-specified level. My review focuses on improving the performance and robustness of the log level checking mechanism by using a Map for lookups instead of Array.indexOf.
There was a problem hiding this comment.
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 implements MCP logging, adding logging capabilities to the Firebase MCP server. The changes include defining log levels, setting the log level via request, and sending log messages. The suggestions aim to improve code clarity, prevent potential runtime errors, and enhance performance.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #8846 +/- ##
==========================================
+ Coverage 51.97% 52.03% +0.06%
==========================================
Files 407 412 +5
Lines 30315 30480 +165
Branches 6276 6302 +26
==========================================
+ Hits 15755 15861 +106
- Misses 13143 13198 +55
- Partials 1417 1421 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
LGTM, feel free to merge whenever |
Description
implement MCP logging protocol https://modelcontextprotocol.io/specification/2025-03-26/server/utilities/logging
Scenarios Tested
I used the MCP inspector. Note that the spec is not well defined in that it does not specify which log level is default. I opened a PR against the inspector to send a default log level (modelcontextprotocol/inspector#611) but this works without it, you just have to explicitly set log level in the inspector