@createtodo/mcp 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +27 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -222,7 +222,7 @@ var listTools = {
|
|
|
222
222
|
inputSchema: z3.object({}),
|
|
223
223
|
handler: async () => {
|
|
224
224
|
const result = await apiRequest("/todo-lists");
|
|
225
|
-
return JSON.stringify(result, null, 2);
|
|
225
|
+
return JSON.stringify(result.todoLists ?? result, null, 2);
|
|
226
226
|
}
|
|
227
227
|
},
|
|
228
228
|
get_list: {
|
|
@@ -231,8 +231,10 @@ var listTools = {
|
|
|
231
231
|
listId: z3.string().describe("The ID of the list")
|
|
232
232
|
}),
|
|
233
233
|
handler: async ({ listId }) => {
|
|
234
|
-
const result = await apiRequest(
|
|
235
|
-
|
|
234
|
+
const result = await apiRequest(
|
|
235
|
+
`/todo-lists/${listId}`
|
|
236
|
+
);
|
|
237
|
+
return JSON.stringify(result.todoList ?? result, null, 2);
|
|
236
238
|
}
|
|
237
239
|
},
|
|
238
240
|
create_list: {
|
|
@@ -343,18 +345,24 @@ var listTools = {
|
|
|
343
345
|
|
|
344
346
|
// src/tools/todos.ts
|
|
345
347
|
import { z as z4 } from "zod";
|
|
346
|
-
var
|
|
348
|
+
var cachedStates;
|
|
349
|
+
async function getWorkflowStates() {
|
|
350
|
+
if (cachedStates) return cachedStates;
|
|
351
|
+
cachedStates = await apiRequest("/shape", {
|
|
352
|
+
params: { table: "workflow_states" }
|
|
353
|
+
});
|
|
354
|
+
return cachedStates;
|
|
355
|
+
}
|
|
347
356
|
async function getDefaultStateId() {
|
|
348
|
-
|
|
349
|
-
const states = await apiRequest(
|
|
350
|
-
"/shape",
|
|
351
|
-
{ params: { table: "workflow_states" } }
|
|
352
|
-
);
|
|
357
|
+
const states = await getWorkflowStates();
|
|
353
358
|
const todo = states.find((s) => s.type === "unstarted" && s.name === "Todo");
|
|
354
359
|
if (!todo) throw new Error('No default "Todo" workflow state found');
|
|
355
|
-
cachedDefaultStateId = todo.id;
|
|
356
360
|
return todo.id;
|
|
357
361
|
}
|
|
362
|
+
function isCompletedState(stateId, states) {
|
|
363
|
+
const state = states.find((s) => s.id === stateId);
|
|
364
|
+
return state?.type === "completed";
|
|
365
|
+
}
|
|
358
366
|
var todoTools = {
|
|
359
367
|
list_todos: {
|
|
360
368
|
description: "List todos in a specific list/container",
|
|
@@ -362,10 +370,8 @@ var todoTools = {
|
|
|
362
370
|
listId: z4.string().describe("The ID of the list to get todos from")
|
|
363
371
|
}),
|
|
364
372
|
handler: async ({ listId }) => {
|
|
365
|
-
const result = await apiRequest(
|
|
366
|
-
|
|
367
|
-
);
|
|
368
|
-
return JSON.stringify(result, null, 2);
|
|
373
|
+
const result = await apiRequest(`/todo-lists/${listId}`);
|
|
374
|
+
return JSON.stringify(result.todoList?.items ?? [], null, 2);
|
|
369
375
|
}
|
|
370
376
|
},
|
|
371
377
|
create_todo: {
|
|
@@ -382,7 +388,10 @@ var todoTools = {
|
|
|
382
388
|
const id = crypto.randomUUID();
|
|
383
389
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
384
390
|
const stateId = input.stateId ?? await getDefaultStateId();
|
|
391
|
+
const states = await getWorkflowStates();
|
|
392
|
+
const completed = isCompletedState(stateId, states);
|
|
385
393
|
const modifiedColumns = ["name", "container_id", "state_id"];
|
|
394
|
+
if (completed) modifiedColumns.push("completed_at");
|
|
386
395
|
if (input.description) modifiedColumns.push("description");
|
|
387
396
|
if (input.priority) modifiedColumns.push("priority");
|
|
388
397
|
if (input.assigneeId) modifiedColumns.push("assignee_id");
|
|
@@ -398,6 +407,7 @@ var todoTools = {
|
|
|
398
407
|
priority: input.priority ?? null,
|
|
399
408
|
assignee_id: input.assigneeId ?? null,
|
|
400
409
|
state_id: stateId,
|
|
410
|
+
completed_at: completed ? now : null,
|
|
401
411
|
created_at: now,
|
|
402
412
|
updated_at: now,
|
|
403
413
|
modified_columns: modifiedColumns,
|
|
@@ -454,6 +464,9 @@ var todoTools = {
|
|
|
454
464
|
if (input.stateId !== void 0) {
|
|
455
465
|
change.state_id = input.stateId;
|
|
456
466
|
modifiedColumns.push("state_id");
|
|
467
|
+
const states = await getWorkflowStates();
|
|
468
|
+
change.completed_at = isCompletedState(input.stateId, states) ? now : null;
|
|
469
|
+
modifiedColumns.push("completed_at");
|
|
457
470
|
}
|
|
458
471
|
if (input.containerId !== void 0) {
|
|
459
472
|
change.container_id = input.containerId;
|