@@ -48,6 +48,11 @@ type CallToolParams struct {
4848 // Arguments holds the tool arguments. It can hold any value that can be
4949 // marshaled to JSON.
5050 Arguments any `json:"arguments,omitempty"`
51+ // Task optionally requests task-based execution of this tool call.
52+ //
53+ // Note: when Task is present, the wire response is a CreateTaskResult rather
54+ // than a CallToolResult.
55+ Task * TaskParams `json:"task,omitempty"`
5156}
5257
5358// CallToolParamsRaw is passed to tool handlers on the server. Its arguments
@@ -63,6 +68,8 @@ type CallToolParamsRaw struct {
6368 // is the responsibility of the tool handler to unmarshal and validate the
6469 // Arguments (see [AddTool]).
6570 Arguments json.RawMessage `json:"arguments,omitempty"`
71+ // Task optionally requests task-based execution of this tool call.
72+ Task * TaskParams `json:"task,omitempty"`
6673}
6774
6875// A CallToolResult is the server's response to a tool call.
@@ -210,13 +217,16 @@ type ClientCapabilities struct {
210217 Sampling * SamplingCapabilities `json:"sampling,omitempty"`
211218 // Elicitation is present if the client supports elicitation from the server.
212219 Elicitation * ElicitationCapabilities `json:"elicitation,omitempty"`
220+ // Tasks describes support for task-based execution.
221+ Tasks * TasksCapabilities `json:"tasks,omitempty"`
213222}
214223
215224// clone returns a deep copy of the ClientCapabilities.
216225func (c * ClientCapabilities ) clone () * ClientCapabilities {
217226 cp := * c
218227 cp .RootsV2 = shallowClone (c .RootsV2 )
219228 cp .Sampling = shallowClone (c .Sampling )
229+ cp .Tasks = shallowClone (c .Tasks )
220230 if c .Elicitation != nil {
221231 x := * c .Elicitation
222232 x .Form = shallowClone (c .Elicitation .Form )
@@ -1092,8 +1102,28 @@ type Tool struct {
10921102 Title string `json:"title,omitempty"`
10931103 // Icons for the tool, if any.
10941104 Icons []Icon `json:"icons,omitempty"`
1105+ // Execution contains optional execution-related settings.
1106+ Execution * ToolExecution `json:"execution,omitempty"`
1107+ }
1108+
1109+ // ToolExecution configures execution behavior for a tool.
1110+ type ToolExecution struct {
1111+ // TaskSupport declares task support for this tool.
1112+ //
1113+ // Valid values are: "required", "optional", or "forbidden".
1114+ // See ToolTaskSupportRequired, ToolTaskSupportOptional, and ToolTaskSupportForbidden.
1115+ TaskSupport string `json:"taskSupport,omitempty"`
10951116}
10961117
1118+ const (
1119+ // ToolTaskSupportRequired indicates the tool MUST be invoked with task augmentation.
1120+ ToolTaskSupportRequired = "required"
1121+ // ToolTaskSupportOptional indicates the tool MAY be invoked with task augmentation.
1122+ ToolTaskSupportOptional = "optional"
1123+ // ToolTaskSupportForbidden indicates the tool MUST NOT be invoked with task augmentation.
1124+ ToolTaskSupportForbidden = "forbidden"
1125+ )
1126+
10971127// Additional properties describing a Tool to clients.
10981128//
10991129// NOTE: all properties in ToolAnnotations are hints. They are not
@@ -1314,6 +1344,8 @@ type ServerCapabilities struct {
13141344 Resources * ResourceCapabilities `json:"resources,omitempty"`
13151345 // Tools is present if the supports tools.
13161346 Tools * ToolCapabilities `json:"tools,omitempty"`
1347+ // Tasks describes support for task-based execution.
1348+ Tasks * TasksCapabilities `json:"tasks,omitempty"`
13171349}
13181350
13191351// clone returns a deep copy of the ServerCapabilities.
@@ -1324,12 +1356,148 @@ func (c *ServerCapabilities) clone() *ServerCapabilities {
13241356 cp .Prompts = shallowClone (c .Prompts )
13251357 cp .Resources = shallowClone (c .Resources )
13261358 cp .Tools = shallowClone (c .Tools )
1359+ cp .Tasks = shallowClone (c .Tasks )
13271360 return & cp
13281361}
13291362
1363+ // TasksCapabilities describes support for task-based execution.
1364+ type TasksCapabilities struct {
1365+ List * TasksListCapabilities `json:"list,omitempty"`
1366+ Cancel * TasksCancelCapabilities `json:"cancel,omitempty"`
1367+ Requests * TasksRequestsCapabilities `json:"requests,omitempty"`
1368+ }
1369+
1370+ type TasksListCapabilities struct {}
1371+ type TasksCancelCapabilities struct {}
1372+
1373+ type TasksRequestsCapabilities struct {
1374+ Tools * TasksToolsRequestCapabilities `json:"tools,omitempty"`
1375+ Sampling * TasksSamplingRequestCapabilities `json:"sampling,omitempty"`
1376+ Elicitation * TasksElicitationRequestCapabilities `json:"elicitation,omitempty"`
1377+ }
1378+
1379+ type TasksToolsRequestCapabilities struct {
1380+ Call * TasksToolsCallCapabilities `json:"call,omitempty"`
1381+ }
1382+
1383+ type TasksToolsCallCapabilities struct {}
1384+
1385+ type TasksSamplingRequestCapabilities struct {
1386+ CreateMessage * TasksSamplingCreateMessageCapabilities `json:"createMessage,omitempty"`
1387+ }
1388+
1389+ type TasksSamplingCreateMessageCapabilities struct {}
1390+
1391+ type TasksElicitationRequestCapabilities struct {
1392+ Create * TasksElicitationCreateCapabilities `json:"create,omitempty"`
1393+ }
1394+
1395+ type TasksElicitationCreateCapabilities struct {}
1396+
1397+ // TaskParams is included in request parameters to request task-based execution.
1398+ type TaskParams struct {
1399+ TTL * int64 `json:"ttl,omitempty"`
1400+ }
1401+
1402+ type TaskStatus string
1403+
1404+ const (
1405+ TaskStatusWorking TaskStatus = "working"
1406+ TaskStatusInputRequired TaskStatus = "input_required"
1407+ TaskStatusCompleted TaskStatus = "completed"
1408+ TaskStatusFailed TaskStatus = "failed"
1409+ TaskStatusCancelled TaskStatus = "cancelled"
1410+ )
1411+
1412+ // Task describes the state of a task.
1413+ type Task struct {
1414+ Meta `json:"_meta,omitempty"`
1415+ TaskID string `json:"taskId"`
1416+ Status TaskStatus `json:"status"`
1417+ StatusMessage string `json:"statusMessage,omitempty"`
1418+ CreatedAt string `json:"createdAt"`
1419+ LastUpdatedAt string `json:"lastUpdatedAt"`
1420+ TTL * int64 `json:"ttl"`
1421+ PollInterval * int64 `json:"pollInterval,omitempty"`
1422+ }
1423+
1424+ // CreateTaskResult is returned for task-augmented requests.
1425+ type CreateTaskResult struct {
1426+ Meta `json:"_meta,omitempty"`
1427+ Task * Task `json:"task"`
1428+ }
1429+
1430+ func (* CreateTaskResult ) isResult () {}
1431+
1432+ type GetTaskParams struct {
1433+ Meta `json:"_meta,omitempty"`
1434+ TaskID string `json:"taskId"`
1435+ }
1436+
1437+ func (* GetTaskParams ) isParams () {}
1438+ func (x * GetTaskParams ) GetProgressToken () any { return getProgressToken (x ) }
1439+ func (x * GetTaskParams ) SetProgressToken (t any ) { setProgressToken (x , t ) }
1440+
1441+ type GetTaskResult Task
1442+
1443+ func (* GetTaskResult ) isResult () {}
1444+
1445+ type ListTasksParams struct {
1446+ Meta `json:"_meta,omitempty"`
1447+ Cursor string `json:"cursor,omitempty"`
1448+ }
1449+
1450+ func (x * ListTasksParams ) isParams () {}
1451+ func (x * ListTasksParams ) GetProgressToken () any { return getProgressToken (x ) }
1452+ func (x * ListTasksParams ) SetProgressToken (t any ) { setProgressToken (x , t ) }
1453+ func (x * ListTasksParams ) cursorPtr () * string { return & x .Cursor }
1454+
1455+ type ListTasksResult struct {
1456+ Meta `json:"_meta,omitempty"`
1457+ Tasks []* Task `json:"tasks"`
1458+ NextCursor string `json:"nextCursor,omitempty"`
1459+ }
1460+
1461+ func (* ListTasksResult ) isResult () {}
1462+ func (x * ListTasksResult ) nextCursorPtr () * string { return & x .NextCursor }
1463+
1464+ type CancelTaskParams struct {
1465+ Meta `json:"_meta,omitempty"`
1466+ TaskID string `json:"taskId"`
1467+ }
1468+
1469+ func (* CancelTaskParams ) isParams () {}
1470+ func (x * CancelTaskParams ) GetProgressToken () any { return getProgressToken (x ) }
1471+ func (x * CancelTaskParams ) SetProgressToken (t any ) { setProgressToken (x , t ) }
1472+
1473+ type CancelTaskResult Task
1474+
1475+ func (* CancelTaskResult ) isResult () {}
1476+
1477+ type TaskResultParams struct {
1478+ Meta `json:"_meta,omitempty"`
1479+ TaskID string `json:"taskId"`
1480+ }
1481+
1482+ func (* TaskResultParams ) isParams () {}
1483+ func (x * TaskResultParams ) GetProgressToken () any { return getProgressToken (x ) }
1484+ func (x * TaskResultParams ) SetProgressToken (t any ) { setProgressToken (x , t ) }
1485+
1486+ // TaskStatusNotificationParams is sent as notifications/tasks/status.
1487+ type TaskStatusNotificationParams Task
1488+
1489+ func (* TaskStatusNotificationParams ) isParams () {}
1490+ func (x * TaskStatusNotificationParams ) GetProgressToken () any { return getProgressToken (x ) }
1491+ func (x * TaskStatusNotificationParams ) SetProgressToken (t any ) { setProgressToken (x , t ) }
1492+
13301493const (
13311494 methodCallTool = "tools/call"
1495+ methodGetTask = "tasks/get"
1496+ methodListTasks = "tasks/list"
1497+ methodCancelTask = "tasks/cancel"
1498+ methodTaskResult = "tasks/result"
13321499 notificationCancelled = "notifications/cancelled"
1500+ notificationTaskStatus = "notifications/tasks/status"
13331501 methodComplete = "completion/complete"
13341502 methodCreateMessage = "sampling/createMessage"
13351503 methodElicit = "elicitation/create"
0 commit comments