caldav-mcp 0.9.2 → 0.10.0

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/README.md CHANGED
@@ -94,12 +94,13 @@ Returns:
94
94
 
95
95
  ### create-event
96
96
 
97
- Creates an event in the calendar specified by its URL
97
+ Creates an event in the calendar specified by its URL. For all-day events, set `wholeDay` to true. For a single-day all-day event, use `start` and `end` datetimes on the same calendar date; they do not need to be identical timestamps.
98
98
 
99
99
  Parameters:
100
100
  - `summary`: string
101
101
  - `start`: string — Start datetime (ISO 8601)
102
102
  - `end`: string — End datetime (ISO 8601)
103
+ - `wholeDay`: boolean (optional) — Create as a whole-day event
103
104
  - `calendarUrl`: string
104
105
  - `description`: string (optional)
105
106
  - `location`: string (optional)
@@ -117,7 +118,7 @@ Returns:
117
118
 
118
119
  ### update-event
119
120
 
120
- Updates an existing event in the calendar specified by its URL. Only provided fields are changed.
121
+ Updates an existing event in the calendar specified by its URL. Only provided fields are changed. For a one-day full-day event, set `wholeDay` to true and set `start` and `end` to the same calendar day.
121
122
 
122
123
  Parameters:
123
124
  - `uid`: string — Unique identifier of the event to update (obtained from list-events)
@@ -125,6 +126,7 @@ Parameters:
125
126
  - `summary`: string (optional)
126
127
  - `start`: string (optional)
127
128
  - `end`: string (optional)
129
+ - `wholeDay`: boolean (optional) — Update whether this is a whole-day event
128
130
  - `description`: string (optional)
129
131
  - `location`: string (optional)
130
132
  - `recurrenceRule`: object (optional)
@@ -149,8 +151,78 @@ Parameters:
149
151
 
150
152
  Returns:
151
153
  - Confirmation message when the event is successfully deleted
154
+
155
+ ### list-todos
156
+
157
+ List tasks (VTODOs) in the calendar specified by its URL. By default returns only open tasks (NEEDS-ACTION and IN-PROCESS), sorted by manual order then due date. Use `status` to include completed (`COMPLETED`) or all (`ALL`) tasks, and `limit`/`offset` to page through long lists.
158
+
159
+ Parameters:
160
+ - `calendarUrl`: string
161
+ - `status`: enum (`OPEN` | `ALL` | `NEEDS-ACTION` | `COMPLETED` | `IN-PROCESS` | `CANCELLED`) (optional) — Filter by status. `OPEN` (default) = NEEDS-ACTION + IN-PROCESS; `ALL` = everything; or an exact status (NEEDS-ACTION, COMPLETED, IN-PROCESS, CANCELLED).
162
+ - `due_before`: string (optional) — Only tasks with a due date at or before this (ISO 8601). Undated tasks are excluded when a due window is set.
163
+ - `due_after`: string (optional) — Only tasks with a due date at or after this (ISO 8601). Undated tasks are excluded when a due window is set.
164
+ - `limit`: number (optional) — Max tasks to return (default 50, max 500)
165
+ - `offset`: number (optional) — Tasks to skip (default 0)
166
+
167
+ Returns:
168
+ - An object `{ todos, total, limit, offset }` where `total` is the count before pagination. Each todo has `uid`, `summary`, `status`, and optionally `due`, `start`, `completed`, `description`, `location`.
169
+
170
+ ### create-todo
171
+
172
+ Creates a task (VTODO) in the calendar specified by its URL. Only `summary` is required; a task may have no dates. Use `due` for a deadline and `start` for when work should begin.
173
+
174
+ Parameters:
175
+ - `summary`: string
176
+ - `calendarUrl`: string
177
+ - `due`: string (optional) — Due datetime (ISO 8601)
178
+ - `start`: string (optional) — Start datetime (ISO 8601)
179
+ - `description`: string (optional)
180
+ - `location`: string (optional)
181
+ - `status`: enum (`NEEDS-ACTION` | `COMPLETED` | `IN-PROCESS` | `CANCELLED`) (optional) — Defaults to NEEDS-ACTION when omitted
182
+
183
+ Returns:
184
+ - The unique ID of the created todo
185
+
186
+ ### update-todo
187
+
188
+ Updates an existing task (VTODO) in the calendar specified by its URL. Only provided fields are changed. To mark a task done, prefer the `complete-todo` tool.
189
+
190
+ Parameters:
191
+ - `uid`: string — Unique identifier of the todo to update (from list-todos)
192
+ - `calendarUrl`: string
193
+ - `summary`: string (optional)
194
+ - `due`: string (optional)
195
+ - `start`: string (optional)
196
+ - `description`: string (optional)
197
+ - `location`: string (optional)
198
+ - `status`: enum (`NEEDS-ACTION` | `COMPLETED` | `IN-PROCESS` | `CANCELLED`) (optional)
199
+
200
+ Returns:
201
+ - The unique ID of the updated todo
202
+
203
+ ### complete-todo
204
+
205
+ Marks a task (VTODO) as done. Sets its status to COMPLETED and records the completion time.
206
+
207
+ Parameters:
208
+ - `uid`: string — Unique identifier of the todo to complete (from list-todos)
209
+ - `calendarUrl`: string
210
+
211
+ Returns:
212
+ - The unique ID of the completed todo
213
+
214
+ ### delete-todo
215
+
216
+ Deletes a task (VTODO) in the calendar specified by its URL
217
+
218
+ Parameters:
219
+ - `uid`: string — Unique identifier of the todo to delete (from list-todos)
220
+ - `calendarUrl`: string
221
+
222
+ Returns:
223
+ - Confirmation message when the todo is successfully deleted
152
224
  <!-- TOOLS:END -->
