refactor: change notification params type from Map<String,Object> to Object#137
Merged
refactor: change notification params type from Map<String,Object> to Object#137
Conversation
…Object This change generalizes the parameter type for notification methods across the MCP framework, allowing for more flexible parameter passing. Instead of requiring parameters to be structured as a Map<String,Object>, the API now accepts any Object as parameters. The primary motivation is to simplify client usage by allowing direct passing of strongly-typed objects without requiring conversion to a Map first, as demonstrated in the McpAsyncServer logging notification implementation. Affected components: - McpSession interface and implementations - McpServerTransportProvider interface and implementations - McpSchema JSONRPCNotification record Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
chemicL
reviewed
Apr 10, 2025
Comment on lines
672
to
676
| // Map<String, Object> params = | ||
| // this.objectMapper.convertValue(loggingMessageNotification, | ||
| // new TypeReference<Map<String, Object>>() { | ||
| // }); | ||
|
|
Member
There was a problem hiding this comment.
Suggested change
| // Map<String, Object> params = | |
| // this.objectMapper.convertValue(loggingMessageNotification, | |
| // new TypeReference<Map<String, Object>>() { | |
| // }); |
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
chemicL
approved these changes
Apr 10, 2025
Member
chemicL
left a comment
There was a problem hiding this comment.
Breaking change alert, but I think it's absolutely worth it.
| * @see McpSession#sendNotification(String, Map) | ||
| */ | ||
| Mono<Void> notifyClients(String method, Map<String, Object> params); | ||
| Mono<Void> notifyClients(String method, Object params); |
Member
There was a problem hiding this comment.
Let's keep in mind to take note of the breaking change in the release docs. I think it's worth the effort though.
| * @return a Mono that completes when the notification has been sent | ||
| */ | ||
| Mono<Void> sendNotification(String method, Map<String, Object> params); | ||
| Mono<Void> sendNotification(String method, Object params); |
Member
There was a problem hiding this comment.
Let's keep in mind to take note of the breaking change in the release docs. I think it's worth the effort though.
noear
added a commit
to solonlab/mcp-java-sdk
that referenced
this pull request
May 17, 2025
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.
This change generalizes the parameter type for notification methods across the MCP framework, allowing for more flexible parameter passing. Instead of requiring parameters to be structured as a Map<String,Object>, the API now accepts any Object as parameters.
The primary motivation is to simplify client usage by allowing direct passing of strongly-typed
objects without requiring conversion to a Map first, as demonstrated in the McpAsyncServer
logging notification implementation.
Affected components: