feat: add getters for server/client capabilities and implementation info

Add getter methods to expose server and client capabilities and implementation
information in both McpAsyncServer and McpSyncServer classes. Store client
metadata received during initialization for later retrieval.
This commit is contained in:
Christian Tzolov 2025-01-01 13:33:54 +01:00
commit 2b42379c57

View file

@ -16,11 +16,11 @@
package org.springframework.ai.mcp.server;
import reactor.core.publisher.Mono;
import org.springframework.ai.mcp.server.McpServer.PromptRegistration;
import org.springframework.ai.mcp.server.McpServer.ResourceRegistration;
import org.springframework.ai.mcp.server.McpServer.ToolRegistration;
import org.springframework.ai.mcp.spec.McpSchema;
import org.springframework.ai.mcp.spec.McpSchema.ClientCapabilities;
import org.springframework.ai.mcp.spec.McpSchema.LoggingMessageNotification;
import org.springframework.ai.mcp.util.Assert;
@ -124,6 +124,38 @@ public class McpSyncServer {
this.asyncServer.loggingNotification(loggingMessageNotification).block();
}
/**
* Get the server capabilities that define the supported features and functionality.
* @return The server capabilities
*/
public McpSchema.ServerCapabilities getServerCapabilities() {
return this.asyncServer.getServerCapabilities();
}
/**
* Get the server implementation information.
* @return The server implementation details
*/
public McpSchema.Implementation getServerInfo() {
return this.asyncServer.getServerInfo();
}
/**
* Get the client capabilities that define the supported features and functionality.
* @return The client capabilities
*/
public ClientCapabilities getClientCapabilities() {
return this.asyncServer.getClientCapabilities();
}
/**
* Get the client implementation information.
* @return The client implementation details
*/
public McpSchema.Implementation getClientInfo() {
return this.asyncServer.getClientInfo();
}
/**
* Close the server gracefully.
*/