@createtodo/mcp 0.1.0 → 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.
Files changed (2) hide show
  1. package/dist/index.js +34 -8
  2. package/package.json +6 -7
package/dist/index.js CHANGED
@@ -18,6 +18,9 @@ async function apiRequest(path, options = {}) {
18
18
  url.searchParams.set(key, value);
19
19
  }
20
20
  }
21
+ if (path === "/shape" && !url.searchParams.has("offset")) {
22
+ url.searchParams.set("offset", "-1");
23
+ }
21
24
  const headers = {
22
25
  "x-api-key": API_KEY
23
26
  };
@@ -219,7 +222,7 @@ var listTools = {
219
222
  inputSchema: z3.object({}),
220
223
  handler: async () => {
221
224
  const result = await apiRequest("/todo-lists");
222
- return JSON.stringify(result.todoLists, null, 2);
225
+ return JSON.stringify(result.todoLists ?? result, null, 2);
223
226
  }
224
227
  },
225
228
  get_list: {
@@ -340,6 +343,24 @@ var listTools = {
340
343
 
341
344
  // src/tools/todos.ts
342
345
  import { z as z4 } from "zod";
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
+ }
354
+ async function getDefaultStateId() {
355
+ const states = await getWorkflowStates();
356
+ const todo = states.find((s) => s.type === "unstarted" && s.name === "Todo");
357
+ if (!todo) throw new Error('No default "Todo" workflow state found');
358
+ return todo.id;
359
+ }
360
+ function isCompletedState(stateId, states) {
361
+ const state = states.find((s) => s.id === stateId);
362
+ return state?.type === "completed";
363
+ }
343
364
  var todoTools = {
344
365
  list_todos: {
345
366
  description: "List todos in a specific list/container",
@@ -347,10 +368,8 @@ var todoTools = {
347
368
  listId: z4.string().describe("The ID of the list to get todos from")
348
369
  }),
349
370
  handler: async ({ listId }) => {
350
- const result = await apiRequest(
351
- `/todo-lists/${listId}`
352
- );
353
- return JSON.stringify(result.todoList, null, 2);
371
+ const result = await apiRequest(`/todo-lists/${listId}`);
372
+ return JSON.stringify(result.todoList ?? result, null, 2);
354
373
  }
355
374
  },
356
375
  create_todo: {
@@ -366,11 +385,14 @@ var todoTools = {
366
385
  handler: async (input) => {
367
386
  const id = crypto.randomUUID();
368
387
  const now = (/* @__PURE__ */ new Date()).toISOString();
369
- const modifiedColumns = ["name", "container_id"];
388
+ const stateId = input.stateId ?? await getDefaultStateId();
389
+ const states = await getWorkflowStates();
390
+ const completed = isCompletedState(stateId, states);
391
+ const modifiedColumns = ["name", "container_id", "state_id"];
392
+ if (completed) modifiedColumns.push("completed_at");
370
393
  if (input.description) modifiedColumns.push("description");
371
394
  if (input.priority) modifiedColumns.push("priority");
372
395
  if (input.assigneeId) modifiedColumns.push("assignee_id");
373
- if (input.stateId) modifiedColumns.push("state_id");
374
396
  const result = await apiRequest("/apply-changes", {
375
397
  method: "POST",
376
398
  body: {
@@ -382,7 +404,8 @@ var todoTools = {
382
404
  description: input.description ?? null,
383
405
  priority: input.priority ?? null,
384
406
  assignee_id: input.assigneeId ?? null,
385
- state_id: input.stateId ?? null,
407
+ state_id: stateId,
408
+ completed_at: completed ? now : null,
386
409
  created_at: now,
387
410
  updated_at: now,
388
411
  modified_columns: modifiedColumns,
@@ -439,6 +462,9 @@ var todoTools = {
439
462
  if (input.stateId !== void 0) {
440
463
  change.state_id = input.stateId;
441
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");
442
468
  }
443
469
  if (input.containerId !== void 0) {
444
470
  change.container_id = input.containerId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@createtodo/mcp",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "MCP server for managing createtodo tasks, lists, labels, and more",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -24,11 +24,6 @@
24
24
  "files": [
25
25
  "dist"
26
26
  ],
27
- "scripts": {
28
- "build": "tsup src/index.ts --format esm --dts --clean",
29
- "prepublishOnly": "pnpm build",
30
- "dev": "tsx src/index.ts"
31
- },
32
27
  "dependencies": {
33
28
  "@modelcontextprotocol/sdk": "^1.12.1",
34
29
  "zod": "^3.24.0"
@@ -37,5 +32,9 @@
37
32
  "tsup": "^8.4.0",
38
33
  "tsx": "^4.19.0",
39
34
  "typescript": "^5.9.3"
35
+ },
36
+ "scripts": {
37
+ "build": "tsup src/index.ts --format esm --dts --clean",
38
+ "dev": "tsx src/index.ts"
40
39
  }
41
- }
40
+ }