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

Method registerTools

mcp/server.go:108–183  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

106}
107
108func (s *Server) registerTools() {
109 type ListArgs struct {
110 All bool `json:"all,omitempty" jsonschema:"include completed tasks"`
111 }
112 mcp.AddTool(s.server, &mcp.Tool{
113 Name: "todo_list",
114 Description: "List tasks in the current directory's todo list",
115 }, func(ctx context.Context, req *mcp.CallToolRequest, args ListArgs) (*mcp.CallToolResult, any, error) {
116 return s.handleList(args.All)
117 })
118
119 type AddArgs struct {
120 Text string `json:"text" jsonschema:"task text"`
121 Priority string `json:"priority,omitempty" jsonschema:"task priority (veryhigh/high/medium/low/verylow)"`
122 Parent string `json:"parent,omitempty" jsonschema:"parent task index to nest under (e.g. 1 or 1.2)"`
123 }
124 mcp.AddTool(s.server, &mcp.Tool{
125 Name: "todo_add",
126 Description: "Add a new task to the todo list",
127 }, func(ctx context.Context, req *mcp.CallToolRequest, args AddArgs) (*mcp.CallToolResult, any, error) {
128 return s.handleAdd(args.Text, args.Priority, args.Parent)
129 })
130
131 type DoneArgs struct {
132 Indices []string `json:"indices" jsonschema:"task indices to mark as done (e.g. 1 or 2.1)"`
133 }
134 mcp.AddTool(s.server, &mcp.Tool{
135 Name: "todo_done",
136 Description: "Mark tasks as completed",
137 }, func(ctx context.Context, req *mcp.CallToolRequest, args DoneArgs) (*mcp.CallToolResult, any, error) {
138 return s.handleDone(args.Indices)
139 })
140
141 type UndoneArgs struct {
142 Indices []string `json:"indices" jsonschema:"task indices to mark as not done"`
143 }
144 mcp.AddTool(s.server, &mcp.Tool{
145 Name: "todo_undone",
146 Description: "Mark tasks as not completed",
147 }, func(ctx context.Context, req *mcp.CallToolRequest, args UndoneArgs) (*mcp.CallToolResult, any, error) {
148 return s.handleUndone(args.Indices)
149 })
150
151 type EditArgs struct {
152 Index string `json:"index" jsonschema:"task index to edit"`
153 Text string `json:"text,omitempty" jsonschema:"new task text"`
154 Priority string `json:"priority,omitempty" jsonschema:"new priority"`
155 }
156 mcp.AddTool(s.server, &mcp.Tool{
157 Name: "todo_edit",
158 Description: "Edit a task's text and/or priority",
159 }, func(ctx context.Context, req *mcp.CallToolRequest, args EditArgs) (*mcp.CallToolResult, any, error) {
160 return s.handleEdit(args.Index, args.Text, args.Priority)
161 })
162
163 type RemoveArgs struct {
164 Indices []string `json:"indices" jsonschema:"task indices to remove"`
165 }

Callers 1

NewServerFunction · 0.95

Calls 7

handleListMethod · 0.95
handleAddMethod · 0.95
handleDoneMethod · 0.95
handleUndoneMethod · 0.95
handleEditMethod · 0.95
handleRemoveMethod · 0.95
handleReparentMethod · 0.95

Tested by

no test coverage detected