-
Notifications
You must be signed in to change notification settings - Fork 312
refactor: change notification params type from Map<String,Object> to Object #137
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
…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>
// Map<String, Object> params = | ||
// this.objectMapper.convertValue(loggingMessageNotification, | ||
// new TypeReference<Map<String, Object>>() { | ||
// }); | ||
|
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.
// Map<String, Object> params = | |
// this.objectMapper.convertValue(loggingMessageNotification, | |
// new TypeReference<Map<String, Object>>() { | |
// }); |
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
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.
Breaking change alert, but I think it's absolutely worth it.
* @return a Mono that completes when the notification has been broadcast | ||
* @see McpSession#sendNotification(String, Map) | ||
*/ | ||
Mono<Void> notifyClients(String method, Map<String, Object> params); | ||
Mono<Void> notifyClients(String method, Object params); |
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.
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); |
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.
Let's keep in mind to take note of the breaking change in the release docs. I think it's worth the effort though.
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: