diff --git a/mcp/src/main/java/io/modelcontextprotocol/server/McpAsyncServerExchange.java b/mcp/src/main/java/io/modelcontextprotocol/server/McpAsyncServerExchange.java index 889dc66d..f97aec59 100644 --- a/mcp/src/main/java/io/modelcontextprotocol/server/McpAsyncServerExchange.java +++ b/mcp/src/main/java/io/modelcontextprotocol/server/McpAsyncServerExchange.java @@ -66,6 +66,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 52360e54..8796db39 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