Skip to content

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

Merged
merged 4 commits into from
Jul 15, 2025
Merged

implement mcp logging #8846

merged 4 commits into from
Jul 15, 2025

Conversation

antholeole
Copy link
Contributor

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

Copy link
Contributor

@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 @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 the logging 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 a SetLevelRequestSchema handler. Log messages are filtered based on this configured level.
  • Convenient Logging API: I've exposed a public readonly logger object on the FirebaseMcpServer 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

  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.

@antholeole
Copy link
Contributor Author

/gemini review

Copy link
Contributor

@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 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.

Copy link
Contributor

@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

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-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 52.03%. Comparing base (609bb02) to head (9725bbc).
Report is 30 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@joehan
Copy link
Contributor

joehan commented Jul 15, 2025

LGTM, feel free to merge whenever

@antholeole antholeole enabled auto-merge (squash) July 15, 2025 20:39
@antholeole antholeole merged commit a3e87e5 into master Jul 15, 2025
48 of 50 checks passed
@antholeole antholeole deleted the oleina/mcplogging branch July 15, 2025 20:50
@github-project-automation github-project-automation bot moved this from Approved [PR] to Done in [Cloud] Extensions + Functions Jul 15, 2025
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.

3 participants