Skip to content

Commit c238541

Browse files
committed
chore: fix client documentation for getTaskResult
1 parent 3e52ee5 commit c238541

File tree

2 files changed

+83
-16
lines changed

2 files changed

+83
-16
lines changed

mcp-core/src/main/java/io/modelcontextprotocol/client/McpAsyncClient.java

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,12 +1622,17 @@ public Mono<McpSchema.GetTaskResult> getTask(String taskId) {
16221622
}
16231623

16241624
/**
1625-
* Get the result of a completed task.
1625+
* Get the result of a completed task previously initiated by the client with the
1626+
* server.
16261627
*
16271628
* <p>
16281629
* The result type depends on the original request that created the task. For tool
1629-
* calls, use {@code new TypeRef<McpSchema.CallToolResult>(){}}. For sampling
1630-
* requests, use {@code new TypeRef<McpSchema.CreateMessageResult>(){}}.
1630+
* calls, use {@code new TypeRef<McpSchema.CallToolResult>(){}}.
1631+
*
1632+
* <p>
1633+
* This method mirrors
1634+
* {@link io.modelcontextprotocol.server.McpSyncServerExchange#getTaskResult(McpSchema.GetTaskPayloadRequest, TypeRef)},
1635+
* which is used for when the server has initiated a task with the client.
16311636
*
16321637
* <p>
16331638
* Example usage:
@@ -1643,13 +1648,13 @@ public Mono<McpSchema.GetTaskResult> getTask(String taskId) {
16431648
* <p>
16441649
* <strong>Note:</strong> This is an experimental feature that may change in future
16451650
* releases.
1646-
* @param <T> The expected result type, must extend {@link McpSchema.Result}
1651+
* @param <T> The expected result type, must extend
1652+
* {@link McpSchema.ServerTaskPayloadResult}
16471653
* @param getTaskPayloadRequest The request containing the task ID.
16481654
* @param resultTypeRef Type reference for deserializing the result.
16491655
* @return A Mono that completes with the task result.
16501656
* @see McpSchema.GetTaskPayloadRequest
1651-
* @see McpSchema.CallToolResult
1652-
* @see McpSchema.CreateMessageResult
1657+
* @see McpSchema.ServerTaskPayloadResult
16531658
*/
16541659
public <T extends McpSchema.ServerTaskPayloadResult> Mono<T> getTaskResult(
16551660
McpSchema.GetTaskPayloadRequest getTaskPayloadRequest, TypeRef<T> resultTypeRef) {
@@ -1662,19 +1667,43 @@ public <T extends McpSchema.ServerTaskPayloadResult> Mono<T> getTaskResult(
16621667
}
16631668

16641669
/**
1665-
* Retrieves the result of a completed task by task ID.
1670+
* Get the result of a completed task previously initiated by the client with the
1671+
* server by its task ID.
16661672
*
16671673
* <p>
16681674
* This is a convenience overload that creates a
16691675
* {@link McpSchema.GetTaskPayloadRequest} from the task ID.
16701676
*
16711677
* <p>
1678+
* The result type depends on the original request that created the task. For tool
1679+
* calls, use {@code new TypeRef<McpSchema.CallToolResult>(){}}.
1680+
*
1681+
* <p>
1682+
* This method mirrors
1683+
* {@link io.modelcontextprotocol.server.McpAsyncServerExchange#getTaskResult(McpSchema.GetTaskPayloadRequest, TypeRef)},
1684+
* which is used for when the server has initiated a task with the client.
1685+
*
1686+
* <p>
1687+
* Example usage:
1688+
*
1689+
* <pre>{@code
1690+
* // For tool task results:
1691+
* var result = client.getTaskResult(
1692+
* taskId,
1693+
* new TypeRef<McpSchema.CallToolResult>(){})
1694+
* .block();
1695+
* }</pre>
1696+
*
1697+
* <p>
16721698
* <strong>Note:</strong> This is an experimental feature that may change in future
16731699
* releases.
1674-
* @param <T> The expected result type, must extend {@link McpSchema.Result}
1700+
* @param <T> The expected result type, must extend
1701+
* {@link McpSchema.ServerTaskPayloadResult}
16751702
* @param taskId The task identifier.
16761703
* @param resultTypeRef Type reference for deserializing the result.
16771704
* @return A Mono that completes with the task result.
1705+
* @see McpSchema.GetTaskPayloadRequest
1706+
* @see McpSchema.ServerTaskPayloadResult
16781707
*/
16791708
public <T extends McpSchema.ServerTaskPayloadResult> Mono<T> getTaskResult(String taskId,
16801709
TypeRef<T> resultTypeRef) {

mcp-core/src/main/java/io/modelcontextprotocol/client/McpSyncClient.java

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -542,43 +542,81 @@ public McpSchema.GetTaskResult getTask(String taskId) {
542542
}
543543

544544
/**
545-
* Get the result of a completed task.
545+
* Get the result of a completed task previously initiated by the client with the
546+
* server.
546547
*
547548
* <p>
548549
* The result type depends on the original request that created the task. For tool
549-
* calls, use {@code new TypeRef<McpSchema.CallToolResult>(){}}. For sampling
550-
* requests, use {@code new TypeRef<McpSchema.CreateMessageResult>(){}}.
550+
* calls, use {@code new TypeRef<McpSchema.CallToolResult>(){}}.
551+
*
552+
* <p>
553+
* This method mirrors
554+
* {@link io.modelcontextprotocol.server.McpSyncServerExchange#getTaskResult(McpSchema.GetTaskPayloadRequest, TypeRef)},
555+
* which is used for when the server has initiated a task with the client.
556+
*
557+
* <p>
558+
* Example usage:
559+
*
560+
* <pre>{@code
561+
* // For tool task results:
562+
* var result = client.getTaskResult(
563+
* new GetTaskPayloadRequest(taskId, null),
564+
* new TypeRef<McpSchema.CallToolResult>(){});
565+
* }</pre>
551566
*
552567
* <p>
553568
* <strong>Note:</strong> This is an experimental feature that may change in future
554569
* releases.
555-
* @param <T> The expected result type, must extend {@link McpSchema.Result}
570+
* @param <T> The expected result type, must extend
571+
* {@link McpSchema.ServerTaskPayloadResult}
556572
* @param getTaskPayloadRequest The request containing the task ID.
557573
* @param resultTypeRef Type reference for deserializing the result.
558574
* @return The task result.
559575
* @see McpSchema.GetTaskPayloadRequest
560-
* @see McpSchema.CallToolResult
561-
* @see McpSchema.CreateMessageResult
576+
* @see McpSchema.ServerTaskPayloadResult
562577
*/
563578
public <T extends McpSchema.ServerTaskPayloadResult> T getTaskResult(
564579
McpSchema.GetTaskPayloadRequest getTaskPayloadRequest, TypeRef<T> resultTypeRef) {
565580
return withProvidedContext(this.delegate.getTaskResult(getTaskPayloadRequest, resultTypeRef)).block();
566581
}
567582

568583
/**
569-
* Retrieves the result of a completed task by task ID.
584+
* Get the result of a completed task previously initiated by the client with the
585+
* server by its task ID.
570586
*
571587
* <p>
572588
* This is a convenience overload that creates a
573589
* {@link McpSchema.GetTaskPayloadRequest} from the task ID.
574590
*
575591
* <p>
592+
* The result type depends on the original request that created the task. For tool
593+
* calls, use {@code new TypeRef<McpSchema.CallToolResult>(){}}.
594+
*
595+
* <p>
596+
* This method mirrors
597+
* {@link io.modelcontextprotocol.server.McpSyncServerExchange#getTaskResult(McpSchema.GetTaskPayloadRequest, TypeRef)},
598+
* which is used for when the server has initiated a task with the client.
599+
*
600+
* <p>
601+
* Example usage:
602+
*
603+
* <pre>{@code
604+
* // For tool task results:
605+
* var result = client.getTaskResult(
606+
* taskId,
607+
* new TypeRef<McpSchema.CallToolResult>(){});
608+
* }</pre>
609+
*
610+
* <p>
576611
* <strong>Note:</strong> This is an experimental feature that may change in future
577612
* releases.
578-
* @param <T> The expected result type, must extend {@link McpSchema.Result}
613+
* @param <T> The expected result type, must extend
614+
* {@link McpSchema.ServerTaskPayloadResult}
579615
* @param taskId The task identifier.
580616
* @param resultTypeRef Type reference for deserializing the result.
581617
* @return The task result.
618+
* @see McpSchema.GetTaskPayloadRequest
619+
* @see McpSchema.ServerTaskPayloadResult
582620
*/
583621
public <T extends McpSchema.ServerTaskPayloadResult> T getTaskResult(String taskId, TypeRef<T> resultTypeRef) {
584622
return withProvidedContext(this.delegate.getTaskResult(taskId, resultTypeRef)).block();

0 commit comments

Comments
 (0)