caldav-mcp 0.11.4 → 0.12.1
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 +33 -7
- package/dist/http-server.js +1 -1
- package/dist/tools/calendar-address.js +47 -0
- package/dist/tools/create-event.js +21 -2
- package/dist/tools/list-events.js +15 -9
- package/dist/tools/update-event.js +31 -3
- package/package.json +2 -2
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
|
|
93
|
-
|
|
94
|
-
| `MCP_HOST`
|
|
95
|
-
| `MCP_PORT`
|
|
96
|
-
| `MCP_AUTH_TOKEN` | _(unset)_
|
|
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
|
|
|
@@ -141,6 +144,7 @@ List all calendars returning both name and absolute URL. Pass a calendar's `url`
|
|
|
141
144
|
Parameters: none
|
|
142
145
|
|
|
143
146
|
Returns:
|
|
147
|
+
|
|
144
148
|
- List of all available calendars
|
|
145
149
|
|
|
146
150
|
### list-events
|
|
@@ -148,22 +152,26 @@ Returns:
|
|
|
148
152
|
List all events between start and end date in the calendar specified by its URL
|
|
149
153
|
|
|
150
154
|
Parameters:
|
|
155
|
+
|
|
151
156
|
- `calendarUrl`: string
|
|
152
157
|
- `end`: string — End date (ISO 8601)
|
|
153
158
|
- `start`: string — Start date (ISO 8601)
|
|
154
159
|
|
|
155
160
|
Returns:
|
|
156
|
-
|
|
161
|
+
|
|
162
|
+
- 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
163
|
|
|
158
164
|
### create-event
|
|
159
165
|
|
|
160
166
|
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
167
|
|
|
162
168
|
Parameters:
|
|
169
|
+
|
|
163
170
|
- `calendarUrl`: string
|
|
164
171
|
- `description`: string (optional)
|
|
165
172
|
- `end`: string — End datetime (ISO 8601)
|
|
166
173
|
- `location`: string (optional)
|
|
174
|
+
- `organizer`: string (optional) — 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.
|
|
167
175
|
- `recurrenceRule`: object (optional)
|
|
168
176
|
- `byday`: array of string (optional)
|
|
169
177
|
- `bymonth`: array of number (optional)
|
|
@@ -173,21 +181,25 @@ Parameters:
|
|
|
173
181
|
- `interval`: number (optional)
|
|
174
182
|
- `until`: string (optional)
|
|
175
183
|
- `start`: string — Start datetime (ISO 8601)
|
|
184
|
+
- `attendees`: array of string (optional) — Attendee emails (no mailto:), written as ATTENDEE lines; a scheduling-capable server mails them the invitation. Requires organizer.
|
|
176
185
|
- `summary`: string
|
|
177
186
|
- `wholeDay`: boolean (optional) — Create as a whole-day event
|
|
178
187
|
|
|
179
188
|
Returns:
|
|
189
|
+
|
|
180
190
|
- The unique ID of the created event
|
|
181
191
|
|
|
182
192
|
### update-event
|
|
183
193
|
|
|
184
|
-
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.
|
|
194
|
+
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).
|
|
185
195
|
|
|
186
196
|
Parameters:
|
|
197
|
+
|
|
187
198
|
- `calendarUrl`: string
|
|
188
199
|
- `description`: string (optional)
|
|
189
200
|
- `end`: string (optional)
|
|
190
201
|
- `location`: string (optional)
|
|
202
|
+
- `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.
|
|
191
203
|
- `recurrenceRule`: object (optional)
|
|
192
204
|
- `byday`: array of string (optional)
|
|
193
205
|
- `bymonth`: array of number (optional)
|
|
@@ -197,11 +209,13 @@ Parameters:
|
|
|
197
209
|
- `interval`: number (optional)
|
|
198
210
|
- `until`: string (optional)
|
|
199
211
|
- `start`: string (optional)
|
|
212
|
+
- `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.
|
|
200
213
|
- `summary`: string (optional)
|
|
201
214
|
- `uid`: string — Unique identifier of the event to update (obtained from list-events)
|
|
202
215
|
- `wholeDay`: boolean (optional) — Update whether this is a whole-day event
|
|
203
216
|
|
|
204
217
|
Returns:
|
|
218
|
+
|
|
205
219
|
- The unique ID of the updated event
|
|
206
220
|
|
|
207
221
|
### delete-event
|
|
@@ -209,10 +223,12 @@ Returns:
|
|
|
209
223
|
Deletes an event in the calendar specified by its URL
|
|
210
224
|
|
|
211
225
|
Parameters:
|
|
226
|
+
|
|
212
227
|
- `calendarUrl`: string
|
|
213
228
|
- `uid`: string — Unique identifier of the event to delete (obtained from list-events)
|
|
214
229
|
|
|
215
230
|
Returns:
|
|
231
|
+
|
|
216
232
|
- Confirmation message when the event is successfully deleted
|
|
217
233
|
|
|
218
234
|
### list-todos
|
|
@@ -220,6 +236,7 @@ Returns:
|
|
|
220
236
|
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.
|
|
221
237
|
|
|
222
238
|
Parameters:
|
|
239
|
+
|
|
223
240
|
- `calendarUrl`: string
|
|
224
241
|
- `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.
|
|
225
242
|
- `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.
|
|
@@ -228,6 +245,7 @@ Parameters:
|
|
|
228
245
|
- `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).
|
|
229
246
|
|
|
230
247
|
Returns:
|
|
248
|
+
|
|
231
249
|
- 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`.
|
|
232
250
|
|
|
233
251
|
### create-todo
|
|
@@ -235,6 +253,7 @@ Returns:
|
|
|
235
253
|
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.
|
|
236
254
|
|
|
237
255
|
Parameters:
|
|
256
|
+
|
|
238
257
|
- `calendarUrl`: string
|
|
239
258
|
- `description`: string (optional)
|
|
240
259
|
- `due`: string (optional) — Due datetime (ISO 8601)
|
|
@@ -244,6 +263,7 @@ Parameters:
|
|
|
244
263
|
- `summary`: string
|
|
245
264
|
|
|
246
265
|
Returns:
|
|
266
|
+
|
|
247
267
|
- The unique ID of the created todo
|
|
248
268
|
|
|
249
269
|
### update-todo
|
|
@@ -251,6 +271,7 @@ Returns:
|
|
|
251
271
|
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.
|
|
252
272
|
|
|
253
273
|
Parameters:
|
|
274
|
+
|
|
254
275
|
- `calendarUrl`: string
|
|
255
276
|
- `description`: string (optional)
|
|
256
277
|
- `due`: string (optional)
|
|
@@ -261,6 +282,7 @@ Parameters:
|
|
|
261
282
|
- `uid`: string — Unique identifier of the todo to update (from list-todos)
|
|
262
283
|
|
|
263
284
|
Returns:
|
|
285
|
+
|
|
264
286
|
- The unique ID of the updated todo
|
|
265
287
|
|
|
266
288
|
### complete-todo
|
|
@@ -268,10 +290,12 @@ Returns:
|
|
|
268
290
|
Marks a task (VTODO) as done. Sets its status to COMPLETED and records the completion time.
|
|
269
291
|
|
|
270
292
|
Parameters:
|
|
293
|
+
|
|
271
294
|
- `calendarUrl`: string
|
|
272
295
|
- `uid`: string — Unique identifier of the todo to complete (from list-todos)
|
|
273
296
|
|
|
274
297
|
Returns:
|
|
298
|
+
|
|
275
299
|
- The unique ID of the completed todo
|
|
276
300
|
|
|
277
301
|
### delete-todo
|
|
@@ -279,10 +303,12 @@ Returns:
|
|
|
279
303
|
Deletes a task (VTODO) in the calendar specified by its URL
|
|
280
304
|
|
|
281
305
|
Parameters:
|
|
306
|
+
|
|
282
307
|
- `calendarUrl`: string
|
|
283
308
|
- `uid`: string — Unique identifier of the todo to delete (from list-todos)
|
|
284
309
|
|
|
285
310
|
Returns:
|
|
311
|
+
|
|
286
312
|
- Confirmation message when the todo is successfully deleted
|
|
287
313
|
<!-- TOOLS:END -->
|
|
288
314
|
|
package/dist/http-server.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash, timingSafeEqual } from "node:crypto";
|
|
2
|
-
import { createServer as createHttpServer
|
|
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,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { toCalendarPath } from "./caldav-href.js";
|
|
3
|
-
import {
|
|
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,11 +13,18 @@ export const createEventDefinition = {
|
|
|
12
13
|
.datetime({ offset: true })
|
|
13
14
|
.describe("End datetime (ISO 8601)"),
|
|
14
15
|
location: z.string().optional(),
|
|
16
|
+
organizer: emailAddressSchema
|
|
17
|
+
.optional()
|
|
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."),
|
|
15
19
|
recurrenceRule: recurrenceRuleSchema.optional(),
|
|
16
20
|
start: z
|
|
17
21
|
.string()
|
|
18
22
|
.datetime({ offset: true })
|
|
19
23
|
.describe("Start datetime (ISO 8601)"),
|
|
24
|
+
attendees: z
|
|
25
|
+
.array(emailAddressSchema)
|
|
26
|
+
.optional()
|
|
27
|
+
.describe("Attendee emails (no mailto:), written as ATTENDEE lines; a scheduling-capable server mails them the invitation. Requires organizer."),
|
|
20
28
|
summary: z.string(),
|
|
21
29
|
wholeDay: z.boolean().optional().describe("Create as a whole-day event"),
|
|
22
30
|
},
|
|
@@ -28,8 +36,18 @@ export function registerCreateEvent(client, server) {
|
|
|
28
36
|
description: createEventDefinition.description,
|
|
29
37
|
inputSchema: createEventDefinition.inputSchema,
|
|
30
38
|
}, async (args) => {
|
|
31
|
-
const { summary, start, end, wholeDay, description, location, recurrenceRule, } = args;
|
|
39
|
+
const { summary, start, end, wholeDay, description, location, recurrenceRule, organizer, attendees, } = args;
|
|
32
40
|
const calendarUrl = toCalendarPath(args.calendarUrl, client.baseUrl);
|
|
41
|
+
assertOrganizerForAttendees(organizer, attendees ?? []);
|
|
42
|
+
// organizer/attendees go through ts-caldav's customFields, which it
|
|
43
|
+
// writes as plain ICS properties.
|
|
44
|
+
const customFields = {};
|
|
45
|
+
if (organizer) {
|
|
46
|
+
customFields.organizer = toCalAddress(organizer);
|
|
47
|
+
}
|
|
48
|
+
if (attendees?.length) {
|
|
49
|
+
customFields.attendee = attendees.map(toCalAddress);
|
|
50
|
+
}
|
|
33
51
|
const event = await client.createEvent(calendarUrl, {
|
|
34
52
|
end: wholeDay ? toWholeDayDate(end) : new Date(end),
|
|
35
53
|
start: wholeDay ? toWholeDayDate(start) : new Date(start),
|
|
@@ -40,6 +58,7 @@ export function registerCreateEvent(client, server) {
|
|
|
40
58
|
...(recurrenceRule !== undefined && {
|
|
41
59
|
recurrenceRule: toRecurrenceRule(recurrenceRule, wholeDay),
|
|
42
60
|
}),
|
|
61
|
+
...(Object.keys(customFields).length > 0 && { customFields }),
|
|
43
62
|
});
|
|
44
63
|
return {
|
|
45
64
|
content: [{ text: event.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 `
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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,16 +1,24 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { hrefFor, toCalendarPath } from "./caldav-href.js";
|
|
3
|
-
import {
|
|
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(),
|
|
13
|
+
organizer: emailAddressOrEmptySchema
|
|
14
|
+
.optional()
|
|
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."),
|
|
12
16
|
recurrenceRule: recurrenceRuleSchema.optional(),
|
|
13
17
|
start: z.string().datetime({ offset: true }).optional(),
|
|
18
|
+
attendees: z
|
|
19
|
+
.array(emailAddressSchema)
|
|
20
|
+
.optional()
|
|
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."),
|
|
14
22
|
summary: z.string().optional(),
|
|
15
23
|
uid: z
|
|
16
24
|
.string()
|
|
@@ -23,12 +31,29 @@ export const updateEventDefinition = {
|
|
|
23
31
|
name: "update-event",
|
|
24
32
|
returns: "The unique ID of the updated event",
|
|
25
33
|
};
|
|
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
|
+
// An empty organizer or attendee list removes the stored value.
|
|
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
|
+
};
|
|
50
|
+
}
|
|
26
51
|
export function registerUpdateEvent(client, server) {
|
|
27
52
|
server.registerTool(updateEventDefinition.name, {
|
|
28
53
|
description: updateEventDefinition.description,
|
|
29
54
|
inputSchema: updateEventDefinition.inputSchema,
|
|
30
55
|
}, async (args) => {
|
|
31
|
-
const { uid, summary, start, end, wholeDay, description, location, recurrenceRule, } = args;
|
|
56
|
+
const { uid, summary, start, end, wholeDay, description, location, recurrenceRule, organizer, attendees, } = args;
|
|
32
57
|
const calendarUrl = toCalendarPath(args.calendarUrl, client.baseUrl);
|
|
33
58
|
const href = hrefFor(calendarUrl, uid);
|
|
34
59
|
const [existing] = await client.getEventsByHref(calendarUrl, [href]);
|
|
@@ -54,6 +79,9 @@ export function registerUpdateEvent(client, server) {
|
|
|
54
79
|
...(recurrenceRule !== undefined && {
|
|
55
80
|
recurrenceRule: toRecurrenceRule(recurrenceRule, effectiveWholeDay),
|
|
56
81
|
}),
|
|
82
|
+
...((organizer !== undefined || attendees !== undefined) && {
|
|
83
|
+
customFields: mergeSchedulingFields(existing.customFields, organizer, attendees),
|
|
84
|
+
}),
|
|
57
85
|
});
|
|
58
86
|
return {
|
|
59
87
|
content: [{ text: updated.uid, type: "text" }],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "caldav-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.1",
|
|
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": {
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"shx": "^0.4.0",
|
|
63
63
|
"tsx": "^4.21.0",
|
|
64
64
|
"typescript": "^7.0.2",
|
|
65
|
-
"ultracite": "8.
|
|
65
|
+
"ultracite": "8.3.1",
|
|
66
66
|
"vitest": "^5.0.0"
|
|
67
67
|
},
|
|
68
68
|
"engines": {
|