@createtodo/mcp 0.1.1 → 0.1.2
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 +23 -12
- 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: {
|
|
@@ -343,18 +343,24 @@ var listTools = {
|
|
|
343
343
|
|
|
344
344
|
// src/tools/todos.ts
|
|
345
345
|
import { z as z4 } from "zod";
|
|
346
|
-
var
|
|
346
|
+
var cachedStates;
|
|
347
|
+
async function getWorkflowStates() {
|
|
348
|
+
if (cachedStates) return cachedStates;
|
|
349
|
+
cachedStates = await apiRequest("/shape", {
|
|
350
|
+
params: { table: "workflow_states" }
|
|
351
|
+
});
|
|
352
|
+
return cachedStates;
|
|
353
|
+
}
|
|
347
354
|
async function getDefaultStateId() {
|
|
348
|
-
|
|
349
|
-
const states = await apiRequest(
|
|
350
|
-
"/shape",
|
|
351
|
-
{ params: { table: "workflow_states" } }
|
|
352
|
-
);
|
|
355
|
+
const states = await getWorkflowStates();
|
|
353
356
|
const todo = states.find((s) => s.type === "unstarted" && s.name === "Todo");
|
|
354
357
|
if (!todo) throw new Error('No default "Todo" workflow state found');
|
|
355
|
-
cachedDefaultStateId = todo.id;
|
|
356
358
|
return todo.id;
|
|
357
359
|
}
|
|
360
|
+
function isCompletedState(stateId, states) {
|
|
361
|
+
const state = states.find((s) => s.id === stateId);
|
|
362
|
+
return state?.type === "completed";
|
|
363
|
+
}
|
|
358
364
|
var todoTools = {
|
|
359
365
|
list_todos: {
|
|
360
366
|
description: "List todos in a specific list/container",
|
|
@@ -362,10 +368,8 @@ var todoTools = {
|
|
|
362
368
|
listId: z4.string().describe("The ID of the list to get todos from")
|
|
363
369
|
}),
|
|
364
370
|
handler: async ({ listId }) => {
|
|
365
|
-
const result = await apiRequest(
|
|
366
|
-
|
|
367
|
-
);
|
|
368
|
-
return JSON.stringify(result, null, 2);
|
|
371
|
+
const result = await apiRequest(`/todo-lists/${listId}`);
|
|
372
|
+
return JSON.stringify(result.todoList ?? result, null, 2);
|
|
369
373
|
}
|
|
370
374
|
},
|
|
371
375
|
create_todo: {
|
|
@@ -382,7 +386,10 @@ var todoTools = {
|
|
|
382
386
|
const id = crypto.randomUUID();
|
|
383
387
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
384
388
|
const stateId = input.stateId ?? await getDefaultStateId();
|
|
389
|
+
const states = await getWorkflowStates();
|
|
390
|
+
const completed = isCompletedState(stateId, states);
|
|
385
391
|
const modifiedColumns = ["name", "container_id", "state_id"];
|
|
392
|
+
if (completed) modifiedColumns.push("completed_at");
|
|
386
393
|
if (input.description) modifiedColumns.push("description");
|
|
387
394
|
if (input.priority) modifiedColumns.push("priority");
|
|
388
395
|
if (input.assigneeId) modifiedColumns.push("assignee_id");
|
|
@@ -398,6 +405,7 @@ var todoTools = {
|
|
|
398
405
|
priority: input.priority ?? null,
|
|
399
406
|
assignee_id: input.assigneeId ?? null,
|
|
400
407
|
state_id: stateId,
|
|
408
|
+
completed_at: completed ? now : null,
|
|
401
409
|
created_at: now,
|
|
402
410
|
updated_at: now,
|
|
403
411
|
modified_columns: modifiedColumns,
|
|
@@ -454,6 +462,9 @@ var todoTools = {
|
|
|
454
462
|
if (input.stateId !== void 0) {
|
|
455
463
|
change.state_id = input.stateId;
|
|
456
464
|
modifiedColumns.push("state_id");
|
|
465
|
+
const states = await getWorkflowStates();
|
|
466
|
+
change.completed_at = isCompletedState(input.stateId, states) ? now : null;
|
|
467
|
+
modifiedColumns.push("completed_at");
|
|
457
468
|
}
|
|
458
469
|
if (input.containerId !== void 0) {
|
|
459
470
|
change.container_id = input.containerId;
|