Skip to content

Commit f5a6e5c

Browse files
committed
chore: fix client documentation for getTaskResult
1 parent 8baba5e commit f5a6e5c

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
@@ -1617,12 +1617,17 @@ public Mono<McpSchema.GetTaskResult> getTask(String taskId) {
16171617
}
16181618

16191619
/**
1620-
* Get the result of a completed task.
1620+
* Get the result of a completed task previously initiated by the client with the
1621+
* server.
16211622
*
16221623
* <p>
16231624
* The result type depends on the original request that created the task. For tool
1624-
* calls, use {@code new TypeRef<McpSchema.CallToolResult>(){}}. For sampling
1625-
* requests, use {@code new TypeRef<McpSchema.CreateMessageResult>(){}}.
1625+
* calls, use {@code new TypeRef<McpSchema.CallToolResult>(){}}.
1626+
*
1627+
* <p>
1628+
* This method mirrors
1629+
* {@link io.modelcontextprotocol.server.McpSyncServerExchange#getTaskResult(McpSchema.GetTaskPayloadRequest, TypeRef)},
1630+
* which is used for when the server has initiated a task with the client.
16261631
*
16271632
* <p>
16281633
* Example usage:
@@ -1638,13 +1643,13 @@ public Mono<McpSchema.GetTaskResult> getTask(String taskId) {
16381643
* <p>
16391644
* <strong>Note:</strong> This is an experimental feature that may change in future
16401645
* releases.
1641-
* @param <T> The expected result type, must extend {@link McpSchema.Result}
1646+
* @param <T> The expected result type, must extend
1647+
* {@link McpSchema.ServerTaskPayloadResult}
16421648
* @param getTaskPayloadRequest The request containing the task ID.
16431649
* @param resultTypeRef Type reference for deserializing the result.
16441650
* @return A Mono that completes with the task result.
16451651
* @see McpSchema.GetTaskPayloadRequest
1646-
* @see McpSchema.CallToolResult
1647-
* @see McpSchema.CreateMessageResult
1652+
* @see McpSchema.ServerTaskPayloadResult
16481653
*/
16491654
public <T extends McpSchema.ServerTaskPayloadResult> Mono<T> getTaskResult(
16501655
McpSchema.GetTaskPayloadRequest getTaskPayloadRequest, TypeRef<T> resultTypeRef) {
@@ -1657,19 +1662,43 @@ public <T extends McpSchema.ServerTaskPayloadResult> Mono<T> getTaskResult(
16571662
}
16581663

16591664
/**
1660-
* Retrieves the result of a completed task by task ID.
1665+
* Get the result of a completed task previously initiated by the client with the
1666+
* server by its task ID.
16611667
*
16621668
* <p>
16631669
* This is a convenience overload that creates a
16641670
* {@link McpSchema.GetTaskPayloadRequest} from the task ID.
16651671
*
16661672
* <p>
1673+
* The result type depends on the original request that created the task. For tool
1674+
* calls, use {@code new TypeRef<McpSchema.CallToolResult>(){}}.
1675+
*
1676+
* <p>
1677+
* This method mirrors
1678+
* {@link io.modelcontextprotocol.server.McpAsyncServerExchange#getTaskResult(McpSchema.GetTaskPayloadRequest, TypeRef)},
1679+
* which is used for when the server has initiated a task with the client.
1680+
*
1681+
* <p>
1682+
* Example usage:
1683+
*
1684+
* <pre>{@code
1685+
* // For tool task results:
1686+
* var result = client.getTaskResult(
1687+
* taskId,
1688+
* new TypeRef<McpSchema.CallToolResult>(){})
1689+
* .block();
1690+
* }</pre>
1691+
*
1692+
* <p>
16671693
* <strong>Note:</strong> This is an experimental feature that may change in future
16681694
* releases.
1669-
* @param <T> The expected result type, must extend {@link McpSchema.Result}
1695+
* @param <T> The expected result type, must extend
1696+
* {@link McpSchema.ServerTaskPayloadResult}
16701697
* @param taskId The task identifier.
16711698
* @param resultTypeRef Type reference for deserializing the result.
16721699
* @return A Mono that completes with the task result.
1700+
* @see McpSchema.GetTaskPayloadRequest
1701+
* @see McpSchema.ServerTaskPayloadResult
16731702
*/
16741703
public <T extends McpSchema.ServerTaskPayloadResult> Mono<T> getTaskResult(String taskId,
16751704
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)