MCPcopy Create free account
hub / github.com/astercloud/aster / Execute

Method Execute

pkg/tools/builtin/task.go:104–127  ·  view source on GitHub ↗
(ctx context.Context, input map[string]any, tc *tools.ToolContext)

Source from the content-addressed store, hash-verified

102}
103
104func (t *TaskTool) Execute(ctx context.Context, input map[string]any, tc *tools.ToolContext) (any, error) {
105 action := GetStringParam(input, "action", "run")
106
107 switch action {
108 case "list":
109 return t.listTasks()
110 case "status":
111 taskID := GetStringParam(input, "task_id", "")
112 if taskID == "" {
113 return NewClaudeErrorResponse(errors.New("task_id is required for status action")), nil
114 }
115 return t.getTaskStatus(taskID)
116 case "cancel":
117 taskID := GetStringParam(input, "task_id", "")
118 if taskID == "" {
119 return NewClaudeErrorResponse(errors.New("task_id is required for cancel action")), nil
120 }
121 return t.cancelTask(taskID)
122 case "run":
123 return t.runTask(ctx, input)
124 default:
125 return NewClaudeErrorResponse(fmt.Errorf("unknown action: %s", action)), nil
126 }
127}
128
129// listTasks 列出所有任务
130func (t *TaskTool) listTasks() (any, error) {

Callers 1

mainFunction · 0.95

Calls 6

listTasksMethod · 0.95
getTaskStatusMethod · 0.95
cancelTaskMethod · 0.95
runTaskMethod · 0.95
GetStringParamFunction · 0.85
NewClaudeErrorResponseFunction · 0.85

Tested by

no test coverage detected