caldav-mcp 0.12.0 → 0.13.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
@@ -56,6 +56,7 @@ Using caldav-mcp? [Tell us how in three minutes](https://tally.so/r/GepQM2?sourc
56
56
  ### Quick Start
57
57
 
58
58
  Run the MCP server in development mode with auto-reload:
59
+
59
60
  ```bash
60
61
  npm run dev
61
62
  ```
@@ -81,19 +82,21 @@ node dist/index.js
81
82
  The server supports two transports, selected at startup:
82
83
 
83
84
  - **stdio** (default): JSON-RPC over stdin/stdout, suitable for the standard MCP client configuration shown in [Setup](#setup).
85
+
84
86
  ```bash
85
87
  npx caldav-mcp
86
88
  ```
87
89
  - **Streamable HTTP** (`--http`): runs as a long-lived server that remote MCP clients connect to at `POST /mcp`. Each request is handled statelessly, and `GET /health` answers `ok` for health checks.
90
+
88
91
  ```bash
89
92
  MCP_AUTH_TOKEN=your-shared-secret npx caldav-mcp --http
90
93
  ```
91
94
 
92
- | Env var | Default | Description |
93
- |---|---|---|
94
- | `MCP_HOST` | `127.0.0.1` | Bind address. Set to `0.0.0.0` to listen on all interfaces. |
95
- | `MCP_PORT` | `PORT`, else `3000` | TCP port to bind. Falls back to `PORT`, which platforms like Cloud Run set. |
96
- | `MCP_AUTH_TOKEN` | _(unset)_ | When set, requests must send `Authorization: Bearer <MCP_AUTH_TOKEN>`; others get `401`. Required when `MCP_HOST` is not a loopback address. |
95
+ | Env var | Default | Description |
96
+ | ---------------- | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
97
+ | `MCP_HOST` | `127.0.0.1` | Bind address. Set to `0.0.0.0` to listen on all interfaces. |
98
+ | `MCP_PORT` | `PORT`, else `3000` | TCP port to bind. Falls back to `PORT`, which platforms like Cloud Run set. |
99
+ | `MCP_AUTH_TOKEN` | _(unset)_ | When set, requests must send `Authorization: Bearer <MCP_AUTH_TOKEN>`; others get `401`. Required when `MCP_HOST` is not a loopback address. |
97
100
 
98
101
  Connect a client, for example Claude Code (`.mcp.json`):
99
102
 
@@ -117,18 +120,21 @@ The server supports two transports, selected at startup:
117
120
 
118
121
  ## Docker
119
122
 
120
- A `Dockerfile` is provided for running the server with the Streamable HTTP transport — useful when hosting the MCP server as a long-running container that remote MCP clients connect to over HTTP, rather than spawning the binary locally via stdio.
123
+ A container image is available for running the server with the Streamable HTTP transport — useful when hosting the MCP server as a long-running container that remote MCP clients connect to over HTTP, rather than spawning the binary locally via stdio.
124
+
125
+ Each release publishes a multi-arch image (`linux/amd64`, `linux/arm64`) to the GitHub Container Registry, tagged with its full, minor and major version (for example `1.2.3`, `1.2`, `1`) and `latest`:
121
126
 
122
127
  ```bash
123
- docker build -t caldav-mcp .
124
128
  docker run --rm -p 3000:3000 \
125
129
  -e CALDAV_BASE_URL=https://your-caldav-server.com/dav \
126
130
  -e CALDAV_USERNAME=your-username \
127
131
  -e CALDAV_PASSWORD=your-password \
128
132
  -e MCP_AUTH_TOKEN=your-shared-secret \
129
- caldav-mcp
133
+ ghcr.io/langmail/caldav-mcp
130
134
  ```
131
135
 
136
+ To build the image yourself instead, run `docker build -t caldav-mcp .` and use `caldav-mcp` as the image name.
137
+
132
138
  The image binds to `0.0.0.0:3000` (or the port in `MCP_PORT`/`PORT`), serves `POST /mcp`, and reports its health from `GET /health`. Because it listens on all interfaces, `MCP_AUTH_TOKEN` is required: without it the container exits at startup (see [Transports](#transports)). The container is not needed for the default stdio setup in [Setup](#setup) above.
133
139
 
134
140
  ## Available Tools
@@ -141,6 +147,7 @@ List all calendars returning both name and absolute URL. Pass a calendar's `url`
141
147
  Parameters: none
142
148
 
143
149
  Returns:
150
+
144
151
  - List of all available calendars
145
152
 
146
153
  ### list-events
@@ -148,18 +155,21 @@ Returns:
148
155
  List all events between start and end date in the calendar specified by its URL
149
156
 
150
157
  Parameters:
158
+
151
159
  - `calendarUrl`: string
152
160
  - `end`: string — End date (ISO 8601)
153
161
  - `start`: string — Start date (ISO 8601)
154
162
 
155
163
  Returns:
156
- - A list of events that fall within the given timeframe, each containing `uid`, `summary`, `start`, `end`, and optionally `description` and `location`
164
+
165
+ - A list of events that fall within the given timeframe, each containing `uid`, `summary`, `start`, `end`, and optionally `description`, `location`, `organizer` (email) and `attendees` (emails)
157
166
 
158
167
  ### create-event
159
168
 
160
169
  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.
161
170
 
162
171
  Parameters:
172
+
163
173
  - `calendarUrl`: string
164
174
  - `description`: string (optional)
165
175
  - `end`: string — End datetime (ISO 8601)
@@ -174,23 +184,25 @@ Parameters:
174
184
  - `interval`: number (optional)
175
185
  - `until`: string (optional)
176
186
  - `start`: string — Start datetime (ISO 8601)
177
- - `attendees`: array of string (optional) — Attendee emails (no mailto:), written as ATTENDEE lines; a scheduling-capable server mails them the invitation. Use with organizer.
187
+ - `attendees`: array of string (optional) — Attendee emails (no mailto:), written as ATTENDEE lines; a scheduling-capable server mails them the invitation. Requires organizer.
178
188
  - `summary`: string
179
189
  - `wholeDay`: boolean (optional) — Create as a whole-day event
180
190
 
181
191
  Returns:
192
+
182
193
  - The unique ID of the created event
183
194
 
184
195
  ### update-event
185
196
 
186
- 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.
197
+ 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. Any update of an event with attendees rewrites them as bare addresses, dropping their names and replies (accepted/declined).
187
198
 
188
199
  Parameters:
200
+
189
201
  - `calendarUrl`: string
190
202
  - `description`: string (optional)
191
203
  - `end`: string (optional)
192
204
  - `location`: string (optional)
193
- - `organizer`: string (optional) — Organizer email (no mailto:); pass to set or change ORGANIZER. Omit to leave it as stored.
205
+ - `organizer`: string (optional) — Organizer email (no mailto:); pass to set or change ORGANIZER, or an empty string to remove it (only when the event has no attendees). Omit to leave it as stored.
194
206
  - `recurrenceRule`: object (optional)
195
207
  - `byday`: array of string (optional)
196
208
  - `bymonth`: array of number (optional)
@@ -200,12 +212,13 @@ Parameters:
200
212
  - `interval`: number (optional)
201
213
  - `until`: string (optional)
202
214
  - `start`: string (optional)
203
- - `attendees`: array of string (optional) — Full desired attendee list (no mailto:); pass to set/replace ATTENDEE lines. Omit to leave stored attendees untouched.
215
+ - `attendees`: array of string (optional) — The complete new attendee list (no mailto:): it replaces the stored one, so get the current attendees from list-events and include everyone who should stay. An empty list removes all attendees. Omit to leave them as stored. Requires an organizer.
204
216
  - `summary`: string (optional)
205
217
  - `uid`: string — Unique identifier of the event to update (obtained from list-events)
206
218
  - `wholeDay`: boolean (optional) — Update whether this is a whole-day event
207
219
 
208
220
  Returns:
221
+
209
222
  - The unique ID of the updated event
210
223
 
211
224
  ### delete-event
@@ -213,10 +226,12 @@ Returns:
213
226
  Deletes an event in the calendar specified by its URL
214
227
 
215
228
  Parameters:
229
+
216
230
  - `calendarUrl`: string
217
231
  - `uid`: string — Unique identifier of the event to delete (obtained from list-events)
218
232
 
219
233
  Returns:
234
+
220
235
  - Confirmation message when the event is successfully deleted
221
236
 
222
237
  ### list-todos
@@ -224,6 +239,7 @@ Returns:
224
239
  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.
225
240
 
226
241
  Parameters:
242
+
227
243
  - `calendarUrl`: string
228
244
  - `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.
229
245
  - `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.
@@ -232,39 +248,46 @@ Parameters:
232
248
  - `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).
233
249
 
234
250
  Returns:
235
- - 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`.
251
+
252
+ - An object `{ todos, total, limit, offset }` where `total` is the count before pagination. Each todo has `uid`, `summary`, `status`, `reminders` (when the task will notify, as ISO datetimes, or as the raw offset such as `-PT15M` for a relative reminder on a task without `start`; empty when it has none), and optionally `due`, `start`, `completed`, `description`, `location`.
236
253
 
237
254
  ### create-todo
238
255
 
239
- 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.
256
+ 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. Use `reminderAt` when the user wants to be reminded ("remind me tomorrow at 9"); a task without it gets no reminder.
240
257
 
241
258
  Parameters:
259
+
242
260
  - `calendarUrl`: string
243
261
  - `description`: string (optional)
244
262
  - `due`: string (optional) — Due datetime (ISO 8601)
245
263
  - `location`: string (optional)
264
+ - `reminderAt`: string (optional) — When the user's devices should notify about the task: a clock time (ISO 8601 with offset), not an offset from the due date. For "an hour before it's due", pass the due time minus one hour.
246
265
  - `start`: string (optional) — Start datetime (ISO 8601)
247
266
  - `status`: enum (`NEEDS-ACTION` | `COMPLETED` | `IN-PROCESS` | `CANCELLED`) (optional) — Defaults to NEEDS-ACTION when omitted
248
267
  - `summary`: string
249
268
 
250
269
  Returns:
270
+
251
271
  - The unique ID of the created todo
252
272
 
253
273
  ### update-todo
254
274
 
255
- 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.
275
+ Updates an existing task (VTODO) in the calendar specified by its URL. Only provided fields are changed. `reminderAt` replaces the task's reminders with one at that time, `null` removes all of them, and omitting it keeps them. To mark a task done, prefer the `complete-todo` tool.
256
276
 
257
277
  Parameters:
278
+
258
279
  - `calendarUrl`: string
259
280
  - `description`: string (optional)
260
281
  - `due`: string (optional)
261
282
  - `location`: string (optional)
283
+ - `reminderAt`: string | null (optional) — When the user's devices should notify about the task: a clock time (ISO 8601 with offset), not an offset from the due date. For "an hour before it's due", pass the due time minus one hour. Replaces all existing reminders; `null` removes them; omit to keep them.
262
284
  - `start`: string (optional)
263
285
  - `status`: enum (`NEEDS-ACTION` | `COMPLETED` | `IN-PROCESS` | `CANCELLED`) (optional)
264
286
  - `summary`: string (optional)
265
287
  - `uid`: string — Unique identifier of the todo to update (from list-todos)
266
288
 
267
289
  Returns:
290
+
268
291
  - The unique ID of the updated todo
269
292
 
270
293
  ### complete-todo
@@ -272,10 +295,12 @@ Returns:
272
295
  Marks a task (VTODO) as done. Sets its status to COMPLETED and records the completion time.
273
296
 
274
297
  Parameters:
298
+
275
299
  - `calendarUrl`: string
276
300
  - `uid`: string — Unique identifier of the todo to complete (from list-todos)
277
301
 
278
302
  Returns:
303
+
279
304
  - The unique ID of the completed todo
280
305
 
281
306
  ### delete-todo
@@ -283,10 +308,12 @@ Returns:
283
308
  Deletes a task (VTODO) in the calendar specified by its URL
284
309
 
285
310
  Parameters:
311
+
286
312
  - `calendarUrl`: string
287
313
  - `uid`: string — Unique identifier of the todo to delete (from list-todos)
288
314
 
289
315
  Returns:
316
+
290
317
  - Confirmation message when the todo is successfully deleted
291
318
  <!-- TOOLS:END -->
292
319
 
@@ -1,5 +1,5 @@
1
1
  import { createHash, timingSafeEqual } from "node:crypto";
2
- import { createServer as createHttpServer, } from "node:http";
2
+ import { createServer as createHttpServer } from "node:http";
3
3
  import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
4
4
  import { isLoopbackHost } from "./http-config.js";
5
5
  const MCP_PATH = "/mcp";
@@ -0,0 +1,47 @@
1
+ import { z } from "zod";
2
+ // ORGANIZER and ATTENDEE values are written verbatim into the ICS, so an
3
+ // address must not carry anything that changes the line's structure: line
4
+ // breaks (which would start new properties), whitespace, ":" (so a `mailto:`
5
+ // prefix is rejected instead of doubled) or display-name syntax. Deliberately
6
+ // looser than `z.email()`, which rejects `user@localhost` and non-ASCII
7
+ // addresses that self-hosted servers accept.
8
+ const ADDRESS_PART = String.raw `[^\s\p{Cc}@:<>",;]+`;
9
+ const ADDRESS = new RegExp(`^${ADDRESS_PART}@${ADDRESS_PART}$`, "u");
10
+ const ADDRESS_OR_EMPTY = new RegExp(`^(?:${ADDRESS_PART}@${ADDRESS_PART})?$`, "u");
11
+ const MAILTO_PREFIX = /^mailto:/iu;
12
+ const ADDRESS_MESSAGE = "Expected a plain email address such as name@example.com (no mailto:, no display name)";
13
+ export const emailAddressSchema = z
14
+ .string()
15
+ .regex(ADDRESS, { message: ADDRESS_MESSAGE });
16
+ // update-event takes "" to remove the stored organizer.
17
+ export const emailAddressOrEmptySchema = z
18
+ .string()
19
+ .regex(ADDRESS_OR_EMPTY, { message: ADDRESS_MESSAGE });
20
+ export function toCalAddress(email) {
21
+ return `mailto:${email}`;
22
+ }
23
+ function fromCalAddress(value) {
24
+ return value.replace(MAILTO_PREFIX, "");
25
+ }
26
+ function asList(value) {
27
+ if (value === undefined) {
28
+ return [];
29
+ }
30
+ return Array.isArray(value) ? value : [value];
31
+ }
32
+ // ts-caldav keeps properties it doesn't model in `customFields`, keyed by the
33
+ // lowercase property name; a repeated property becomes an array.
34
+ export function readScheduling(customFields) {
35
+ const [organizer] = asList(customFields?.organizer);
36
+ return {
37
+ attendees: asList(customFields?.attendee).map(fromCalAddress),
38
+ organizer: organizer === undefined ? undefined : fromCalAddress(organizer),
39
+ };
40
+ }
41
+ // RFC 5545 requires ORGANIZER on any event that has ATTENDEE properties, and
42
+ // without one a scheduling server sends no invitations.
43
+ export function assertOrganizerForAttendees(organizer, attendees) {
44
+ if (attendees.length > 0 && !organizer) {
45
+ throw new Error("attendees need an organizer: pass `organizer` (the address the invitations come from) or remove the attendees");
46
+ }
47
+ }
@@ -1,5 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { hrefFor, toCalendarPath } from "./caldav-href.js";
3
+ import { writableAlarms } from "./reminder.js";
3
4
  export const completeTodoDefinition = {
4
5
  description: "Marks a task (VTODO) as done. Sets its status to COMPLETED and records the completion time.",
5
6
  inputSchema: {
@@ -26,6 +27,7 @@ export function registerCompleteTodo(client, server) {
26
27
  // RFC 5545: a COMPLETED VTODO should carry a COMPLETED timestamp.
27
28
  const updated = await client.updateTodo(calendarUrl, {
28
29
  ...existing,
30
+ ...(existing.alarms && { alarms: writableAlarms(existing.alarms) }),
29
31
  completed: new Date(),
30
32
  status: "COMPLETED",
31
33
  });
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { toCalendarPath } from "./caldav-href.js";
3
- import { recurrenceRuleSchema, toRecurrenceRule, } from "./recurrence-rule.js";
3
+ import { assertOrganizerForAttendees, emailAddressSchema, toCalAddress, } from "./calendar-address.js";
4
+ import { recurrenceRuleSchema, toRecurrenceRule } from "./recurrence-rule.js";
4
5
  import { toWholeDayDate } from "./whole-day-date.js";
5
6
  export const createEventDefinition = {
6
7
  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.",
@@ -12,8 +13,7 @@ export const createEventDefinition = {
12
13
  .datetime({ offset: true })
13
14
  .describe("End datetime (ISO 8601)"),
14
15
  location: z.string().optional(),
15
- organizer: z
16
- .string()
16
+ organizer: emailAddressSchema
17
17
  .optional()
18
18
  .describe("Organizer email (no mailto:), written as ORGANIZER; a scheduling-capable server (e.g. Radicale with the email/iMIP hook) uses it to send invitations, updates and cancellations to the attendees."),
19
19
  recurrenceRule: recurrenceRuleSchema.optional(),
@@ -22,9 +22,9 @@ export const createEventDefinition = {
22
22
  .datetime({ offset: true })
23
23
  .describe("Start datetime (ISO 8601)"),
24
24
  attendees: z
25
- .array(z.string())
25
+ .array(emailAddressSchema)
26
26
  .optional()
27
- .describe("Attendee emails (no mailto:), written as ATTENDEE lines; a scheduling-capable server mails them the invitation. Use with organizer."),
27
+ .describe("Attendee emails (no mailto:), written as ATTENDEE lines; a scheduling-capable server mails them the invitation. Requires organizer."),
28
28
  summary: z.string(),
29
29
  wholeDay: z.boolean().optional().describe("Create as a whole-day event"),
30
30
  },
@@ -38,15 +38,15 @@ export function registerCreateEvent(client, server) {
38
38
  }, async (args) => {
39
39
  const { summary, start, end, wholeDay, description, location, recurrenceRule, organizer, attendees, } = args;
40
40
  const calendarUrl = toCalendarPath(args.calendarUrl, client.baseUrl);
41
- // organizer/attendees are written through the ts-caldav customFields
42
- // escape hatch (unknown props round-trip as raw ICS lines). The typed
43
- // cast keeps this compiling across ts-caldav versions.
41
+ assertOrganizerForAttendees(organizer, attendees ?? []);
42
+ // organizer/attendees go through ts-caldav's customFields, which it
43
+ // writes as plain ICS properties.
44
44
  const customFields = {};
45
45
  if (organizer) {
46
- customFields.organizer = `mailto:${organizer}`;
46
+ customFields.organizer = toCalAddress(organizer);
47
47
  }
48
48
  if (attendees?.length) {
49
- customFields.attendee = attendees.map((a) => `mailto:${a}`);
49
+ customFields.attendee = attendees.map(toCalAddress);
50
50
  }
51
51
  const event = await client.createEvent(calendarUrl, {
52
52
  end: wholeDay ? toWholeDayDate(end) : new Date(end),
@@ -58,9 +58,7 @@ export function registerCreateEvent(client, server) {
58
58
  ...(recurrenceRule !== undefined && {
59
59
  recurrenceRule: toRecurrenceRule(recurrenceRule, wholeDay),
60
60
  }),
61
- ...(Object.keys(customFields).length > 0 && {
62
- customFields: customFields,
63
- }),
61
+ ...(Object.keys(customFields).length > 0 && { customFields }),
64
62
  });
65
63
  return {
66
64
  content: [{ text: event.uid, type: "text" }],
@@ -1,8 +1,9 @@
1
1
  import { z } from "zod";
2
2
  import { toCalendarPath } from "./caldav-href.js";
3
+ import { reminderAlarm } from "./reminder.js";
3
4
  import { todoStatusSchema } from "./todo-status.js";
4
5
  export const createTodoDefinition = {
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
+ 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. Use `reminderAt` when the user wants to be reminded ("remind me tomorrow at 9"); a task without it gets no reminder.',
6
7
  inputSchema: {
7
8
  calendarUrl: z.string(),
8
9
  description: z.string().optional(),
@@ -12,6 +13,11 @@ export const createTodoDefinition = {
12
13
  .optional()
13
14
  .describe("Due datetime (ISO 8601)"),
14
15
  location: z.string().optional(),
16
+ reminderAt: z
17
+ .string()
18
+ .datetime({ offset: true })
19
+ .optional()
20
+ .describe("When the user's devices should notify about the task: a clock time (ISO 8601 with offset), not an offset from the due date. For \"an hour before it's due\", pass the due time minus one hour."),
15
21
  start: z
16
22
  .string()
17
23
  .datetime({ offset: true })
@@ -30,7 +36,7 @@ export function registerCreateTodo(client, server) {
30
36
  description: createTodoDefinition.description,
31
37
  inputSchema: createTodoDefinition.inputSchema,
32
38
  }, async (args) => {
33
- const { summary, due, start, description, location, status } = args;
39
+ const { summary, due, start, description, location, reminderAt, status } = args;
34
40
  const calendarUrl = toCalendarPath(args.calendarUrl, client.baseUrl);
35
41
  const todo = await client.createTodo(calendarUrl, {
36
42
  summary,
@@ -39,6 +45,9 @@ export function registerCreateTodo(client, server) {
39
45
  ...(description !== undefined && { description }),
40
46
  ...(location !== undefined && { location }),
41
47
  ...(status !== undefined && { status }),
48
+ ...(reminderAt !== undefined && {
49
+ alarms: [reminderAlarm(reminderAt, summary)],
50
+ }),
42
51
  });
43
52
  return {
44
53
  content: [{ text: todo.uid, type: "text" }],
@@ -1,5 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { toCalendarPath } from "./caldav-href.js";
3
+ import { readScheduling } from "./calendar-address.js";
3
4
  export const listEventsDefinition = {
4
5
  description: "List all events between start and end date in the calendar specified by its URL",
5
6
  inputSchema: {
@@ -18,7 +19,7 @@ export const listEventsDefinition = {
18
19
  .describe("Start date (ISO 8601)"),
19
20
  },
20
21
  name: "list-events",
21
- returns: "A list of events that fall within the given timeframe, each containing `uid`, `summary`, `start`, `end`, and optionally `description` and `location`",
22
+ returns: "A list of events that fall within the given timeframe, each containing `uid`, `summary`, `start`, `end`, and optionally `description`, `location`, `organizer` (email) and `attendees` (emails)",
22
23
  };
23
24
  export function registerListEvents(client, server) {
24
25
  server.registerTool(listEventsDefinition.name, {
@@ -32,14 +33,19 @@ export function registerListEvents(client, server) {
32
33
  start: new Date(start),
33
34
  };
34
35
  const allEvents = await client.getEvents(calendarUrl, options);
35
- const data = allEvents.map((e) => ({
36
- end: e.end,
37
- start: e.start,
38
- summary: e.summary,
39
- uid: e.uid,
40
- ...(e.description && { description: e.description }),
41
- ...(e.location && { location: e.location }),
42
- }));
36
+ const data = allEvents.map((e) => {
37
+ const { organizer, attendees } = readScheduling(e.customFields);
38
+ return {
39
+ end: e.end,
40
+ start: e.start,
41
+ summary: e.summary,
42
+ uid: e.uid,
43
+ ...(e.description && { description: e.description }),
44
+ ...(e.location && { location: e.location }),
45
+ ...(organizer && { organizer }),
46
+ ...(attendees.length > 0 && { attendees }),
47
+ };
48
+ });
43
49
  return {
44
50
  content: [{ text: JSON.stringify(data), type: "text" }],
45
51
  };
@@ -1,5 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { toCalendarPath } from "./caldav-href.js";
3
+ import { reminderTimes } from "./reminder.js";
3
4
  import { todoStatusSchema } from "./todo-status.js";
4
5
  // `OPEN`/`ALL` are filter keywords expressing sets no single status can (a union
5
6
  // and "no filter"); the four raw statuses allow an exact-status query. The raw
@@ -65,7 +66,7 @@ export const listTodosDefinition = {
65
66
  .describe("Filter by status. `OPEN` (default) = NEEDS-ACTION + IN-PROCESS; `ALL` = everything; or an exact status (NEEDS-ACTION, COMPLETED, IN-PROCESS, CANCELLED)."),
66
67
  },
67
68
  name: "list-todos",
68
- 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`.",
69
+ returns: "An object `{ todos, total, limit, offset }` where `total` is the count before pagination. Each todo has `uid`, `summary`, `status`, `reminders` (when the task will notify, as ISO datetimes, or as the raw offset such as `-PT15M` for a relative reminder on a task without `start`; empty when it has none), and optionally `due`, `start`, `completed`, `description`, `location`.",
69
70
  };
70
71
  export function registerListTodos(client, server) {
71
72
  server.registerTool(listTodosDefinition.name, {
@@ -114,6 +115,7 @@ export function registerListTodos(client, server) {
114
115
  .filter((t) => matchesStatus(t) && matchesWindow(t))
115
116
  .sort(compareTodos);
116
117
  const todos = filtered.slice(offset, offset + limit).map((t) => ({
118
+ reminders: reminderTimes(t.alarms ?? [], t.start),
117
119
  status: statusOf(t),
118
120
  summary: t.summary,
119
121
  uid: t.uid,
@@ -0,0 +1,67 @@
1
+ import ICAL from "ical.js";
2
+ // A trigger that ts-caldav read back is a string: an ISO 8601 duration
3
+ // (`-PT15M`) for a relative alarm, or a datetime (`2026-11-27T08:00:00Z`) for
4
+ // an absolute one. ts-caldav's `addAlarms` hands the trigger to ical.js as is,
5
+ // which parses a string as a duration, so only an `ICAL.Time` writes a
6
+ // `TRIGGER;VALUE=DATE-TIME`. The `Alarm` type says `string`, hence the casts.
7
+ // Workaround for the lost trigger parameters, reported in issue #192.
8
+ const DURATION = /^[+-]?P/u;
9
+ function isDuration(trigger) {
10
+ return DURATION.test(trigger);
11
+ }
12
+ /** One display alarm that fires at `at` (ISO 8601 with offset). */
13
+ export function reminderAlarm(at, description) {
14
+ const trigger = ICAL.Time.fromJSDate(new Date(at), true);
15
+ return {
16
+ action: "DISPLAY",
17
+ description,
18
+ trigger: trigger,
19
+ };
20
+ }
21
+ /**
22
+ * Alarms as read from the server, made writable again: an absolute trigger
23
+ * becomes an `ICAL.Time`, so writing it back keeps `VALUE=DATE-TIME` instead
24
+ * of throwing `invalid duration value`.
25
+ */
26
+ export function writableAlarms(alarms) {
27
+ return alarms.map((alarm) => isDuration(alarm.trigger)
28
+ ? alarm
29
+ : {
30
+ ...alarm,
31
+ trigger: ICAL.Time.fromDateTimeString(alarm.trigger),
32
+ });
33
+ }
34
+ /**
35
+ * When each alarm fires, as ISO datetimes. A relative trigger is resolved
36
+ * against `start`; without one it is returned as the raw duration. ts-caldav
37
+ * drops `RELATED=END`, so a due-relative trigger is resolved wrongly (#192).
38
+ */
39
+ export function reminderTimes(alarms, start) {
40
+ return alarms.map(({ trigger }) => {
41
+ if (!isDuration(trigger)) {
42
+ return new Date(trigger).toISOString();
43
+ }
44
+ if (!start) {
45
+ return trigger;
46
+ }
47
+ const seconds = ICAL.Duration.fromString(trigger).toSeconds();
48
+ return new Date(start.getTime() + seconds * 1000).toISOString();
49
+ });
50
+ }
51
+ /**
52
+ * The alarms an update writes: `reminderAt` replaces them all with one,
53
+ * `null` removes them, and omitting it keeps the existing ones. A kept
54
+ * display alarm that showed the old summary shows the new one.
55
+ */
56
+ export function updatedAlarms(existing, reminderAt, summary) {
57
+ if (reminderAt === null) {
58
+ return [];
59
+ }
60
+ if (reminderAt !== undefined) {
61
+ return [reminderAlarm(reminderAt, summary.after)];
62
+ }
63
+ return (existing &&
64
+ writableAlarms(existing).map((alarm) => alarm.action === "DISPLAY" && alarm.description === summary.before
65
+ ? { ...alarm, description: summary.after }
66
+ : alarm));
67
+ }
@@ -1,24 +1,24 @@
1
1
  import { z } from "zod";
2
2
  import { hrefFor, toCalendarPath } from "./caldav-href.js";
3
- import { recurrenceRuleSchema, toRecurrenceRule, } from "./recurrence-rule.js";
3
+ import { assertOrganizerForAttendees, emailAddressOrEmptySchema, emailAddressSchema, readScheduling, toCalAddress, } from "./calendar-address.js";
4
+ import { recurrenceRuleSchema, toRecurrenceRule } from "./recurrence-rule.js";
4
5
  import { carryOverWholeDayDates, toWholeDayDate } from "./whole-day-date.js";
5
6
  export const updateEventDefinition = {
6
- 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.",
7
+ 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. Any update of an event with attendees rewrites them as bare addresses, dropping their names and replies (accepted/declined).",
7
8
  inputSchema: {
8
9
  calendarUrl: z.string(),
9
10
  description: z.string().optional(),
10
11
  end: z.string().datetime({ offset: true }).optional(),
11
12
  location: z.string().optional(),
12
- organizer: z
13
- .string()
13
+ organizer: emailAddressOrEmptySchema
14
14
  .optional()
15
- .describe("Organizer email (no mailto:); pass to set or change ORGANIZER. Omit to leave it as stored."),
15
+ .describe("Organizer email (no mailto:); pass to set or change ORGANIZER, or an empty string to remove it (only when the event has no attendees). Omit to leave it as stored."),
16
16
  recurrenceRule: recurrenceRuleSchema.optional(),
17
17
  start: z.string().datetime({ offset: true }).optional(),
18
18
  attendees: z
19
- .array(z.string())
19
+ .array(emailAddressSchema)
20
20
  .optional()
21
- .describe("Full desired attendee list (no mailto:); pass to set/replace ATTENDEE lines. Omit to leave stored attendees untouched."),
21
+ .describe("The complete new attendee list (no mailto:): it replaces the stored one, so get the current attendees from list-events and include everyone who should stay. An empty list removes all attendees. Omit to leave them as stored. Requires an organizer."),
22
22
  summary: z.string().optional(),
23
23
  uid: z
24
24
  .string()
@@ -31,25 +31,22 @@ export const updateEventDefinition = {
31
31
  name: "update-event",
32
32
  returns: "The unique ID of the updated event",
33
33
  };
34
- // Merge organizer/attendees into the event's stored customFields
35
- // (ts-caldav round-trips unknown props there); never wipe other fields.
34
+ // Merge organizer/attendees into the event's stored customFields (ts-caldav
35
+ // keeps properties it doesn't model there) without touching other fields.
36
36
  // An empty organizer or attendee list removes the stored value.
37
- function mergeSchedulingFields(existing, organizer, attendees) {
38
- const { organizer: storedOrganizer, attendee: storedAttendees, ...rest } = existing.customFields ?? {};
39
- const next = { ...rest };
40
- const nextOrganizer = organizer === undefined
41
- ? storedOrganizer
42
- : organizer && `mailto:${organizer}`;
43
- if (nextOrganizer) {
44
- next.organizer = nextOrganizer;
45
- }
46
- const nextAttendees = attendees === undefined
47
- ? storedAttendees
48
- : attendees.map((a) => `mailto:${a}`);
49
- if (nextAttendees?.length) {
50
- next.attendee = nextAttendees;
51
- }
52
- return next;
37
+ function mergeSchedulingFields(stored, organizer, attendees) {
38
+ const current = readScheduling(stored);
39
+ const nextOrganizer = organizer ?? current.organizer;
40
+ const nextAttendees = attendees ?? current.attendees;
41
+ assertOrganizerForAttendees(nextOrganizer, nextAttendees);
42
+ const { organizer: _organizer, attendee: _attendee, ...rest } = stored ?? {};
43
+ return {
44
+ ...rest,
45
+ ...(nextOrganizer && { organizer: toCalAddress(nextOrganizer) }),
46
+ ...(nextAttendees.length > 0 && {
47
+ attendee: nextAttendees.map(toCalAddress),
48
+ }),
49
+ };
53
50
  }
54
51
  export function registerUpdateEvent(client, server) {
55
52
  server.registerTool(updateEventDefinition.name, {
@@ -83,7 +80,7 @@ export function registerUpdateEvent(client, server) {
83
80
  recurrenceRule: toRecurrenceRule(recurrenceRule, effectiveWholeDay),
84
81
  }),
85
82
  ...((organizer !== undefined || attendees !== undefined) && {
86
- customFields: mergeSchedulingFields(existing, organizer, attendees),
83
+ customFields: mergeSchedulingFields(existing.customFields, organizer, attendees),
87
84
  }),
88
85
  });
89
86
  return {
@@ -1,13 +1,20 @@
1
1
  import { z } from "zod";
2
2
  import { hrefFor, toCalendarPath } from "./caldav-href.js";
3
+ import { updatedAlarms } from "./reminder.js";
3
4
  import { todoStatusSchema } from "./todo-status.js";
4
5
  export const updateTodoDefinition = {
5
- 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.",
6
+ description: "Updates an existing task (VTODO) in the calendar specified by its URL. Only provided fields are changed. `reminderAt` replaces the task's reminders with one at that time, `null` removes all of them, and omitting it keeps them. To mark a task done, prefer the `complete-todo` tool.",
6
7
  inputSchema: {
7
8
  calendarUrl: z.string(),
8
9
  description: z.string().optional(),
9
10
  due: z.string().datetime({ offset: true }).optional(),
10
11
  location: z.string().optional(),
12
+ reminderAt: z
13
+ .string()
14
+ .datetime({ offset: true })
15
+ .nullable()
16
+ .optional()
17
+ .describe("When the user's devices should notify about the task: a clock time (ISO 8601 with offset), not an offset from the due date. For \"an hour before it's due\", pass the due time minus one hour. Replaces all existing reminders; `null` removes them; omit to keep them."),
11
18
  start: z.string().datetime({ offset: true }).optional(),
12
19
  status: todoStatusSchema.optional(),
13
20
  summary: z.string().optional(),
@@ -23,7 +30,7 @@ export function registerUpdateTodo(client, server) {
23
30
  description: updateTodoDefinition.description,
24
31
  inputSchema: updateTodoDefinition.inputSchema,
25
32
  }, async (args) => {
26
- const { uid, summary, due, start, description, location, status } = args;
33
+ const { uid, summary, due, start, description, location, reminderAt, status, } = args;
27
34
  const calendarUrl = toCalendarPath(args.calendarUrl, client.baseUrl);
28
35
  const href = hrefFor(calendarUrl, uid);
29
36
  const [existing] = await client.getTodosByHref(calendarUrl, [href]);
@@ -45,6 +52,10 @@ export function registerUpdateTodo(client, server) {
45
52
  else if (status === "COMPLETED") {
46
53
  completed = priorCompleted ?? new Date();
47
54
  }
55
+ const alarms = updatedAlarms(base.alarms, reminderAt, {
56
+ after: summary ?? base.summary,
57
+ before: base.summary,
58
+ });
48
59
  const updated = await client.updateTodo(calendarUrl, {
49
60
  ...base,
50
61
  ...(summary !== undefined && { summary }),
@@ -54,6 +65,7 @@ export function registerUpdateTodo(client, server) {
54
65
  ...(location !== undefined && { location }),
55
66
  ...(status !== undefined && { status }),
56
67
  ...(completed !== undefined && { completed }),
68
+ ...(alarms !== undefined && { alarms }),
57
69
  });
58
70
  return {
59
71
  content: [{ text: updated.uid, type: "text" }],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "caldav-mcp",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "A CalDAV client using Model Context Protocol (MCP) to expose calendar operations as tools for AI assistants.",
5
5
  "homepage": "https://github.com/langmail/caldav-mcp#readme",
6
6
  "bugs": {
@@ -33,7 +33,7 @@
33
33
  "prepare": "lefthook install",
34
34
  "semantic-release": "semantic-release",
35
35
  "smoke": "npm run build && tsx --env-file=.env scripts/smoke.ts",
36
- "smoke:agent": "npm run build && bash scripts/smoke-agent.sh",
36
+ "smoke:agent": "npm run build && bash scripts/smoke-agent.sh && tsx --env-file=.env scripts/smoke-agent-reminder.ts",
37
37
  "smoke:http": "npm run build && SMOKE_TRANSPORT=http tsx --env-file=.env scripts/smoke.ts",
38
38
  "test": "vitest run",
39
39
  "test:coverage": "vitest run --coverage",
@@ -43,6 +43,7 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@modelcontextprotocol/sdk": "^1.26.0",
46
+ "ical.js": "^2.2.1",
46
47
  "ts-caldav": "^0.4.0",
47
48
  "zod": "^4.4.3"
48
49
  },
@@ -62,7 +63,7 @@
62
63
  "shx": "^0.4.0",
63
64
  "tsx": "^4.21.0",
64
65
  "typescript": "^7.0.2",
65
- "ultracite": "8.2.0",
66
+ "ultracite": "8.3.1",
66
67
  "vitest": "^5.0.0"
67
68
  },
68
69
  "engines": {