refactor: change notification params type from Map<String,Object> to Object (#137)

* refactor: change notification params type from Map<String,Object> to 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>
This commit is contained in:
Christian Tzolov 2025-04-10 12:26:29 +02:00 • committed by GitHub
commit 391ec19fdc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 17 deletions

View file

@ -188,7 +188,7 @@ public class WebFluxSseServerTransportProvider implements McpServerTransportProv
* errors if any session fails to receive the message
*/
@Override
public Mono<Void> notifyClients(String method, Map<String, Object> params) {
public Mono<Void> notifyClients(String method, Object params) {
if (sessions.isEmpty()) {
logger.debug("No active sessions to broadcast message to");
return Mono.empty();

View file

@ -179,7 +179,7 @@ public class WebMvcSseServerTransportProvider implements McpServerTransportProvi
* @return A Mono that completes when the broadcast attempt is finished
*/
@Override
public Mono<Void> notifyClients(String method, Map<String, Object> params) {
public Mono<Void> notifyClients(String method, Object params) {
if (sessions.isEmpty()) {
logger.debug("No active sessions to broadcast message to");
return Mono.empty();