Skip to content

feat(mcp): refactor logging to use exchange for targeted client notifications #132

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

Closed
wants to merge 8 commits into from

Conversation

tzolov
Copy link
Contributor

@tzolov tzolov commented Apr 9, 2025

Refactors the MCP logging system to use the exchange mechanism for sending logging notifications only to specific client sessions rather than broadcasting to all clients.

  • Move logging notification delivery from server-wide broadcast to per-session exchange
  • Implement per-session minimum logging level tracking and filtering
  • Change setLoggingLevel from notification to request/response pattern
  • Deprecate global server.loggingNotification in favor of exchange.loggingNotification
  • Add integration test demonstrating filtered logging notifications

Resolves #131

@tzolov tzolov marked this pull request as ready for review April 9, 2025 10:00
Copy link
Member

@chemicL chemicL left a comment

Choose a reason for hiding this comment

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

I haven't gone through all the tests yet as I have some concerns regarding the design and public API changes, let's address these first.

@@ -44,7 +45,7 @@

public class HttpServletSseServerTransportProviderIntegrationTests {

private static final int PORT = 8185;
private static final int PORT = 8189;
Copy link
Member

Choose a reason for hiding this comment

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

Why change? Perhaps we need a simple utility to allocate a random port instead of relying on a constant? https://stackoverflow.com/questions/2675362/how-to-find-an-available-port

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This makes sense. Spring Boot used to have such utility but discarded it for some reason.
Lets handle this in a dedicated issue/pr

@tzolov tzolov force-pushed the fix-mcp-logging branch from 16635be to 2805809 Compare April 9, 2025 16:14
tzolov added 4 commits April 10, 2025 12:27
…ications

Refactors the MCP logging system to use the exchange mechanism for sending
logging notifications only to specific client sessions rather than broadcasting to all clients.

- Move logging notification delivery from server-wide broadcast to per-session exchange
- Implement per-session minimum logging level tracking and filtering
- Change setLoggingLevel from notification to request/response pattern
- Deprecate global server.loggingNotification in favor of exchange.loggingNotification
- Add integration test demonstrating filtered logging notifications

Resolves #131

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
- Implement AutoCloseable interface for McpAsyncClient, McpAsyncServer, and McpSyncServer
- Refactor test methods to use try-with-resources for automatic resource cleanup
- Add missing Javadoc for McpSyncServerExchange.setMinLoggingLevel
- Change visibility of McpAsyncServerExchange.setMinLoggingLevel to package-private

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
…syncServerExchange

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
chemicL added 3 commits April 10, 2025 15:07
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
tzolov added a commit that referenced this pull request Apr 10, 2025
…ications (#132)

Refactors the MCP logging system to use the exchange mechanism for sending
logging notifications only to specific client sessions rather than broadcasting to all clients.

- Move logging notification delivery from server-wide broadcast to per-session exchange
- Implement per-session minimum logging level tracking and filtering
- Add proper logging level filtering at the exchange level
- Change setLoggingLevel from notification to request/response pattern (breaking change)
- Deprecate global server.loggingNotification in favor of exchange.loggingNotification
- Add SetLevelRequest record to McpSchema
- Add integration test demonstrating filtered logging notifications

Resolves #131

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
Co-authored-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
@tzolov
Copy link
Contributor Author

tzolov commented Apr 10, 2025

rebased, squashed and merged at c88ac93

@tzolov tzolov closed this Apr 10, 2025
@chemicL chemicL deleted the fix-mcp-logging branch April 11, 2025 10:46
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.

Refactor logging system to use exchange for targeted client notifications
2 participants