@@ -206,10 +206,9 @@ default Object progressToken() {
206206
207207 }
208208
209- public sealed interface Result extends Meta permits CallToolAuxResult , CallToolResult , CancelTaskResult ,
210- CompleteResult , CreateMessageResult , CreateTaskResult , ElicitResult , GetPromptResult , GetTaskResult ,
211- InitializeResult , ListPromptsResult , ListResourceTemplatesResult , ListResourcesResult , ListRootsResult ,
212- ListTasksResult , ListToolsResult , ReadResourceResult {
209+ public sealed interface Result extends Meta permits CallToolResult , CancelTaskResult , CompleteResult ,
210+ CreateMessageResult , CreateTaskResult , ElicitResult , GetPromptResult , GetTaskPayloadResult , GetTaskResult ,
211+ InitializeResult , PaginatedResult , ReadResourceResult {
213212
214213 }
215214
@@ -1102,7 +1101,7 @@ public ResourceTemplate build() {
11021101 public record ListResourcesResult ( // @formatter:off
11031102 @ JsonProperty ("resources" ) List <Resource > resources ,
11041103 @ JsonProperty ("nextCursor" ) String nextCursor ,
1105- @ JsonProperty ("_meta" ) Map <String , Object > meta ) implements Result { // @formatter:on
1104+ @ JsonProperty ("_meta" ) Map <String , Object > meta ) implements PaginatedResult { // @formatter:on
11061105
11071106 public ListResourcesResult (List <Resource > resources , String nextCursor ) {
11081107 this (resources , nextCursor , null );
@@ -1122,7 +1121,7 @@ public ListResourcesResult(List<Resource> resources, String nextCursor) {
11221121 public record ListResourceTemplatesResult ( // @formatter:off
11231122 @ JsonProperty ("resourceTemplates" ) List <ResourceTemplate > resourceTemplates ,
11241123 @ JsonProperty ("nextCursor" ) String nextCursor ,
1125- @ JsonProperty ("_meta" ) Map <String , Object > meta ) implements Result { // @formatter:on
1124+ @ JsonProperty ("_meta" ) Map <String , Object > meta ) implements PaginatedResult { // @formatter:on
11261125
11271126 public ListResourceTemplatesResult (List <ResourceTemplate > resourceTemplates , String nextCursor ) {
11281127 this (resourceTemplates , nextCursor , null );
@@ -1348,7 +1347,7 @@ public record PromptMessage( // @formatter:off
13481347 public record ListPromptsResult ( // @formatter:off
13491348 @ JsonProperty ("prompts" ) List <Prompt > prompts ,
13501349 @ JsonProperty ("nextCursor" ) String nextCursor ,
1351- @ JsonProperty ("_meta" ) Map <String , Object > meta ) implements Result { // @formatter:on
1350+ @ JsonProperty ("_meta" ) Map <String , Object > meta ) implements PaginatedResult { // @formatter:on
13521351
13531352 public ListPromptsResult (List <Prompt > prompts , String nextCursor ) {
13541353 this (prompts , nextCursor , null );
@@ -1409,7 +1408,7 @@ public GetPromptResult(String description, List<PromptMessage> messages) {
14091408 public record ListToolsResult ( // @formatter:off
14101409 @ JsonProperty ("tools" ) List <Tool > tools ,
14111410 @ JsonProperty ("nextCursor" ) String nextCursor ,
1412- @ JsonProperty ("_meta" ) Map <String , Object > meta ) implements Result { // @formatter:on
1411+ @ JsonProperty ("_meta" ) Map <String , Object > meta ) implements PaginatedResult { // @formatter:on
14131412
14141413 public ListToolsResult (List <Tool > tools , String nextCursor ) {
14151414 this (tools , nextCursor , null );
@@ -1438,7 +1437,7 @@ public record JsonSchema( // @formatter:off
14381437 }
14391438
14401439 /**
1441- * Execution behavior for a tool.
1440+ * Execution-related properties for a tool.
14421441 */
14431442 @ JsonInclude (JsonInclude .Include .NON_ABSENT )
14441443 @ JsonIgnoreProperties (ignoreUnknown = true )
@@ -1705,25 +1704,29 @@ private static JsonSchema parseSchema(McpJsonMapper jsonMapper, String schema) {
17051704 }
17061705
17071706 /**
1708- * Metadata about a task.
1707+ * Metadata for augmenting a request with task execution. Include this in the
1708+ * {@code task} field of the request parameters.
17091709 *
1710- * @param ttl Optional time to live for the task, in milliseconds .
1710+ * @param ttl Optional duration in milliseconds to retain task from creation .
17111711 */
17121712 @ JsonInclude (JsonInclude .Include .NON_ABSENT )
17131713 @ JsonIgnoreProperties (ignoreUnknown = true )
17141714 public record TaskMetaData (@ JsonProperty ("ttl" ) Long ttl ) {
17151715 }
17161716
17171717 /**
1718- * Related task metadata.
1718+ * Metadata for associating messages with a task. Include this in the {@code _meta}
1719+ * field under the key {@code io.modelcontextprotocol/related-task}.
1720+ *
1721+ * @param taskId The task identifier this message is associated with.
17191722 */
17201723 @ JsonInclude (JsonInclude .Include .NON_ABSENT )
17211724 @ JsonIgnoreProperties (ignoreUnknown = true )
17221725 public record RelatedTaskMetaData (@ JsonProperty ("taskId" ) String taskId ) {
17231726 }
17241727
17251728 /**
1726- * Task information interface .
1729+ * Data associated with a task .
17271730 */
17281731 public interface TaskInfo {
17291732
@@ -1870,9 +1873,9 @@ public record CreateTaskResult( // @formatter:off
18701873 }
18711874
18721875 /**
1873- * A request to get task status .
1876+ * A request to retrieve the state of a task .
18741877 *
1875- * @param taskId The ID of the task to retrieve.
1878+ * @param taskId The task identifier to retrieve.
18761879 * @param meta Optional metadata about the request.
18771880 */
18781881 @ JsonInclude (JsonInclude .Include .NON_ABSENT )
@@ -1908,9 +1911,11 @@ public record GetTaskResult( // @formatter:off
19081911 }
19091912
19101913 /**
1911- * A request to get task payload.
1914+ * The response to a tasks/result request. The structure matches the result type of
1915+ * the original request. For example, a tools/call task would return the
1916+ * CallToolResult structure.
19121917 *
1913- * @param taskId task ID
1918+ * @param taskId The task identifier to retrieve results for.
19141919 * @param meta Optional metadata about the request.
19151920 */
19161921 @ JsonInclude (JsonInclude .Include .NON_ABSENT )
@@ -1920,6 +1925,15 @@ public record getTaskPayloadRequest( // @formatter:off
19201925 @ JsonProperty ("_meta" ) Map <String , Object > meta ) implements Request { // @formatter:on
19211926 }
19221927
1928+ /**
1929+ * The response to a tasks/result request. The structure matches the result type of
1930+ * the original request. For example, a tools/call task would return the
1931+ * CallToolResult structure.
1932+ */
1933+ sealed interface GetTaskPayloadResult extends Result {
1934+
1935+ }
1936+
19231937 /**
19241938 * A request to cancel a task.
19251939 *
@@ -1932,7 +1946,7 @@ public record CancelTaskRequest( // @formatter:off
19321946 }
19331947
19341948 /**
1935- * The response to a cancel task request.
1949+ * The response to a tasks/ cancel request.
19361950 *
19371951 * @param taskId task ID
19381952 * @param status task status
@@ -1970,7 +1984,7 @@ public record CancelTaskResult( // @formatter:off
19701984 public record ListTasksResult ( // @formatter:off
19711985 @ JsonProperty ("tasks" ) List <Task > tasks ,
19721986 @ JsonProperty ("nextCursor" ) String nextCursor ,
1973- @ JsonProperty ("_meta" ) Map <String , Object > meta ) implements Result { // @formatter:on
1987+ @ JsonProperty ("_meta" ) Map <String , Object > meta ) implements PaginatedResult { // @formatter:on
19741988 }
19751989
19761990 /**
@@ -2128,38 +2142,6 @@ public static TaskStatus fromValue(String value) {
21282142
21292143 }
21302144
2131- /**
2132- * The server's response to a tools/call request from the client, which can be
2133- * `CallToolResult` or `CreateTaskResult`.
2134- *
2135- * @param content A list of content items representing the tool's output. Each item
2136- * can be text, an image, or an embedded resource.
2137- * @param isError If true, indicates that the tool execution failed and the content
2138- * contains error information. If false or absent, indicates successful execution.
2139- * @param structuredContent An optional JSON object that represents the structured
2140- * result of the tool call.
2141- * @param task Task information when the tool is invoked as a task.
2142- * @param meta See specification for notes on _meta usage
2143- */
2144- @ JsonInclude (JsonInclude .Include .NON_ABSENT )
2145- @ JsonIgnoreProperties (ignoreUnknown = true )
2146- public record CallToolAuxResult ( // @formatter:off
2147- @ JsonProperty ("content" ) List <Content > content ,
2148- @ JsonProperty ("isError" ) Boolean isError ,
2149- @ JsonProperty ("structuredContent" ) Object structuredContent ,
2150- @ JsonProperty ("task" ) Task task ,
2151- @ JsonProperty ("_meta" ) Map <String , Object > meta ) implements Result {
2152-
2153- public CreateTaskResult toCreateTaskResult () {
2154- return new CreateTaskResult (task , meta );
2155- }
2156-
2157- public CallToolResult toCallToolResult () {
2158- return new CallToolResult (content , isError , structuredContent , meta );
2159- }
2160-
2161- } // @formatter:on
2162-
21632145 /**
21642146 * The server's response to a tools/call request from the client.
21652147 *
@@ -2169,6 +2151,7 @@ public CallToolResult toCallToolResult() {
21692151 * contains error information. If false or absent, indicates successful execution.
21702152 * @param structuredContent An optional JSON object that represents the structured
21712153 * result of the tool call.
2154+ * @param task Task information when the tool is invoked as a task.
21722155 * @param meta See specification for notes on _meta usage
21732156 */
21742157 @ JsonInclude (JsonInclude .Include .NON_ABSENT )
@@ -2177,22 +2160,31 @@ public record CallToolResult( // @formatter:off
21772160 @ JsonProperty ("content" ) List <Content > content ,
21782161 @ JsonProperty ("isError" ) Boolean isError ,
21792162 @ JsonProperty ("structuredContent" ) Object structuredContent ,
2180- @ JsonProperty ("_meta" ) Map <String , Object > meta ) implements Result { // @formatter:on
2163+ @ JsonProperty ("task" ) Task task ,
2164+ @ JsonProperty ("_meta" ) Map <String , Object > meta ) implements Result , GetTaskPayloadResult { // @formatter:on
21812165
21822166 /**
21832167 * @deprecated use the builder instead.
21842168 */
21852169 @ Deprecated
21862170 public CallToolResult (List <Content > content , Boolean isError ) {
2187- this (content , isError , (Object ) null , null );
2171+ this (content , isError , (Object ) null , null , null );
21882172 }
21892173
21902174 /**
21912175 * @deprecated use the builder instead.
21922176 */
21932177 @ Deprecated
21942178 public CallToolResult (List <Content > content , Boolean isError , Map <String , Object > structuredContent ) {
2195- this (content , isError , structuredContent , null );
2179+ this (content , isError , structuredContent , null , null );
2180+ }
2181+
2182+ /**
2183+ * Binary compatibility constructor
2184+ */
2185+ public CallToolResult (List <Content > content , Boolean isError , Map <String , Object > structuredContent ,
2186+ Map <String , Object > meta ) {
2187+ this (content , isError , structuredContent , null , meta );
21962188 }
21972189
21982190 /**
@@ -2228,6 +2220,8 @@ public static class Builder {
22282220
22292221 private Object structuredContent ;
22302222
2223+ private Task task ;
2224+
22312225 private Map <String , Object > meta ;
22322226
22332227 /**
@@ -2314,12 +2308,22 @@ public Builder meta(Map<String, Object> meta) {
23142308 return this ;
23152309 }
23162310
2311+ /**
2312+ * Sets the task information for the tool result.
2313+ * @param task task information
2314+ * @return this builder
2315+ */
2316+ public Builder task (Task task ) {
2317+ this .task = task ;
2318+ return this ;
2319+ }
2320+
23172321 /**
23182322 * Builds a new {@link CallToolResult} instance.
23192323 * @return a new CallToolResult instance
23202324 */
23212325 public CallToolResult build () {
2322- return new CallToolResult (content , isError , structuredContent , meta );
2326+ return new CallToolResult (content , isError , structuredContent , task , meta );
23232327 }
23242328
23252329 }
@@ -2861,15 +2865,17 @@ public PaginatedRequest() {
28612865 }
28622866
28632867 /**
2864- * An opaque token representing the pagination position after the last returned
2865- * result. If present, there may be more results available.
2866- *
2867- * @param nextCursor An opaque token representing the pagination position after the
2868- * last returned result. If present, there may be more results available
2868+ * Pagination result interface.
28692869 */
2870- @ JsonInclude (JsonInclude .Include .NON_ABSENT )
2871- @ JsonIgnoreProperties (ignoreUnknown = true )
2872- public record PaginatedResult (@ JsonProperty ("nextCursor" ) String nextCursor ) {
2870+ sealed interface PaginatedResult extends Result permits ListResourceTemplatesResult , ListResourcesResult ,
2871+ ListRootsResult , ListPromptsResult , ListToolsResult , ListTasksResult {
2872+
2873+ /**
2874+ * An opaque token representing the pagination position after the ast returned
2875+ * result. If present, there may be more results available
2876+ */
2877+ String nextCursor ();
2878+
28732879 }
28742880
28752881 // ---------------------------
@@ -3534,7 +3540,7 @@ public Root(String uri, String name) {
35343540 public record ListRootsResult ( // @formatter:off
35353541 @ JsonProperty ("roots" ) List <Root > roots ,
35363542 @ JsonProperty ("nextCursor" ) String nextCursor ,
3537- @ JsonProperty ("_meta" ) Map <String , Object > meta ) implements Result { // @formatter:on
3543+ @ JsonProperty ("_meta" ) Map <String , Object > meta ) implements PaginatedResult { // @formatter:on
35383544
35393545 public ListRootsResult (List <Root > roots ) {
35403546 this (roots , null );
0 commit comments