diff --git a/mcp/src/main/java/io/modelcontextprotocol/server/McpAsyncServerExchange.java b/mcp/src/main/java/io/modelcontextprotocol/server/McpAsyncServerExchange.java index cfb07d26c..64338ba4f 100644 --- a/mcp/src/main/java/io/modelcontextprotocol/server/McpAsyncServerExchange.java +++ b/mcp/src/main/java/io/modelcontextprotocol/server/McpAsyncServerExchange.java @@ -69,6 +69,14 @@ public McpSchema.Implementation getClientInfo() { return this.clientInfo; } + /** + * Get mcp server session. + * @return The mcp server session + */ + public McpServerSession getSession() { + return this.session; + } + /** * Create a new message using the sampling capabilities of the client. The Model * Context Protocol (MCP) provides a standardized way for servers to request LLM diff --git a/mcp/src/main/java/io/modelcontextprotocol/server/McpSyncServerExchange.java b/mcp/src/main/java/io/modelcontextprotocol/server/McpSyncServerExchange.java index 084412b96..0f5aa838d 100644 --- a/mcp/src/main/java/io/modelcontextprotocol/server/McpSyncServerExchange.java +++ b/mcp/src/main/java/io/modelcontextprotocol/server/McpSyncServerExchange.java @@ -7,6 +7,7 @@ import io.modelcontextprotocol.spec.McpSchema; import io.modelcontextprotocol.spec.McpSchema.LoggingLevel; import io.modelcontextprotocol.spec.McpSchema.LoggingMessageNotification; +import io.modelcontextprotocol.spec.McpServerSession; /** * Represents a synchronous exchange with a Model Context Protocol (MCP) client. The @@ -43,6 +44,14 @@ public McpSchema.ClientCapabilities getClientCapabilities() { public McpSchema.Implementation getClientInfo() { return this.exchange.getClientInfo(); } + + /** + * Get mcp server session. + * @return The mcp server session + */ + public McpServerSession getSession() { + return this.exchange.getSession(); + } /** * Create a new message using the sampling capabilities of the client. The Model