(_ context.Context, _ *gomcp.CallToolRequest, input ContextInput)
| 30 | } |
| 31 | |
| 32 | func handleContext(_ context.Context, _ *gomcp.CallToolRequest, input ContextInput) (*gomcp.CallToolResult, any, error) { |
| 33 | if input.TaskID == "" { |
| 34 | return nil, nil, fmt.Errorf("task_id is required") |
| 35 | } |
| 36 | |
| 37 | taskDir := input.TaskDir |
| 38 | if taskDir == "" { |
| 39 | taskDir = "." |
| 40 | } |
| 41 | |
| 42 | taskScanner := scanner.NewScanner(taskDir, false, nil) |
| 43 | result, err := taskScanner.Scan() |
| 44 | if err != nil { |
| 45 | return nil, nil, fmt.Errorf("scan failed: %w", err) |
| 46 | } |
| 47 | |
| 48 | task := findTaskByID(input.TaskID, result.Tasks) |
| 49 | if task == nil { |
| 50 | return nil, nil, fmt.Errorf("task not found: %s", input.TaskID) |
| 51 | } |
| 52 | |
| 53 | projectRoot := input.ProjectRoot |
| 54 | if projectRoot == "" { |
| 55 | projectRoot = "." |
| 56 | } |
| 57 | |
| 58 | opts := taskcontext.Options{ |
| 59 | Scopes: taskcontext.ScopeMap(input.Scopes), |
| 60 | ProjectRoot: projectRoot, |
| 61 | Resolve: input.Resolve, |
| 62 | IncludeContent: input.IncludeContent, |
| 63 | MaxFiles: input.MaxFiles, |
| 64 | } |
| 65 | |
| 66 | ctxResult, err := taskcontext.Resolve(task, opts) |
| 67 | if err != nil { |
| 68 | return nil, nil, fmt.Errorf("context resolution failed: %w", err) |
| 69 | } |
| 70 | |
| 71 | data, err := json.Marshal(ctxResult) |
| 72 | if err != nil { |
| 73 | return nil, nil, fmt.Errorf("json marshal failed: %w", err) |
| 74 | } |
| 75 | |
| 76 | return &gomcp.CallToolResult{ |
| 77 | Content: []gomcp.Content{&gomcp.TextContent{Text: string(data)}}, |
| 78 | }, nil, nil |
| 79 | } |
nothing calls this directly
no test coverage detected