153
225
 
154
226
  ## License
155
227
 
156
- MIT
228
+ MIT
package/dist/index.js CHANGED
@@ -2,11 +2,16 @@
2
2
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
3
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
4
  import { CalDAVClient } from "ts-caldav";
5
+ import { registerCompleteTodo } from "./tools/complete-todo.js";
5
6
  import { registerCreateEvent } from "./tools/create-event.js";
7
+ import { registerCreateTodo } from "./tools/create-todo.js";
6
8
  import { registerDeleteEvent } from "./tools/delete-event.js";
9
+ import { registerDeleteTodo } from "./tools/delete-todo.js";
7
10
  import { registerListCalendars } from "./tools/list-calendars.js";
8
11
  import { registerListEvents } from "./tools/list-events.js";
12
+ import { registerListTodos } from "./tools/list-todos.js";
9
13
  import { registerUpdateEvent } from "./tools/update-event.js";
14
+ import { registerUpdateTodo } from "./tools/update-todo.js";
10
15
  const server = new McpServer({
11
16
  name: "caldav-mcp",
12
17
  version: "0.1.0",
@@ -32,6 +37,11 @@ async function main() {
32
37
  registerListEvents(client, server);
33
38
  registerDeleteEvent(client, server);
34
39
  registerUpdateEvent(client, server);
40
+ registerCreateTodo(client, server);
41
+ registerListTodos(client, server);
42
+ registerUpdateTodo(client, server);
43
+ registerCompleteTodo(client, server);
44
+ registerDeleteTodo(client, server);
35
45
  await registerListCalendars(client, server);
36
46
  // Start receiving messages on stdin and sending messages on stdout
37
47
  const transport = new StdioServerTransport();
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Builds the CalDAV object href (`<calendar>/<uid>.ics`) used to address a
3
+ * single event or todo. Mirrors how ts-caldav stores objects, tolerating a
4
+ * calendar URL with or without a trailing slash.
5
+ */
6
+ export function hrefFor(calendarUrl, uid) {
7
+ const base = calendarUrl.endsWith("/") ? calendarUrl : `${calendarUrl}/`;
8
+ return `${base}${uid}.ics`;
9
+ }
@@ -0,0 +1,35 @@
1
+ import { z } from "zod";
2
+ import { hrefFor } from "./caldav-href.js";
3
+ export const completeTodoDefinition = {
4
+ name: "complete-todo",
5
+ description: "Marks a task (VTODO) as done. Sets its status to COMPLETED and records the completion time.",
6
+ inputSchema: {
7
+ uid: z
8
+ .string()
9
+ .describe("Unique identifier of the todo to complete (from list-todos)"),
10
+ calendarUrl: z.string(),
11
+ },
12
+ returns: "The unique ID of the completed todo",
13
+ };
14
+ export function registerCompleteTodo(client, server) {
15
+ server.registerTool(completeTodoDefinition.name, {
16
+ description: completeTodoDefinition.description,
17
+ inputSchema: completeTodoDefinition.inputSchema,
18
+ }, async (args) => {
19
+ const { uid, calendarUrl } = args;
20
+ const href = hrefFor(calendarUrl, uid);
21
+ const [existing] = await client.getTodosByHref(calendarUrl, [href]);
22
+ if (!existing) {
23
+ throw new Error(`Todo not found: ${uid}`);
24
+ }
25
+ // RFC 5545: a COMPLETED VTODO should carry a COMPLETED timestamp.
26
+ const updated = await client.updateTodo(calendarUrl, {
27
+ ...existing,
28
+ status: "COMPLETED",
29
+ completed: new Date(),
30
+ });
31
+ return {
32
+ content: [{ type: "text", text: updated.uid }],
33
+ };
34
+ });
35
+ }
@@ -28,7 +28,7 @@ const recurrenceRuleSchema = z.object({
28
28
  });
29
29
  export const createEventDefinition = {
30
30
  name: "create-event",
31
- description: "Creates an event in the calendar specified by its URL",
31
+ description: "Creates an event in the calendar specified by its URL. For all-day events, set `wholeDay` to true. For a single-day all-day event, use `start` and `end` datetimes on the same calendar date; they do not need to be identical timestamps.",
32
32
  inputSchema: {
33
33
  summary: z.string(),
34
34
  start: z
@@ -39,6 +39,7 @@ export const createEventDefinition = {
39
39
  .string()
40
40
  .datetime({ offset: true })
41
41
  .describe("End datetime (ISO 8601)"),
42
+ wholeDay: z.boolean().optional().describe("Create as a whole-day event"),
42
43
  calendarUrl: z.string(),
43
44
  description: z.string().optional(),
44
45
  location: z.string().optional(),
@@ -51,11 +52,12 @@ export function registerCreateEvent(client, server) {
51
52
  description: createEventDefinition.description,
52
53
  inputSchema: createEventDefinition.inputSchema,
53
54
  }, async (args) => {
54
- const { calendarUrl, summary, start, end, description, location, recurrenceRule, } = args;
55
+ const { calendarUrl, summary, start, end, wholeDay, description, location, recurrenceRule, } = args;
55
56
  const event = await client.createEvent(calendarUrl, {
56
57
  summary: summary,
57
58
  start: new Date(start),
58
59
  end: new Date(end),
60
+ ...(wholeDay !== undefined && { wholeDay }),
59
61
  ...(description !== undefined && { description }),
60
62
  ...(location !== undefined && { location }),
61
63
  ...(recurrenceRule !== undefined && {
@@ -0,0 +1,45 @@
1
+ import { z } from "zod";
2
+ import { todoStatusSchema } from "./todo-status.js";
3
+ export const createTodoDefinition = {
4
+ name: "create-todo",
5
+ description: "Creates a task (VTODO) in the calendar specified by its URL. Only `summary` is required; a task may have no dates. Use `due` for a deadline and `start` for when work should begin.",
6
+ inputSchema: {
7
+ summary: z.string(),
8
+ calendarUrl: z.string(),
9
+ due: z
10
+ .string()
11
+ .datetime({ offset: true })
12
+ .optional()
13
+ .describe("Due datetime (ISO 8601)"),
14
+ start: z
15
+ .string()
16
+ .datetime({ offset: true })
17
+ .optional()
18
+ .describe("Start datetime (ISO 8601)"),
19
+ description: z.string().optional(),
20
+ location: z.string().optional(),
21
+ status: todoStatusSchema
22
+ .optional()
23
+ .describe("Defaults to NEEDS-ACTION when omitted"),
24
+ },
25
+ returns: "The unique ID of the created todo",
26
+ };
27
+ export function registerCreateTodo(client, server) {
28
+ server.registerTool(createTodoDefinition.name, {
29
+ description: createTodoDefinition.description,
30
+ inputSchema: createTodoDefinition.inputSchema,
31
+ }, async (args) => {
32
+ const { calendarUrl, summary, due, start, description, location, status, } = args;
33
+ const todo = await client.createTodo(calendarUrl, {
34
+ summary,
35
+ ...(due !== undefined && { due: new Date(due) }),
36
+ ...(start !== undefined && { start: new Date(start) }),
37
+ ...(description !== undefined && { description }),
38
+ ...(location !== undefined && { location }),
39
+ ...(status !== undefined && { status }),
40
+ });
41
+ return {
42
+ content: [{ type: "text", text: todo.uid }],
43
+ };
44
+ });
45
+ }
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { hrefFor } from "./caldav-href.js";
2
3
  export const deleteEventDefinition = {
3
4
  name: "delete-event",
4
5
  description: "Deletes an event in the calendar specified by its URL",
@@ -16,9 +17,7 @@ export function registerDeleteEvent(client, server) {
16
17
  inputSchema: deleteEventDefinition.inputSchema,
17
18
  }, async (args) => {
18
19
  const { uid, calendarUrl } = args;
19
- const base = calendarUrl.endsWith("/") ? calendarUrl : `${calendarUrl}/`;
20
- const href = `${base}${uid}.ics`;
21
- const etag = await client.getETag(href);
20
+ const etag = await client.getETag(hrefFor(calendarUrl, uid));
22
21
  await client.deleteEvent(calendarUrl, uid, etag);
23
22
  return {
24
23
  content: [{ type: "text", text: "Event deleted" }],
@@ -0,0 +1,40 @@
1
+ import { CalDAVError } from "ts-caldav";
2
+ import { z } from "zod";
3
+ import { hrefFor } from "./caldav-href.js";
4
+ export const deleteTodoDefinition = {
5
+ name: "delete-todo",
6
+ description: "Deletes a task (VTODO) in the calendar specified by its URL",
7
+ inputSchema: {
8
+ uid: z
9
+ .string()
10
+ .describe("Unique identifier of the todo to delete (from list-todos)"),
11
+ calendarUrl: z.string(),
12
+ },
13
+ returns: "Confirmation message when the todo is successfully deleted",
14
+ };
15
+ export function registerDeleteTodo(client, server) {
16
+ server.registerTool(deleteTodoDefinition.name, {
17
+ description: deleteTodoDefinition.description,
18
+ inputSchema: deleteTodoDefinition.inputSchema,
19
+ }, async (args) => {
20
+ const { uid, calendarUrl } = args;
21
+ // Map a missing object onto the same friendly message complete-todo and
22
+ // update-todo raise, so all three todo tools report a missing task the
23
+ // same way. (delete-event still surfaces the raw transport error; the
24
+ // event family is left as-is.) Non-404 failures propagate untouched.
25
+ let etag;
26
+ try {
27
+ etag = await client.getETag(hrefFor(calendarUrl, uid));
28
+ }
29
+ catch (error) {
30
+ if (error instanceof CalDAVError && error.status === 404) {
31
+ throw new Error(`Todo not found: ${uid}`);
32
+ }
33
+ throw error;
34
+ }
35
+ await client.deleteTodo(calendarUrl, uid, etag);
36
+ return {
37
+ content: [{ type: "text", text: "Todo deleted" }],
38
+ };
39
+ });
40
+ }
@@ -0,0 +1,131 @@
1
+ import { z } from "zod";
2
+ import { todoStatusSchema } from "./todo-status.js";
3
+ // `OPEN`/`ALL` are filter keywords expressing sets no single status can (a union
4
+ // and "no filter"); the four raw statuses allow an exact-status query. The raw
5
+ // values come from todoStatusSchema so adding a new status stays in sync with
6
+ // create/update instead of silently diverging. A `COMPLETED` query goes through
7
+ // the raw status — no separate `completed` keyword, which would just duplicate it.
8
+ const statusFilterSchema = z.enum(["OPEN", "ALL", ...todoStatusSchema.options]);
9
+ const OPEN_STATUSES = ["NEEDS-ACTION", "IN-PROCESS"];
10
+ /** A VTODO without an explicit STATUS is treated as NEEDS-ACTION (RFC 5545). */
11
+ function statusOf(t) {
12
+ return t.status ?? "NEEDS-ACTION";
13
+ }
14
+ /**
15
+ * Sort order: `sortOrder` ascending (a user's explicit drag-reorder intent;
16
+ * missing values sort last), then `due` ascending (undated tasks last), then
17
+ * `summary`. When every task shares the same `sortOrder` (typically none set,
18
+ * so all compare equal) the order falls through to the due date, so the same
19
+ * rule serves both "I arranged these" and "show me by deadline" without a mode
20
+ * flag.
21
+ */
22
+ export function compareTodos(a, b) {
23
+ const soA = a.sortOrder ?? Number.POSITIVE_INFINITY;
24
+ const soB = b.sortOrder ?? Number.POSITIVE_INFINITY;
25
+ if (soA !== soB)
26
+ return soA - soB;
27
+ const dueA = a.due ? a.due.getTime() : Number.POSITIVE_INFINITY;
28
+ const dueB = b.due ? b.due.getTime() : Number.POSITIVE_INFINITY;
29
+ if (dueA !== dueB)
30
+ return dueA - dueB;
31
+ return a.summary.localeCompare(b.summary);
32
+ }
33
+ export const listTodosDefinition = {
34
+ name: "list-todos",
35
+ description: "List tasks (VTODOs) in the calendar specified by its URL. By default returns only open tasks (NEEDS-ACTION and IN-PROCESS), sorted by manual order then due date. Use `status` to include completed (`COMPLETED`) or all (`ALL`) tasks, and `limit`/`offset` to page through long lists.",
36
+ inputSchema: {
37
+ calendarUrl: z.string(),
38
+ status: statusFilterSchema
39
+ .optional()
40
+ .describe("Filter by status. `OPEN` (default) = NEEDS-ACTION + IN-PROCESS; `ALL` = everything; or an exact status (NEEDS-ACTION, COMPLETED, IN-PROCESS, CANCELLED)."),
41
+ due_before: z
42
+ .string()
43
+ .datetime({ offset: true })
44
+ .optional()
45
+ .describe("Only tasks with a due date at or before this (ISO 8601). Undated tasks are excluded when a due window is set."),
46
+ due_after: z
47
+ .string()
48
+ .datetime({ offset: true })
49
+ .optional()
50
+ .describe("Only tasks with a due date at or after this (ISO 8601). Undated tasks are excluded when a due window is set."),
51
+ limit: z
52
+ .number()
53
+ .int()
54
+ .positive()
55
+ .max(500)
56
+ .optional()
57
+ .describe("Max tasks to return (default 50, max 500)"),
58
+ offset: z
59
+ .number()
60
+ .int()
61
+ .nonnegative()
62
+ .optional()
63
+ .describe("Tasks to skip (default 0)"),
64
+ },
65
+ returns: "An object `{ todos, total, limit, offset }` where `total` is the count before pagination. Each todo has `uid`, `summary`, `status`, and optionally `due`, `start`, `completed`, `description`, `location`.",
66
+ };
67
+ export function registerListTodos(client, server) {
68
+ server.registerTool(listTodosDefinition.name, {
69
+ description: listTodosDefinition.description,
70
+ inputSchema: listTodosDefinition.inputSchema,
71
+ }, async (args) => {
72
+ const { calendarUrl } = args;
73
+ const status = args.status ?? "OPEN";
74
+ const limit = args.limit ?? 50;
75
+ const offset = args.offset ?? 0;
76
+ const hasWindow = args.due_after !== undefined || args.due_before !== undefined;
77
+ const after = args.due_after !== undefined
78
+ ? new Date(args.due_after).getTime()
79
+ : null;
80
+ const before = args.due_before !== undefined
81
+ ? new Date(args.due_before).getTime()
82
+ : null;
83
+ const matchesStatus = (t) => {
84
+ const s = statusOf(t);
85
+ if (status === "ALL")
86
+ return true;
87
+ if (status === "OPEN")
88
+ return OPEN_STATUSES.includes(s);
89
+ return s === status;
90
+ };
91
+ const matchesWindow = (t) => {
92
+ if (!hasWindow)
93
+ return true;
94
+ if (!t.due)
95
+ return false;
96
+ const d = t.due.getTime();
97
+ if (after !== null && d < after)
98
+ return false;
99
+ if (before !== null && d > before)
100
+ return false;
101
+ return true;
102
+ };
103
+ const all = await client.getTodos(calendarUrl, { all: true });
104
+ const filtered = all
105
+ .filter((t) => matchesStatus(t) && matchesWindow(t))
106
+ .sort(compareTodos);
107
+ const todos = filtered.slice(offset, offset + limit).map((t) => ({
108
+ uid: t.uid,
109
+ summary: t.summary,
110
+ status: statusOf(t),
111
+ ...(t.due && { due: t.due }),
112
+ ...(t.start && { start: t.start }),
113
+ ...(t.completed && { completed: t.completed }),
114
+ ...(t.description && { description: t.description }),
115
+ ...(t.location && { location: t.location }),
116
+ }));
117
+ return {
118
+ content: [
119
+ {
120
+ type: "text",
121
+ text: JSON.stringify({
122
+ todos,
123
+ total: filtered.length,
124
+ limit,
125
+ offset,
126
+ }),
127
+ },
128
+ ],
129
+ };
130
+ });
131
+ }
@@ -0,0 +1,12 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * The VTODO `STATUS` values defined by RFC 5545 §3.8.1.11. Shared by the todo
4
+ * tools so the writable status set stays in one place rather than one tool
5
+ * depending on another (`list`/`update` previously imported it from `create`).
6
+ */
7
+ export const todoStatusSchema = z.enum([
8
+ "NEEDS-ACTION",
9
+ "COMPLETED",
10
+ "IN-PROCESS",
11
+ "CANCELLED",
12
+ ]);
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { hrefFor } from "./caldav-href.js";
2
3
  function toRecurrenceRule(r) {
3
4
  const out = {};
4
5
  if (r.freq !== undefined)
@@ -28,7 +29,7 @@ const recurrenceRuleSchema = z.object({
28
29
  });
29
30
  export const updateEventDefinition = {
30
31
  name: "update-event",
31
- description: "Updates an existing event in the calendar specified by its URL. Only provided fields are changed.",
32
+ description: "Updates an existing event in the calendar specified by its URL. Only provided fields are changed. For a one-day full-day event, set `wholeDay` to true and set `start` and `end` to the same calendar day.",
32
33
  inputSchema: {
33
34
  uid: z
34
35
  .string()
@@ -37,6 +38,10 @@ export const updateEventDefinition = {
37
38
  summary: z.string().optional(),
38
39
  start: z.string().datetime({ offset: true }).optional(),
39
40
  end: z.string().datetime({ offset: true }).optional(),
41
+ wholeDay: z
42
+ .boolean()
43
+ .optional()
44
+ .describe("Update whether this is a whole-day event"),
40
45
  description: z.string().optional(),
41
46
  location: z.string().optional(),
42
47
  recurrenceRule: recurrenceRuleSchema.optional(),
@@ -48,9 +53,8 @@ export function registerUpdateEvent(client, server) {
48
53
  description: updateEventDefinition.description,
49
54
  inputSchema: updateEventDefinition.inputSchema,
50
55
  }, async (args) => {
51
- const { uid, calendarUrl, summary, start, end, description, location, recurrenceRule, } = args;
52
- const base = calendarUrl.endsWith("/") ? calendarUrl : `${calendarUrl}/`;
53
- const href = `${base}${uid}.ics`;
56
+ const { uid, calendarUrl, summary, start, end, wholeDay, description, location, recurrenceRule, } = args;
57
+ const href = hrefFor(calendarUrl, uid);
54
58
  const [existing] = await client.getEventsByHref(calendarUrl, [href]);
55
59
  if (!existing) {
56
60
  throw new Error(`Event not found: ${uid}`);
@@ -60,6 +64,7 @@ export function registerUpdateEvent(client, server) {
60
64
  ...(summary !== undefined && { summary }),
61
65
  ...(start !== undefined && { start: new Date(start) }),
62
66
  ...(end !== undefined && { end: new Date(end) }),
67
+ ...(wholeDay !== undefined && { wholeDay }),
63
68
  ...(description !== undefined && { description }),
64
69
  ...(location !== undefined && { location }),
65
70
  ...(recurrenceRule !== undefined && {
@@ -0,0 +1,59 @@
1
+ import { z } from "zod";
2
+ import { hrefFor } from "./caldav-href.js";
3
+ import { todoStatusSchema } from "./todo-status.js";
4
+ export const updateTodoDefinition = {
5
+ name: "update-todo",
6
+ description: "Updates an existing task (VTODO) in the calendar specified by its URL. Only provided fields are changed. To mark a task done, prefer the `complete-todo` tool.",
7
+ inputSchema: {
8
+ uid: z
9
+ .string()
10
+ .describe("Unique identifier of the todo to update (from list-todos)"),
11
+ calendarUrl: z.string(),
12
+ summary: z.string().optional(),
13
+ due: z.string().datetime({ offset: true }).optional(),
14
+ start: z.string().datetime({ offset: true }).optional(),
15
+ description: z.string().optional(),
16
+ location: z.string().optional(),
17
+ status: todoStatusSchema.optional(),
18
+ },
19
+ returns: "The unique ID of the updated todo",
20
+ };
21
+ export function registerUpdateTodo(client, server) {
22
+ server.registerTool(updateTodoDefinition.name, {
23
+ description: updateTodoDefinition.description,
24
+ inputSchema: updateTodoDefinition.inputSchema,
25
+ }, async (args) => {
26
+ const { uid, calendarUrl, summary, due, start, description, location, status, } = args;
27
+ const href = hrefFor(calendarUrl, uid);
28
+ const [existing] = await client.getTodosByHref(calendarUrl, [href]);
29
+ if (!existing) {
30
+ throw new Error(`Todo not found: ${uid}`);
31
+ }
32
+ // RFC 5545: a COMPLETED VTODO carries a COMPLETED timestamp. Keep status
33
+ // and that timestamp consistent so updating status here can't leave the
34
+ // task in the RFC-incomplete state complete-todo guards against. An
35
+ // existing completion time is preserved (completion happened once);
36
+ // transitioning away drops it. `completed` is pulled out of `existing`
37
+ // so the cleared case omits the property entirely rather than setting it
38
+ // undefined (which exactOptionalPropertyTypes forbids).
39
+ const { completed: priorCompleted, ...base } = existing;
40
+ const completed = status === undefined
41
+ ? priorCompleted
42
+ : status === "COMPLETED"
43
+ ? (priorCompleted ?? new Date())
44
+ : undefined;
45
+ const updated = await client.updateTodo(calendarUrl, {
46
+ ...base,
47
+ ...(summary !== undefined && { summary }),
48
+ ...(due !== undefined && { due: new Date(due) }),
49
+ ...(start !== undefined && { start: new Date(start) }),
50
+ ...(description !== undefined && { description }),
51
+ ...(location !== undefined && { location }),
52
+ ...(status !== undefined && { status }),
53
+ ...(completed !== undefined && { completed }),
54
+ });
55
+ return {
56
+ content: [{ type: "text", text: updated.uid }],
57
+ };
58
+ });
59
+ }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "caldav-mcp",
3
3
  "mcpName": "io.github.dominik1001/caldav-mcp",
4
4
  "description": "A CalDAV client using Model Context Protocol (MCP) to expose calendar operations as tools for AI assistants.",
5
- "version": "0.9.2",
5
+ "version": "0.10.0",
6
6
  "main": "dist/index.js",
7
7
  "type": "module",
8
8
  "bin": {
@@ -57,7 +57,7 @@
57
57
  "@semantic-release/git": "^10.0.1",
58
58
  "@semantic-release/github": "^12.0.5",
59
59
  "@semantic-release/npm": "^13.1.4",
60
- "@types/node": "^25.6.2",
60
+ "@types/node": "^26.0.0",
61
61
  "@vitest/coverage-v8": "^4.1.5",
62
62
  "knip": "^6.12.1",
63
63
  "lefthook": "^2.1.6",