@@ -509,13 +509,27 @@ public TaskStore<McpSchema.ClientTaskPayloadResult> getTaskStore() {
509509 }
510510
511511 /**
512- * Get the status and metadata of a task.
512+ * Retrieves a task previously initiated by the client with the server.
513+ *
514+ * <p>
515+ * This method mirrors
516+ * {@link io.modelcontextprotocol.server.McpSyncServerExchange#getTask(McpSchema.GetTaskRequest)},
517+ * which is used for when the server has initiated a task with the client.
518+ *
519+ * <p>
520+ * Example usage:
521+ *
522+ * <pre>{@code
523+ * var result = client.getTask(GetTaskRequest.builder()
524+ * .taskId(taskId)
525+ * .build());
526+ * }</pre>
513527 *
514528 * <p>
515529 * <strong>Note:</strong> This is an experimental feature that may change in future
516530 * releases.
517531 * @param getTaskRequest The request containing the task ID.
518- * @return The task status and metadata .
532+ * @return The task information .
519533 * @see McpSchema.GetTaskRequest
520534 * @see McpSchema.GetTaskResult
521535 */
@@ -524,21 +538,33 @@ public McpSchema.GetTaskResult getTask(McpSchema.GetTaskRequest getTaskRequest)
524538 }
525539
526540 /**
527- * Get the status and metadata of a task by ID.
541+ * Retrieves a task previously initiated by the client with the server by its ID.
542+ *
543+ * <p>
544+ * This method mirrors
545+ * {@link io.modelcontextprotocol.server.McpSyncServerExchange#getTask(McpSchema.GetTaskRequest)},
546+ * which is used for when the server has initiated a task with the client.
528547 *
529548 * <p>
530549 * This is a convenience overload that creates a {@link McpSchema.GetTaskRequest} with
531550 * the given task ID.
532551 *
533552 * <p>
553+ * Example usage:
554+ *
555+ * <pre>{@code
556+ * var result = client.getTask(taskId);
557+ * }</pre>
558+ *
559+ * <p>
534560 * <strong>Note:</strong> This is an experimental feature that may change in future
535561 * releases.
536562 * @param taskId The task identifier to query.
537- * @return The task status and metadata .
563+ * @return The task information .
538564 */
539565 public McpSchema .GetTaskResult getTask (String taskId ) {
540566 Assert .hasText (taskId , "Task ID must not be null or empty" );
541- return getTask ( McpSchema . GetTaskRequest . builder (). taskId ( taskId ). build () );
567+ return withProvidedContext ( this . delegate . getTask ( taskId )). block ( );
542568 }
543569
544570 /**
@@ -560,7 +586,7 @@ public McpSchema.GetTaskResult getTask(String taskId) {
560586 * <pre>{@code
561587 * // For tool task results:
562588 * var result = client.getTaskResult(
563- * new GetTaskPayloadRequest( taskId, null ),
589+ * GetTaskPayloadRequest.builder(). taskId(taskId).build( ),
564590 * new TypeRef<McpSchema.CallToolResult>(){});
565591 * }</pre>
566592 *
@@ -619,6 +645,7 @@ public <T extends McpSchema.ServerTaskPayloadResult> T getTaskResult(
619645 * @see McpSchema.ServerTaskPayloadResult
620646 */
621647 public <T extends McpSchema .ServerTaskPayloadResult > T getTaskResult (String taskId , TypeRef <T > resultTypeRef ) {
648+ Assert .hasText (taskId , "Task ID must not be null or empty" );
622649 return withProvidedContext (this .delegate .getTaskResult (taskId , resultTypeRef )).block ();
623650 }
624651
0 commit comments