-
Notifications
You must be signed in to change notification settings - Fork 466
feat(MCPServer): send log message notifications to specific client #301
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
Conversation
""" WalkthroughThe changes introduce a new server-to-client logging notification mechanism. This includes defining a new MCP method constant, mapping logging levels to RFC-5424 severity codes, and adding logic to determine if a message should be sent based on client subscription level. A method is added to the server for sending log notifications, and comprehensive tests are implemented to verify this functionality under various scenarios. Additionally, an error message was clarified to reflect support for both setting and getting logging levels. Changes
Possibly related PRs
Suggested labels
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (1.64.8)Error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2 Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Looks good. We can merge this.
hi @pottekkat @cryo-zd It's a great idea to support this feature, but this implement is not what I think. for example, how develops use this function, they can not access I think the python-sdk is a good reference example, it allow develop send log message in tool function: @mcp.tool()
async def long_task(files: list[str], ctx: Context) -> str:
"""Process multiple files with progress tracking"""
for i, file in enumerate(files):
ctx.info(f"Processing {file}")
await ctx.report_progress(i, len(files))
data, mime_type = await ctx.read_resource(f"file://{file}")
return "Processing complete" |
Also, we need to consider compatibility with both cancelled_notification and progress_notification, maybe there are some design ideas they could share. |
Relaying the discussion we had in the Discord server. The current implementation has limitations that make it difficult for developers to use the log notifications effectively within tool handlers. Ideally, we want to implement a more idiomatic way to handle these logs, maybe similar to the logging package in the standard library where the SDK does the heavy lifting and offer neat abstractions for Go developers that are intuitive and familiar. We can merge this PR and open a new issue to track this improvement because it will be a breaking change. We have to plan out how to implement this and @dugenkui03 can include his thoughts. |
@pottekkat I agree with that and create another issue #321. And I left another comment for this pr: how about change the type of |
picked from: https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/schema/2025-03-26/schema.json "LoggingLevel": {
"description": "The severity of a log message.\n\nThese map to syslog message severities, as specified in RFC-5424:\nhttps://datatracker.ietf.org/doc/html/rfc5424#section-6.2.1",
"enum": [
"alert",
"critical",
"debug",
"emergency",
"error",
"info",
"notice",
"warning"
],
"type": "string"
}, May be string is better for consistency? |
@cryo-zd thank you present more details, and I agree with you. |
Ok, so we are reimplementing this as per the new proposal in #329 and this was closed. |
Description
This PR enables MCPServer to send log message notifications to specific client according to the specification

Type of Change
Checklist
MCP Spec Compliance
Additional Information
Summary by CodeRabbit