@@ -1438,20 +1438,28 @@ public record JsonSchema( // @formatter:off
14381438 }
14391439
14401440 /**
1441- * The task hint.
1441+ * Execution behavior for a tool.
1442+ */
1443+ @ JsonInclude (JsonInclude .Include .NON_ABSENT )
1444+ @ JsonIgnoreProperties (ignoreUnknown = true )
1445+ public record ToolExecution (TaskSupport task ) {
1446+ }
1447+
1448+ /**
1449+ * The task augmented support mode for a tool.
14421450 * <p>
1443- * If taskHint is {@code always}, clients SHOULD invoke the tool as a task. Servers
1444- * MAY return a -32601 (Method not found) error if a client does not attempt to do so.
1451+ * If mode is {@code always}, clients SHOULD invoke the tool as a task. Servers MAY
1452+ * return a -32601 (Method not found) error if a client does not attempt to do so.
14451453 * <p>
1446- * If taskHint is {@code optional}, clients MAY invoke the tool as a task or as a
1447- * normal request.
1454+ * If mode is {@code optional}, clients MAY invoke the tool as a task or as a normal
1455+ * request.
14481456 * <p>
1449- * If taskHint is not present or {@code never}, clients MUST NOT attempt to invoke the
1457+ * If mode is not present or {@code never}, clients MUST NOT attempt to invoke the
14501458 * tool as a task. Servers SHOULD return a -32601 (Method not found) error if a client
14511459 * attempts to do so. This is the default behavior.
14521460 *
14531461 */
1454- public enum TaskHint {
1462+ public enum TaskSupport {
14551463
14561464 // @formatter:off
14571465 @ JsonProperty ("always" ) ALWAYS ("always" ),
@@ -1461,21 +1469,21 @@ public enum TaskHint {
14611469
14621470 private final String value ;
14631471
1464- TaskHint (final String value ) {
1472+ TaskSupport (final String value ) {
14651473 this .value = value ;
14661474 }
14671475
14681476 public String getValue () {
14691477 return value ;
14701478 }
14711479
1472- public static TaskHint fromValue (String value ) {
1473- for (TaskHint hint : TaskHint .values ()) {
1480+ public static TaskSupport fromValue (String value ) {
1481+ for (TaskSupport hint : TaskSupport .values ()) {
14741482 if (hint .value .equalsIgnoreCase (value )) {
14751483 return hint ;
14761484 }
14771485 }
1478- throw new IllegalArgumentException ("Unknown TaskHint value: " + value );
1486+ throw new IllegalArgumentException ("Unknown task support value: " + value );
14791487 }
14801488
14811489 }
@@ -1498,8 +1506,7 @@ public record ToolAnnotations( // @formatter:off
14981506 @ JsonProperty ("destructiveHint" ) Boolean destructiveHint ,
14991507 @ JsonProperty ("idempotentHint" ) Boolean idempotentHint ,
15001508 @ JsonProperty ("openWorldHint" ) Boolean openWorldHint ,
1501- @ JsonProperty ("returnDirect" ) Boolean returnDirect ,
1502- @ JsonProperty ("taskHint" ) TaskHint taskHint ) { // @formatter:on
1509+ @ JsonProperty ("returnDirect" ) Boolean returnDirect ) { // @formatter:on
15031510
15041511 public static Builder builder () {
15051512 return new Builder ();
@@ -1519,8 +1526,6 @@ public static class Builder {
15191526
15201527 private boolean returnDirect ;
15211528
1522- private TaskHint taskHint ;
1523-
15241529 public Builder title (String title ) {
15251530 this .title = title ;
15261531 return this ;
@@ -1551,14 +1556,9 @@ public Builder returnDirect(boolean returnDirect) {
15511556 return this ;
15521557 }
15531558
1554- public Builder taskHint (TaskHint taskHint ) {
1555- this .taskHint = taskHint ;
1556- return this ;
1557- }
1558-
15591559 public ToolAnnotations build () {
15601560 return new ToolAnnotations (title , readOnlyHint , destructiveHint , idempotentHint , openWorldHint ,
1561- returnDirect , taskHint );
1561+ returnDirect );
15621562 }
15631563
15641564 }
@@ -1576,6 +1576,7 @@ public ToolAnnotations build() {
15761576 * used by clients to improve the LLM's understanding of available tools.
15771577 * @param inputSchema A JSON Schema object that describes the expected structure of
15781578 * the arguments when calling this tool. This allows clients to validate tool
1579+ * @param execution The execution behavior for the tool.
15791580 * @param outputSchema An optional JSON Schema object defining the structure of the
15801581 * tool's output returned in the structuredContent field of a CallToolResult.
15811582 * @param annotations Optional additional tool information.
@@ -1589,9 +1590,24 @@ public record Tool( // @formatter:off
15891590 @ JsonProperty ("description" ) String description ,
15901591 @ JsonProperty ("inputSchema" ) JsonSchema inputSchema ,
15911592 @ JsonProperty ("outputSchema" ) Map <String , Object > outputSchema ,
1593+ @ JsonProperty ("execution" ) ToolExecution execution ,
15921594 @ JsonProperty ("annotations" ) ToolAnnotations annotations ,
15931595 @ JsonProperty ("_meta" ) Map <String , Object > meta ) { // @formatter:on
15941596
1597+ /**
1598+ * @deprecated keep for backwards compatibility
1599+ */
1600+ public Tool ( // @formatter:off
1601+ String name ,
1602+ String title ,
1603+ String description ,
1604+ JsonSchema inputSchema ,
1605+ Map <String , Object > outputSchema ,
1606+ ToolAnnotations annotations ,
1607+ Map <String , Object > meta ) { // @formatter:on
1608+ this (name , title , description , inputSchema , outputSchema , null , annotations , meta );
1609+ }
1610+
15951611 public static Builder builder () {
15961612 return new Builder ();
15971613 }
@@ -1608,6 +1624,8 @@ public static class Builder {
16081624
16091625 private Map <String , Object > outputSchema ;
16101626
1627+ private ToolExecution execution ;
1628+
16111629 private ToolAnnotations annotations ;
16121630
16131631 private Map <String , Object > meta ;
@@ -1647,6 +1665,11 @@ public Builder outputSchema(McpJsonMapper jsonMapper, String outputSchema) {
16471665 return this ;
16481666 }
16491667
1668+ public Builder execution (ToolExecution execution ) {
1669+ this .execution = execution ;
1670+ return this ;
1671+ }
1672+
16501673 public Builder annotations (ToolAnnotations annotations ) {
16511674 this .annotations = annotations ;
16521675 return this ;
@@ -1659,7 +1682,7 @@ public Builder meta(Map<String, Object> meta) {
16591682
16601683 public Tool build () {
16611684 Assert .hasText (name , "name must not be empty" );
1662- return new Tool (name , title , description , inputSchema , outputSchema , annotations , meta );
1685+ return new Tool (name , title , description , inputSchema , outputSchema , execution , annotations , meta );
16631686 }
16641687
16651688 }
0 commit comments