caldav-mcp 0.12.0 → 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 +32 -10
- package/dist/http-server.js +1 -1
- package/dist/tools/calendar-address.js +47 -0
- package/dist/tools/create-event.js +11 -13
- package/dist/tools/list-events.js +15 -9
- package/dist/tools/update-event.js +23 -26
- 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,18 +152,21 @@ 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)
|
|
@@ -174,23 +181,25 @@ Parameters:
|
|
|
174
181
|
- `interval`: number (optional)
|
|
175
182
|
- `until`: string (optional)
|
|
176
183
|
- `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.
|
|
184
|
+
- `attendees`: array of string (optional) — Attendee emails (no mailto:), written as ATTENDEE lines; a scheduling-capable server mails them the invitation. Requires organizer.
|
|
178
185
|
- `summary`: string
|
|
179
186
|
- `wholeDay`: boolean (optional) — Create as a whole-day event
|
|
180
187
|
|
|
181
188
|
Returns:
|
|
189
|
+
|
|
182
190
|
- The unique ID of the created event
|
|
183
191
|
|
|
184
192
|
### update-event
|
|
185
193
|
|
|
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.
|
|
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).
|
|
187
195
|
|
|
188
196
|
Parameters:
|
|
197
|
+
|
|
189
198
|
- `calendarUrl`: string
|
|
190
199
|
- `description`: string (optional)
|
|
191
200
|
- `end`: string (optional)
|
|
192
201
|
- `location`: string (optional)
|
|
193
|
-
- `organizer`: string (optional) — Organizer email (no mailto:); pass to set or change ORGANIZER. Omit to leave it as stored.
|
|
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.
|
|
194
203
|
- `recurrenceRule`: object (optional)
|
|
195
204
|
- `byday`: array of string (optional)
|
|
196
205
|
- `bymonth`: array of number (optional)
|
|
@@ -200,12 +209,13 @@ Parameters:
|
|
|
200
209
|
- `interval`: number (optional)
|
|
201
210
|
- `until`: string (optional)
|
|
202
211
|
- `start`: string (optional)
|
|
203
|
-
- `attendees`: array of 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.
|
|
204
213
|
- `summary`: string (optional)
|
|
205
214
|
- `uid`: string — Unique identifier of the event to update (obtained from list-events)
|
|
206
215
|
- `wholeDay`: boolean (optional) — Update whether this is a whole-day event
|
|
207
216
|
|
|
208
217
|
Returns:
|
|
218
|
+
|
|
209
219
|
- The unique ID of the updated event
|
|
210
220
|
|
|
211
221
|
### delete-event
|
|
@@ -213,10 +223,12 @@ Returns:
|
|
|
213
223
|
Deletes an event in the calendar specified by its URL
|
|
214
224
|
|
|
215
225
|
Parameters:
|
|
226
|
+
|
|
216
227
|
- `calendarUrl`: string
|
|
217
228
|
- `uid`: string — Unique identifier of the event to delete (obtained from list-events)
|
|
218
229
|
|
|
219
230
|
Returns:
|
|
231
|
+
|
|
220
232
|
- Confirmation message when the event is successfully deleted
|
|
221
233
|
|
|
222
234
|
### list-todos
|
|
@@ -224,6 +236,7 @@ Returns:
|
|
|
224
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.
|
|
225
237
|
|
|
226
238
|
Parameters:
|
|
239
|
+
|
|
227
240
|
- `calendarUrl`: string
|
|
228
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.
|
|
229
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.
|
|
@@ -232,6 +245,7 @@ Parameters:
|
|
|
232
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).
|
|
233
246
|
|
|
234
247
|
Returns:
|
|
248
|
+
|
|
235
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`.
|
|
236
250
|
|
|
237
251
|
### create-todo
|
|
@@ -239,6 +253,7 @@ Returns:
|
|
|
239
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.
|
|
240
254
|
|
|
241
255
|
Parameters:
|
|
256
|
+
|
|
242
257
|
- `calendarUrl`: string
|
|
243
258
|
- `description`: string (optional)
|
|
244
259
|
- `due`: string (optional) — Due datetime (ISO 8601)
|
|
@@ -248,6 +263,7 @@ Parameters:
|
|
|
248
263
|
- `summary`: string
|
|
249
264
|
|
|
250
265
|
Returns:
|
|
266
|
+
|
|
251
267
|
- The unique ID of the created todo
|
|
252
268
|
|
|
253
269
|
### update-todo
|
|
@@ -255,6 +271,7 @@ Returns:
|
|
|
255
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.
|
|
256
272
|
|
|
257
273
|
Parameters:
|
|
274
|
+
|
|
258
275
|
- `calendarUrl`: string
|
|
259
276
|
- `description`: string (optional)
|
|
260
277
|
- `due`: string (optional)
|
|
@@ -265,6 +282,7 @@ Parameters:
|
|
|
265
282
|
- `uid`: string — Unique identifier of the todo to update (from list-todos)
|
|
266
283
|
|
|
267
284
|
Returns:
|
|
285
|
+
|
|
268
286
|
- The unique ID of the updated todo
|
|
269
287
|
|
|
270
288
|
### complete-todo
|
|
@@ -272,10 +290,12 @@ Returns:
|
|
|
272
290
|
Marks a task (VTODO) as done. Sets its status to COMPLETED and records the completion time.
|
|
273
291
|
|
|
274
292
|
Parameters:
|
|
293
|
+
|
|
275
294
|
- `calendarUrl`: string
|
|
276
295
|
- `uid`: string — Unique identifier of the todo to complete (from list-todos)
|
|
277
296
|
|
|
278
297
|
Returns:
|
|
298
|
+
|
|
279
299
|
- The unique ID of the completed todo
|
|
280
300
|
|
|
281
301
|
### delete-todo
|
|
@@ -283,10 +303,12 @@ Returns:
|
|
|
283
303
|
Deletes a task (VTODO) in the calendar specified by its URL
|
|
284
304
|
|
|
285
305
|
Parameters:
|
|
306
|
+
|
|
286
307
|
- `calendarUrl`: string
|
|
287
308
|
- `uid`: string — Unique identifier of the todo to delete (from list-todos)
|
|
288
309
|
|
|
289
310
|
Returns:
|
|
311
|
+
|
|
290
312
|
- Confirmation message when the todo is successfully deleted
|
|
291
313
|
<!-- TOOLS:END -->
|
|
292
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,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:
|
|
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(
|
|
25
|
+
.array(emailAddressSchema)
|
|
26
26
|
.optional()
|
|
27
|
-
.describe("Attendee emails (no mailto:), written as ATTENDEE lines; a scheduling-capable server mails them the invitation.
|
|
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
|
-
|
|
42
|
-
//
|
|
43
|
-
//
|
|
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 =
|
|
46
|
+
customFields.organizer = toCalAddress(organizer);
|
|
47
47
|
}
|
|
48
48
|
if (attendees?.length) {
|
|
49
|
-
customFields.attendee = attendees.map(
|
|
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,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,24 +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(),
|
|
12
|
-
organizer:
|
|
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(
|
|
19
|
+
.array(emailAddressSchema)
|
|
20
20
|
.optional()
|
|
21
|
-
.describe("
|
|
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
|
-
//
|
|
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(
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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 {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "caldav-mcp",
|
|
3
|
-
"version": "0.12.
|
|
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": {
|