MCPcopy Create free account
hub / github.com/driangle/taskmd / handleGet

Function handleGet

apps/cli/internal/mcp/get.go:53–84  ·  view source on GitHub ↗
(_ context.Context, _ *gomcp.CallToolRequest, input GetInput)

Source from the content-addressed store, hash-verified

51}
52
53func handleGet(_ context.Context, _ *gomcp.CallToolRequest, input GetInput) (*gomcp.CallToolResult, any, error) {
54 if input.TaskID == "" {
55 return nil, nil, fmt.Errorf("task_id is required")
56 }
57
58 taskDir := input.TaskDir
59 if taskDir == "" {
60 taskDir = "."
61 }
62
63 taskScanner := scanner.NewScanner(taskDir, false, nil)
64 result, err := taskScanner.Scan()
65 if err != nil {
66 return nil, nil, fmt.Errorf("scan failed: %w", err)
67 }
68
69 task := findTaskByID(input.TaskID, result.Tasks)
70 if task == nil {
71 return nil, nil, fmt.Errorf("task not found: %s", input.TaskID)
72 }
73
74 out := buildGetOutput(task, result.Tasks)
75
76 data, err := json.Marshal(out)
77 if err != nil {
78 return nil, nil, fmt.Errorf("json marshal failed: %w", err)
79 }
80
81 return &gomcp.CallToolResult{
82 Content: []gomcp.Content{&gomcp.TextContent{Text: string(data)}},
83 }, nil, nil
84}
85
86func findTaskByID(id string, tasks []*model.Task) *model.Task {
87 for _, t := range tasks {

Callers

nothing calls this directly

Calls 3

ScanMethod · 0.95
findTaskByIDFunction · 0.70
buildGetOutputFunction · 0.70

Tested by

no test coverage detected