caldav-mcp 0.10.2 → 0.10.3
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 +1 -1
- package/dist/tools/caldav-href.js +40 -0
- package/dist/tools/complete-todo.js +3 -2
- package/dist/tools/create-event.js +3 -1
- package/dist/tools/create-todo.js +3 -1
- package/dist/tools/delete-event.js +3 -2
- package/dist/tools/delete-todo.js +3 -2
- package/dist/tools/list-calendars.js +8 -2
- package/dist/tools/list-events.js +3 -1
- package/dist/tools/list-todos.js +2 -1
- package/dist/tools/update-event.js +3 -2
- package/dist/tools/update-todo.js +3 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -73,7 +73,7 @@ node dist/index.js
|
|
|
73
73
|
<!-- TOOLS:START - generated by scripts/gen-tool-docs.ts -->
|
|
74
74
|
### list-calendars
|
|
75
75
|
|
|
76
|
-
List all calendars returning both name and URL
|
|
76
|
+
List all calendars returning both name and absolute URL. Pass a calendar's `url` unchanged as `calendarUrl` to the other tools.
|
|
77
77
|
|
|
78
78
|
Parameters: none
|
|
79
79
|
|
|
@@ -7,3 +7,43 @@ export function hrefFor(calendarUrl, uid) {
|
|
|
7
7
|
const base = calendarUrl.endsWith("/") ? calendarUrl : `${calendarUrl}/`;
|
|
8
8
|
return `${base}${uid}.ics`;
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Resolves a server-relative calendar href (as ts-caldav returns it) against
|
|
12
|
+
* the configured base URL, so agents get a URL they can pass back verbatim
|
|
13
|
+
* instead of guessing how to prefix it. Hrefs that are already absolute are
|
|
14
|
+
* left as they are. Credentials in the base URL are dropped: the result is
|
|
15
|
+
* shown to the LLM.
|
|
16
|
+
*/
|
|
17
|
+
export function toAbsoluteUrl(href, baseUrl) {
|
|
18
|
+
if (!href || !baseUrl)
|
|
19
|
+
return href;
|
|
20
|
+
try {
|
|
21
|
+
const url = new URL(href, baseUrl);
|
|
22
|
+
url.username = "";
|
|
23
|
+
url.password = "";
|
|
24
|
+
return url.toString();
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return href;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Inverse of `toAbsoluteUrl`: turns an absolute calendar URL on the configured
|
|
32
|
+
* server back into the server-relative path. ts-caldav writes object hrefs
|
|
33
|
+
* into calendar-multiget bodies verbatim, and not every server accepts
|
|
34
|
+
* absolute URLs there, so tools hand it paths only. Relative input and URLs
|
|
35
|
+
* on another origin pass through unchanged.
|
|
36
|
+
*/
|
|
37
|
+
export function toCalendarPath(calendarUrl, baseUrl) {
|
|
38
|
+
if (!baseUrl)
|
|
39
|
+
return calendarUrl;
|
|
40
|
+
try {
|
|
41
|
+
const url = new URL(calendarUrl);
|
|
42
|
+
if (url.origin !== new URL(baseUrl).origin)
|
|
43
|
+
return calendarUrl;
|
|
44
|
+
return `${url.pathname}${url.search}`;
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return calendarUrl;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { hrefFor } from "./caldav-href.js";
|
|
2
|
+
import { hrefFor, toCalendarPath } from "./caldav-href.js";
|
|
3
3
|
export const completeTodoDefinition = {
|
|
4
4
|
name: "complete-todo",
|
|
5
5
|
description: "Marks a task (VTODO) as done. Sets its status to COMPLETED and records the completion time.",
|
|
@@ -16,7 +16,8 @@ export function registerCompleteTodo(client, server) {
|
|
|
16
16
|
description: completeTodoDefinition.description,
|
|
17
17
|
inputSchema: completeTodoDefinition.inputSchema,
|
|
18
18
|
}, async (args) => {
|
|
19
|
-
const { uid
|
|
19
|
+
const { uid } = args;
|
|
20
|
+
const calendarUrl = toCalendarPath(args.calendarUrl, client.baseUrl);
|
|
20
21
|
const href = hrefFor(calendarUrl, uid);
|
|
21
22
|
const [existing] = await client.getTodosByHref(calendarUrl, [href]);
|
|
22
23
|
if (!existing) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { toCalendarPath } from "./caldav-href.js";
|
|
2
3
|
import { recurrenceRuleSchema, toRecurrenceRule, } from "./recurrence-rule.js";
|
|
3
4
|
import { toWholeDayDate } from "./whole-day-date.js";
|
|
4
5
|
export const createEventDefinition = {
|
|
@@ -27,7 +28,8 @@ export function registerCreateEvent(client, server) {
|
|
|
27
28
|
description: createEventDefinition.description,
|
|
28
29
|
inputSchema: createEventDefinition.inputSchema,
|
|
29
30
|
}, async (args) => {
|
|
30
|
-
const {
|
|
31
|
+
const { summary, start, end, wholeDay, description, location, recurrenceRule, } = args;
|
|
32
|
+
const calendarUrl = toCalendarPath(args.calendarUrl, client.baseUrl);
|
|
31
33
|
const event = await client.createEvent(calendarUrl, {
|
|
32
34
|
summary: summary,
|
|
33
35
|
start: wholeDay ? toWholeDayDate(start) : new Date(start),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { toCalendarPath } from "./caldav-href.js";
|
|
2
3
|
import { todoStatusSchema } from "./todo-status.js";
|
|
3
4
|
export const createTodoDefinition = {
|
|
4
5
|
name: "create-todo",
|
|
@@ -29,7 +30,8 @@ export function registerCreateTodo(client, server) {
|
|
|
29
30
|
description: createTodoDefinition.description,
|
|
30
31
|
inputSchema: createTodoDefinition.inputSchema,
|
|
31
32
|
}, async (args) => {
|
|
32
|
-
const {
|
|
33
|
+
const { summary, due, start, description, location, status } = args;
|
|
34
|
+
const calendarUrl = toCalendarPath(args.calendarUrl, client.baseUrl);
|
|
33
35
|
const todo = await client.createTodo(calendarUrl, {
|
|
34
36
|
summary,
|
|
35
37
|
...(due !== undefined && { due: new Date(due) }),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { hrefFor } from "./caldav-href.js";
|
|
2
|
+
import { hrefFor, toCalendarPath } from "./caldav-href.js";
|
|
3
3
|
export const deleteEventDefinition = {
|
|
4
4
|
name: "delete-event",
|
|
5
5
|
description: "Deletes an event in the calendar specified by its URL",
|
|
@@ -16,7 +16,8 @@ export function registerDeleteEvent(client, server) {
|
|
|
16
16
|
description: deleteEventDefinition.description,
|
|
17
17
|
inputSchema: deleteEventDefinition.inputSchema,
|
|
18
18
|
}, async (args) => {
|
|
19
|
-
const { uid
|
|
19
|
+
const { uid } = args;
|
|
20
|
+
const calendarUrl = toCalendarPath(args.calendarUrl, client.baseUrl);
|
|
20
21
|
const etag = await client.getETag(hrefFor(calendarUrl, uid));
|
|
21
22
|
await client.deleteEvent(calendarUrl, uid, etag);
|
|
22
23
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CalDAVError } from "ts-caldav";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { hrefFor } from "./caldav-href.js";
|
|
3
|
+
import { hrefFor, toCalendarPath } from "./caldav-href.js";
|
|
4
4
|
export const deleteTodoDefinition = {
|
|
5
5
|
name: "delete-todo",
|
|
6
6
|
description: "Deletes a task (VTODO) in the calendar specified by its URL",
|
|
@@ -17,7 +17,8 @@ export function registerDeleteTodo(client, server) {
|
|
|
17
17
|
description: deleteTodoDefinition.description,
|
|
18
18
|
inputSchema: deleteTodoDefinition.inputSchema,
|
|
19
19
|
}, async (args) => {
|
|
20
|
-
const { uid
|
|
20
|
+
const { uid } = args;
|
|
21
|
+
const calendarUrl = toCalendarPath(args.calendarUrl, client.baseUrl);
|
|
21
22
|
// Map a missing object onto the same friendly message complete-todo and
|
|
22
23
|
// update-todo raise, so all three todo tools report a missing task the
|
|
23
24
|
// same way. (delete-event still surfaces the raw transport error; the
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
+
import { toAbsoluteUrl } from "./caldav-href.js";
|
|
1
2
|
export const listCalendarsDefinition = {
|
|
2
3
|
name: "list-calendars",
|
|
3
|
-
description: "List all calendars returning both name and URL",
|
|
4
|
+
description: "List all calendars returning both name and absolute URL. Pass a calendar's `url` unchanged as `calendarUrl` to the other tools.",
|
|
4
5
|
inputSchema: {},
|
|
5
6
|
returns: "List of all available calendars",
|
|
6
7
|
};
|
|
7
8
|
export async function registerListCalendars(client, server) {
|
|
8
|
-
|
|
9
|
+
// ts-caldav returns server-relative hrefs; resolve them so agents don't
|
|
10
|
+
// have to guess how to prefix the base URL.
|
|
11
|
+
const calendars = (await client.getCalendars()).map((calendar) => ({
|
|
12
|
+
...calendar,
|
|
13
|
+
url: toAbsoluteUrl(calendar.url, client.baseUrl),
|
|
14
|
+
}));
|
|
9
15
|
server.registerTool(listCalendarsDefinition.name, {
|
|
10
16
|
description: listCalendarsDefinition.description,
|
|
11
17
|
inputSchema: listCalendarsDefinition.inputSchema,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { toCalendarPath } from "./caldav-href.js";
|
|
2
3
|
export const listEventsDefinition = {
|
|
3
4
|
name: "list-events",
|
|
4
5
|
description: "List all events between start and end date in the calendar specified by its URL",
|
|
@@ -24,7 +25,8 @@ export function registerListEvents(client, server) {
|
|
|
24
25
|
description: listEventsDefinition.description,
|
|
25
26
|
inputSchema: listEventsDefinition.inputSchema,
|
|
26
27
|
}, async (args) => {
|
|
27
|
-
const {
|
|
28
|
+
const { start, end } = args;
|
|
29
|
+
const calendarUrl = toCalendarPath(args.calendarUrl, client.baseUrl);
|
|
28
30
|
const options = {
|
|
29
31
|
start: new Date(start),
|
|
30
32
|
end: new Date(end),
|
package/dist/tools/list-todos.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { toCalendarPath } from "./caldav-href.js";
|
|
2
3
|
import { todoStatusSchema } from "./todo-status.js";
|
|
3
4
|
// `OPEN`/`ALL` are filter keywords expressing sets no single status can (a union
|
|
4
5
|
// and "no filter"); the four raw statuses allow an exact-status query. The raw
|
|
@@ -69,7 +70,7 @@ export function registerListTodos(client, server) {
|
|
|
69
70
|
description: listTodosDefinition.description,
|
|
70
71
|
inputSchema: listTodosDefinition.inputSchema,
|
|
71
72
|
}, async (args) => {
|
|
72
|
-
const
|
|
73
|
+
const calendarUrl = toCalendarPath(args.calendarUrl, client.baseUrl);
|
|
73
74
|
const status = args.status ?? "OPEN";
|
|
74
75
|
const limit = args.limit ?? 50;
|
|
75
76
|
const offset = args.offset ?? 0;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { hrefFor } from "./caldav-href.js";
|
|
2
|
+
import { hrefFor, toCalendarPath } from "./caldav-href.js";
|
|
3
3
|
import { recurrenceRuleSchema, toRecurrenceRule, } from "./recurrence-rule.js";
|
|
4
4
|
import { carryOverWholeDayDates, toWholeDayDate } from "./whole-day-date.js";
|
|
5
5
|
export const updateEventDefinition = {
|
|
@@ -28,7 +28,8 @@ export function registerUpdateEvent(client, server) {
|
|
|
28
28
|
description: updateEventDefinition.description,
|
|
29
29
|
inputSchema: updateEventDefinition.inputSchema,
|
|
30
30
|
}, async (args) => {
|
|
31
|
-
const { uid,
|
|
31
|
+
const { uid, summary, start, end, wholeDay, description, location, recurrenceRule, } = args;
|
|
32
|
+
const calendarUrl = toCalendarPath(args.calendarUrl, client.baseUrl);
|
|
32
33
|
const href = hrefFor(calendarUrl, uid);
|
|
33
34
|
const [existing] = await client.getEventsByHref(calendarUrl, [href]);
|
|
34
35
|
if (!existing) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { hrefFor } from "./caldav-href.js";
|
|
2
|
+
import { hrefFor, toCalendarPath } from "./caldav-href.js";
|
|
3
3
|
import { todoStatusSchema } from "./todo-status.js";
|
|
4
4
|
export const updateTodoDefinition = {
|
|
5
5
|
name: "update-todo",
|
|
@@ -23,7 +23,8 @@ export function registerUpdateTodo(client, server) {
|
|
|
23
23
|
description: updateTodoDefinition.description,
|
|
24
24
|
inputSchema: updateTodoDefinition.inputSchema,
|
|
25
25
|
}, async (args) => {
|
|
26
|
-
const { uid,
|
|
26
|
+
const { uid, summary, due, start, description, location, status } = args;
|
|
27
|
+
const calendarUrl = toCalendarPath(args.calendarUrl, client.baseUrl);
|
|
27
28
|
const href = hrefFor(calendarUrl, uid);
|
|
28
29
|
const [existing] = await client.getTodosByHref(calendarUrl, [href]);
|
|
29
30
|
if (!existing) {
|
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.10.
|
|
5
|
+
"version": "0.10.3",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"bin": {
|