MCPcopy Create free account
hub / github.com/alecthomas/devtodo2 / handleRemove

Method handleRemove

mcp/server.go:337–365  ·  view source on GitHub ↗
(indices []string)

Source from the content-addressed store, hash-verified

335}
336
337func (s *Server) handleRemove(indices []string) (*mcp.CallToolResult, any, error) {
338 if len(indices) == 0 {
339 return nil, nil, fmt.Errorf("at least one index is required")
340 }
341
342 tasks, err := s.load()
343 if err != nil {
344 return nil, nil, fmt.Errorf("load tasks: %w", err)
345 }
346 if tasks == nil {
347 return nil, nil, fmt.Errorf("no task list found")
348 }
349
350 var removed []string
351 for _, idx := range indices {
352 task := tasks.Find(idx)
353 if task == nil {
354 return nil, nil, fmt.Errorf("task %q not found", idx)
355 }
356 task.Delete()
357 removed = append(removed, idx)
358 }
359
360 if err := s.save(tasks); err != nil {
361 return nil, nil, fmt.Errorf("save: %w", err)
362 }
363
364 return jsonResult(map[string]any{"removed": removed})
365}
366
367func (s *Server) handleReparent(index, parent string) (*mcp.CallToolResult, any, error) {
368 if index == "" {

Callers 1

registerToolsMethod · 0.95

Calls 5

loadMethod · 0.95
saveMethod · 0.95
jsonResultFunction · 0.85
FindMethod · 0.65
DeleteMethod · 0.65

Tested by

no test coverage detected