fix: registerCapabilities registers logging/setLevel handler#1605
Open
giulio-leone wants to merge 2 commits intomodelcontextprotocol:mainfrom
Open
fix: registerCapabilities registers logging/setLevel handler#1605giulio-leone wants to merge 2 commits intomodelcontextprotocol:mainfrom
giulio-leone wants to merge 2 commits intomodelcontextprotocol:mainfrom
Conversation
|
@modelcontextprotocol/client
@modelcontextprotocol/server
@modelcontextprotocol/express
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
When logging capability is added via registerCapabilities() instead of the constructor options, the logging/setLevel request handler was not being registered. This caused clients to receive 'Method not found' errors when calling setLoggingLevel. Extract the logging handler setup into a private _registerLoggingHandler method and call it from both the constructor (when logging is in initial capabilities) and registerCapabilities (when logging is added later). Fixes modelcontextprotocol#1464
2f06c63 to
a809754
Compare
Author
|
Friendly ping — CI is green and this is ready for review. Happy to address any feedback. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When logging capability is added via
registerCapabilities()instead of the constructor options, thelogging/setLevelrequest handler is not registered. This causes clients to receive a 'Method not found' error when callingsetLoggingLevel().Root Cause
The
logging/setLevelhandler is only registered in the constructor whenthis._capabilities.loggingis truthy. WhenregisterCapabilities()is called later to add logging, it only merges capabilities but doesn't register the handler.Fix
Extract the logging handler setup into a private
_registerLoggingHandler()method and call it from both:registerCapabilities()(when logging capability is added after construction, and wasn't there before)Tests
Two new integration tests:
registerCapabilities should register logging/setLevel handler: Creates a Server without logging, adds it via registerCapabilities, then verifies the client can successfully call setLoggingLevellogging in constructor capabilities should register logging/setLevel handler: Verifies the existing constructor path still worksAll 86 server integration tests pass (2 consecutive clean runs).
Fixes #1464