|
42 | 42 | import org.slf4j.LoggerFactory; |
43 | 43 | import reactor.core.publisher.Flux; |
44 | 44 | import reactor.core.publisher.Mono; |
| 45 | +import reactor.util.context.ContextView; |
45 | 46 |
|
46 | 47 | /** |
47 | 48 | * The Model Context Protocol (MCP) client implementation that provides asynchronous |
@@ -317,13 +318,20 @@ public McpAsyncClient(McpClientTransport transport, Duration requestTimeout, Dur |
317 | 318 | }; |
318 | 319 |
|
319 | 320 | this.initializer = new LifecycleInitializer(clientCapabilities, clientInfo, transport.protocolVersions(), |
320 | | - initializationTimeout, ctx -> new McpClientSession(requestTimeout, transport, requestHandlers, |
321 | | - notificationHandlers, con -> con.contextWrite(ctx)), |
| 321 | + initializationTimeout, |
| 322 | + ctx -> buildClientSession(requestTimeout, transport, requestHandlers, notificationHandlers, ctx), |
322 | 323 | postInitializationHook); |
323 | 324 |
|
324 | 325 | this.transport.setExceptionHandler(this.initializer::handleException); |
325 | 326 | } |
326 | 327 |
|
| 328 | + protected McpClientSession buildClientSession(Duration requestTimeout, McpClientTransport transport, |
| 329 | + Map<String, RequestHandler<?>> requestHandlers, Map<String, NotificationHandler> notificationHandlers, |
| 330 | + ContextView ctx) { |
| 331 | + return new McpClientSession(requestTimeout, transport, requestHandlers, notificationHandlers, |
| 332 | + con -> con.contextWrite(ctx)); |
| 333 | + } |
| 334 | + |
327 | 335 | /** |
328 | 336 | * Get the current initialization result. |
329 | 337 | * @return the initialization result. |
|
0 commit comments