@@ -508,10 +508,30 @@ void setMinLoggingLevel(LoggingLevel minLoggingLevel) {
508508 // --------------------------
509509
510510 /**
511- * Get the status of a task hosted by the client. This is used when the server has
512- * sent a task-augmented request to the client and needs to poll for status updates.
513- * @param getTaskRequest The request containing the task ID
514- * @return A Mono that emits the task status
511+ * Retrieves a task previously initiated by the server with the client.
512+ *
513+ * <p>
514+ * This method mirrors
515+ * {@link io.modelcontextprotocol.client.McpAsyncClient#getTask(McpSchema.GetTaskRequest)},
516+ * which is used for when the client has initiated a task with the server.
517+ *
518+ * <p>
519+ * Example usage:
520+ *
521+ * <pre>{@code
522+ * var result = exchange.getTask(GetTaskRequest.builder()
523+ * .taskId(taskId)
524+ * .build())
525+ * .block();
526+ * }</pre>
527+ *
528+ * <p>
529+ * <strong>Note:</strong> This is an experimental feature that may change in future
530+ * releases.
531+ * @param getTaskRequest The request containing the task ID.
532+ * @return A Mono that completes with the task information.
533+ * @see McpSchema.GetTaskRequest
534+ * @see McpSchema.GetTaskResult
515535 */
516536 public Mono <McpSchema .GetTaskResult > getTask (McpSchema .GetTaskRequest getTaskRequest ) {
517537 if (this .clientCapabilities == null ) {
@@ -525,11 +545,69 @@ public Mono<McpSchema.GetTaskResult> getTask(McpSchema.GetTaskRequest getTaskReq
525545 }
526546
527547 /**
528- * Get the result of a completed task hosted by the client.
529- * @param <T> The expected result type
530- * @param getTaskPayloadRequest The request containing the task ID
531- * @param resultTypeRef Type reference for deserializing the result
532- * @return A Mono that emits the task result
548+ * Retrieves a task previously initiated by the server with the client by its ID.
549+ *
550+ * <p>
551+ * This method mirrors
552+ * {@link io.modelcontextprotocol.client.McpAsyncClient#getTask(String)}, which is
553+ * used for when the client has initiated a task with the server.
554+ *
555+ * <p>
556+ * This is a convenience overload that creates a {@link McpSchema.GetTaskRequest} with
557+ * the given task ID.
558+ *
559+ * <p>
560+ * Example usage:
561+ *
562+ * <pre>{@code
563+ * var result = exchange.getTask(taskId);
564+ * }</pre>
565+ *
566+ * <p>
567+ * <strong>Note:</strong> This is an experimental feature that may change in future
568+ * releases.
569+ * @param taskId The task identifier to query.
570+ * @return A Mono that completes with the task status and metadata.
571+ */
572+ public Mono <McpSchema .GetTaskResult > getTask (String taskId ) {
573+ return this .getTask (McpSchema .GetTaskRequest .builder ().taskId (taskId ).build ());
574+ }
575+
576+ /**
577+ * Get the result of a completed task previously initiated by the server with the
578+ * client.
579+ *
580+ * <p>
581+ * The result type depends on the original request that created the task. For sampling
582+ * requests, use {@code new TypeRef<McpSchema.CreateMessageResult>(){}}. For
583+ * elicitation requests, use {@code new TypeRef<McpSchema.ElicitResult>(){}}.
584+ *
585+ * <p>
586+ * This method mirrors
587+ * {@link io.modelcontextprotocol.client.McpAsyncClient#getTaskResult(McpSchema.GetTaskPayloadRequest, TypeRef)},
588+ * which is used for when the client has initiated a task with the server.
589+ *
590+ * <p>
591+ * Example usage:
592+ *
593+ * <pre>{@code
594+ * // For sampling task results:
595+ * var result = exchange.getTaskResult(
596+ * new GetTaskPayloadRequest(taskId, null),
597+ * new TypeRef<McpSchema.CreateMessageResult>(){})
598+ * .block();
599+ * }</pre>
600+ *
601+ * <p>
602+ * <strong>Note:</strong> This is an experimental feature that may change in future
603+ * releases.
604+ * @param <T> The expected result type, must extend
605+ * {@link McpSchema.ClientTaskPayloadResult}
606+ * @param getTaskPayloadRequest The request containing the task ID.
607+ * @param resultTypeRef Type reference for deserializing the result.
608+ * @return A Mono that completes with the task result.
609+ * @see McpSchema.GetTaskPayloadRequest
610+ * @see McpSchema.ClientTaskPayloadResult
533611 */
534612 public <T extends McpSchema .ClientTaskPayloadResult > Mono <T > getTaskResult (
535613 McpSchema .GetTaskPayloadRequest getTaskPayloadRequest , TypeRef <T > resultTypeRef ) {
@@ -543,6 +621,51 @@ public <T extends McpSchema.ClientTaskPayloadResult> Mono<T> getTaskResult(
543621 return this .session .sendRequest (McpSchema .METHOD_TASKS_RESULT , getTaskPayloadRequest , resultTypeRef );
544622 }
545623
624+ /**
625+ * Get the result of a completed task previously initiated by the server with the
626+ * client by its task ID.
627+ *
628+ * <p>
629+ * This is a convenience overload that creates a
630+ * {@link McpSchema.GetTaskPayloadRequest} from the task ID.
631+ *
632+ * <p>
633+ * The result type depends on the original request that created the task. For sampling
634+ * requests, use {@code new TypeRef<McpSchema.CreateMessageResult>(){}}. For
635+ * elicitation requests, use {@code new TypeRef<McpSchema.ElicitResult>(){}}.
636+ *
637+ * <p>
638+ * This method mirrors
639+ * {@link io.modelcontextprotocol.client.McpAsyncClient#getTaskResult(String, TypeRef)},
640+ * which is used for when the client has initiated a task with the server.
641+ *
642+ * <p>
643+ * Example usage:
644+ *
645+ * <pre>{@code
646+ * // For sampling task results:
647+ * var result = exchange.getTaskResult(
648+ * taskId,
649+ * new TypeRef<McpSchema.CreateMessageResult>(){})
650+ * .block();
651+ * }</pre>
652+ *
653+ * <p>
654+ * <strong>Note:</strong> This is an experimental feature that may change in future
655+ * releases.
656+ * @param <T> The expected result type, must extend
657+ * {@link McpSchema.ClientTaskPayloadResult}
658+ * @param taskId The task identifier.
659+ * @param resultTypeRef Type reference for deserializing the result.
660+ * @return A Mono that completes with the task result.
661+ * @see McpSchema.GetTaskPayloadRequest
662+ * @see McpSchema.ClientTaskPayloadResult
663+ */
664+ public <T extends McpSchema .ClientTaskPayloadResult > Mono <T > getTaskResult (String taskId ,
665+ TypeRef <T > resultTypeRef ) {
666+ return this .getTaskResult (McpSchema .GetTaskPayloadRequest .builder ().taskId (taskId ).build (), resultTypeRef );
667+ }
668+
546669 /**
547670 * List all tasks hosted by the client.
548671 *
0 commit comments