@@ -530,10 +530,30 @@ void setMinLoggingLevel(LoggingLevel minLoggingLevel) {
530530 // --------------------------
531531
532532 /**
533- * Get the status of a task hosted by the client. This is used when the server has
534- * sent a task-augmented request to the client and needs to poll for status updates.
535- * @param getTaskRequest The request containing the task ID
536- * @return A Mono that emits the task status
533+ * Retrieves a task previously initiated by the server with the client.
534+ *
535+ * <p>
536+ * This method mirrors
537+ * {@link io.modelcontextprotocol.client.McpAsyncClient#getTask(McpSchema.GetTaskRequest)},
538+ * which is used for when the client has initiated a task with the server.
539+ *
540+ * <p>
541+ * Example usage:
542+ *
543+ * <pre>{@code
544+ * var result = exchange.getTask(GetTaskRequest.builder()
545+ * .taskId(taskId)
546+ * .build())
547+ * .block();
548+ * }</pre>
549+ *
550+ * <p>
551+ * <strong>Note:</strong> This is an experimental feature that may change in future
552+ * releases.
553+ * @param getTaskRequest The request containing the task ID.
554+ * @return A Mono that completes with the task information.
555+ * @see McpSchema.GetTaskRequest
556+ * @see McpSchema.GetTaskResult
537557 */
538558 public Mono <McpSchema .GetTaskResult > getTask (McpSchema .GetTaskRequest getTaskRequest ) {
539559 if (this .clientCapabilities == null ) {
@@ -547,11 +567,69 @@ public Mono<McpSchema.GetTaskResult> getTask(McpSchema.GetTaskRequest getTaskReq
547567 }
548568
549569 /**
550- * Get the result of a completed task hosted by the client.
551- * @param <T> The expected result type
552- * @param getTaskPayloadRequest The request containing the task ID
553- * @param resultTypeRef Type reference for deserializing the result
554- * @return A Mono that emits the task result
570+ * Retrieves a task previously initiated by the server with the client by its ID.
571+ *
572+ * <p>
573+ * This method mirrors
574+ * {@link io.modelcontextprotocol.client.McpAsyncClient#getTask(String)}, which is
575+ * used for when the client has initiated a task with the server.
576+ *
577+ * <p>
578+ * This is a convenience overload that creates a {@link McpSchema.GetTaskRequest} with
579+ * the given task ID.
580+ *
581+ * <p>
582+ * Example usage:
583+ *
584+ * <pre>{@code
585+ * var result = exchange.getTask(taskId);
586+ * }</pre>
587+ *
588+ * <p>
589+ * <strong>Note:</strong> This is an experimental feature that may change in future
590+ * releases.
591+ * @param taskId The task identifier to query.
592+ * @return A Mono that completes with the task status and metadata.
593+ */
594+ public Mono <McpSchema .GetTaskResult > getTask (String taskId ) {
595+ return this .getTask (McpSchema .GetTaskRequest .builder ().taskId (taskId ).build ());
596+ }
597+
598+ /**
599+ * Get the result of a completed task previously initiated by the server with the
600+ * client.
601+ *
602+ * <p>
603+ * The result type depends on the original request that created the task. For sampling
604+ * requests, use {@code new TypeRef<McpSchema.CreateMessageResult>(){}}. For
605+ * elicitation requests, use {@code new TypeRef<McpSchema.ElicitResult>(){}}.
606+ *
607+ * <p>
608+ * This method mirrors
609+ * {@link io.modelcontextprotocol.client.McpAsyncClient#getTaskResult(McpSchema.GetTaskPayloadRequest, TypeRef)},
610+ * which is used for when the client has initiated a task with the server.
611+ *
612+ * <p>
613+ * Example usage:
614+ *
615+ * <pre>{@code
616+ * // For sampling task results:
617+ * var result = exchange.getTaskResult(
618+ * new GetTaskPayloadRequest(taskId, null),
619+ * new TypeRef<McpSchema.CreateMessageResult>(){})
620+ * .block();
621+ * }</pre>
622+ *
623+ * <p>
624+ * <strong>Note:</strong> This is an experimental feature that may change in future
625+ * releases.
626+ * @param <T> The expected result type, must extend
627+ * {@link McpSchema.ClientTaskPayloadResult}
628+ * @param getTaskPayloadRequest The request containing the task ID.
629+ * @param resultTypeRef Type reference for deserializing the result.
630+ * @return A Mono that completes with the task result.
631+ * @see McpSchema.GetTaskPayloadRequest
632+ * @see McpSchema.ClientTaskPayloadResult
555633 */
556634 public <T extends McpSchema .ClientTaskPayloadResult > Mono <T > getTaskResult (
557635 McpSchema .GetTaskPayloadRequest getTaskPayloadRequest , TypeRef <T > resultTypeRef ) {
@@ -565,6 +643,51 @@ public <T extends McpSchema.ClientTaskPayloadResult> Mono<T> getTaskResult(
565643 return this .session .sendRequest (McpSchema .METHOD_TASKS_RESULT , getTaskPayloadRequest , resultTypeRef );
566644 }
567645
646+ /**
647+ * Get the result of a completed task previously initiated by the server with the
648+ * client by its task ID.
649+ *
650+ * <p>
651+ * This is a convenience overload that creates a
652+ * {@link McpSchema.GetTaskPayloadRequest} from the task ID.
653+ *
654+ * <p>
655+ * The result type depends on the original request that created the task. For sampling
656+ * requests, use {@code new TypeRef<McpSchema.CreateMessageResult>(){}}. For
657+ * elicitation requests, use {@code new TypeRef<McpSchema.ElicitResult>(){}}.
658+ *
659+ * <p>
660+ * This method mirrors
661+ * {@link io.modelcontextprotocol.client.McpAsyncClient#getTaskResult(String, TypeRef)},
662+ * which is used for when the client has initiated a task with the server.
663+ *
664+ * <p>
665+ * Example usage:
666+ *
667+ * <pre>{@code
668+ * // For sampling task results:
669+ * var result = exchange.getTaskResult(
670+ * taskId,
671+ * new TypeRef<McpSchema.CreateMessageResult>(){})
672+ * .block();
673+ * }</pre>
674+ *
675+ * <p>
676+ * <strong>Note:</strong> This is an experimental feature that may change in future
677+ * releases.
678+ * @param <T> The expected result type, must extend
679+ * {@link McpSchema.ClientTaskPayloadResult}
680+ * @param taskId The task identifier.
681+ * @param resultTypeRef Type reference for deserializing the result.
682+ * @return A Mono that completes with the task result.
683+ * @see McpSchema.GetTaskPayloadRequest
684+ * @see McpSchema.ClientTaskPayloadResult
685+ */
686+ public <T extends McpSchema .ClientTaskPayloadResult > Mono <T > getTaskResult (String taskId ,
687+ TypeRef <T > resultTypeRef ) {
688+ return this .getTaskResult (McpSchema .GetTaskPayloadRequest .builder ().taskId (taskId ).build (), resultTypeRef );
689+ }
690+
568691 /**
569692 * List all tasks hosted by the client.
570693 *
0 commit comments