caldav-mcp 0.2.0 → 0.2.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 +1 -0
- package/dist/index.js +12 -52
- package/dist/tools/create-event.js +29 -0
- package/dist/tools/create-event.test.js +4 -0
- package/dist/tools/delete-event.js +9 -0
- package/dist/tools/list-calendars.js +7 -0
- package/dist/tools/list-events.js +21 -0
- package/package.json +25 -10
package/README.md
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
🗓️ A CalDAV Model Context Protocol (MCP) server to expose calendar operations as tools for AI assistants.
|
|
6
6
|
|
|
7
7
|
[](https://choosealicense.com/licenses/mit/)
|
|
8
|
+
[](https://github.com/prettier/prettier)
|
|
8
9
|
[](https://modelcontextprotocol.io)
|
|
9
10
|
[](https://github.com/semantic-release/semantic-release)
|
|
10
11
|
|
package/dist/index.js
CHANGED
|
@@ -1,26 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
2
|
+
import "dotenv/config";
|
|
3
3
|
import { CalDAVClient } from "ts-caldav";
|
|
4
4
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
5
5
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
6
|
-
import {
|
|
6
|
+
import { registerCreateEvent } from "./tools/create-event.js";
|
|
7
|
+
import { registerDeleteEvent } from "./tools/delete-event.js";
|
|
8
|
+
import { registerListCalendars } from "./tools/list-calendars.js";
|
|
9
|
+
import { registerListEvents } from "./tools/list-events.js";
|
|
7
10
|
const server = new McpServer({
|
|
8
11
|
name: "caldav-mcp",
|
|
9
|
-
version: "0.1.0"
|
|
10
|
-
});
|
|
11
|
-
const recurrenceRuleSchema = z.object({
|
|
12
|
-
freq: z.enum(["DAILY", "WEEKLY", "MONTHLY", "YEARLY"]).optional(),
|
|
13
|
-
interval: z.number().optional(),
|
|
14
|
-
count: z.number().optional(),
|
|
15
|
-
until: z.string().datetime().optional(), // ISO 8601 string
|
|
16
|
-
byday: z.array(z.string()).optional(), // e.g. ["MO", "TU"]
|
|
17
|
-
bymonthday: z.array(z.number()).optional(),
|
|
18
|
-
bymonth: z.array(z.number()).optional(),
|
|
19
|
-
});
|
|
20
|
-
const dateString = z
|
|
21
|
-
.string()
|
|
22
|
-
.refine((val) => !isNaN(Date.parse(val)), {
|
|
23
|
-
message: "Invalid date string",
|
|
12
|
+
version: "0.1.0",
|
|
24
13
|
});
|
|
25
14
|
async function main() {
|
|
26
15
|
const client = await CalDAVClient.create({
|
|
@@ -28,42 +17,13 @@ async function main() {
|
|
|
28
17
|
auth: {
|
|
29
18
|
type: "basic",
|
|
30
19
|
username: process.env.CALDAV_USERNAME || "",
|
|
31
|
-
password: process.env.CALDAV_PASSWORD || ""
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
const calendars = await client.getCalendars();
|
|
35
|
-
server.tool("create-event", "Creates an event in the calendar specified by its URL", { summary: z.string(), start: z.string().datetime(), end: z.string().datetime(), calendarUrl: z.string(), recurrenceRule: recurrenceRuleSchema.optional() }, async ({ calendarUrl, summary, start, end, recurrenceRule }) => {
|
|
36
|
-
const event = await client.createEvent(calendarUrl, {
|
|
37
|
-
summary: summary,
|
|
38
|
-
start: new Date(start),
|
|
39
|
-
end: new Date(end),
|
|
40
|
-
recurrenceRule: recurrenceRule,
|
|
41
|
-
});
|
|
42
|
-
return {
|
|
43
|
-
content: [{ type: "text", text: event.uid }]
|
|
44
|
-
};
|
|
45
|
-
});
|
|
46
|
-
server.tool("list-events", "List all events between start and end date in the calendar specified by its URL", { start: dateString, end: dateString, calendarUrl: z.string() }, async ({ calendarUrl, start, end }) => {
|
|
47
|
-
const options = {
|
|
48
|
-
start: new Date(start),
|
|
49
|
-
end: new Date(end),
|
|
50
|
-
};
|
|
51
|
-
const allEvents = await client.getEvents(calendarUrl, options);
|
|
52
|
-
const data = allEvents.map(e => ({ summary: e.summary, start: e.start, end: e.end }));
|
|
53
|
-
return {
|
|
54
|
-
content: [{ type: "text", text: JSON.stringify(data) }]
|
|
55
|
-
};
|
|
56
|
-
});
|
|
57
|
-
server.tool("delete-event", "Deletes an event in the calendar specified by its URL", { uid: z.string(), calendarUrl: z.string() }, async ({ uid, calendarUrl }) => {
|
|
58
|
-
await client.deleteEvent(calendarUrl, uid);
|
|
59
|
-
return {
|
|
60
|
-
content: [{ type: "text", text: "Event deleted" }]
|
|
61
|
-
};
|
|
62
|
-
});
|
|
63
|
-
server.tool("list-calendars", "List all calendars returning both name and URL", {}, async () => {
|
|
64
|
-
const data = calendars.map(c => ({ name: c.displayName, url: c.url }));
|
|
65
|
-
return { content: [{ type: "text", text: JSON.stringify(data) }] };
|
|
20
|
+
password: process.env.CALDAV_PASSWORD || "",
|
|
21
|
+
},
|
|
66
22
|
});
|
|
23
|
+
registerCreateEvent(client, server);
|
|
24
|
+
registerListEvents(client, server);
|
|
25
|
+
registerDeleteEvent(client, server);
|
|
26
|
+
await registerListCalendars(client, server);
|
|
67
27
|
// Start receiving messages on stdin and sending messages on stdout
|
|
68
28
|
const transport = new StdioServerTransport();
|
|
69
29
|
await server.connect(transport);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const recurrenceRuleSchema = z.object({
|
|
3
|
+
freq: z.enum(["DAILY", "WEEKLY", "MONTHLY", "YEARLY"]).optional(),
|
|
4
|
+
interval: z.number().optional(),
|
|
5
|
+
count: z.number().optional(),
|
|
6
|
+
until: z.string().datetime().optional(), // ISO 8601 string
|
|
7
|
+
byday: z.array(z.string()).optional(), // e.g. ["MO", "TU"]
|
|
8
|
+
bymonthday: z.array(z.number()).optional(),
|
|
9
|
+
bymonth: z.array(z.number()).optional(),
|
|
10
|
+
});
|
|
11
|
+
export function registerCreateEvent(client, server) {
|
|
12
|
+
server.tool("create-event", "Creates an event in the calendar specified by its URL", {
|
|
13
|
+
summary: z.string(),
|
|
14
|
+
start: z.string().datetime(),
|
|
15
|
+
end: z.string().datetime(),
|
|
16
|
+
calendarUrl: z.string(),
|
|
17
|
+
recurrenceRule: recurrenceRuleSchema.optional(),
|
|
18
|
+
}, async ({ calendarUrl, summary, start, end, recurrenceRule }) => {
|
|
19
|
+
const event = await client.createEvent(calendarUrl, {
|
|
20
|
+
summary: summary,
|
|
21
|
+
start: new Date(start),
|
|
22
|
+
end: new Date(end),
|
|
23
|
+
recurrenceRule: recurrenceRule,
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
content: [{ type: "text", text: event.uid }],
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export function registerDeleteEvent(client, server) {
|
|
3
|
+
server.tool("delete-event", "Deletes an event in the calendar specified by its URL", { uid: z.string(), calendarUrl: z.string() }, async ({ uid, calendarUrl }) => {
|
|
4
|
+
await client.deleteEvent(calendarUrl, uid);
|
|
5
|
+
return {
|
|
6
|
+
content: [{ type: "text", text: "Event deleted" }],
|
|
7
|
+
};
|
|
8
|
+
});
|
|
9
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export async function registerListCalendars(client, server) {
|
|
2
|
+
const calendars = await client.getCalendars();
|
|
3
|
+
server.tool("list-calendars", "List all calendars returning both name and URL", {}, async () => {
|
|
4
|
+
const data = calendars.map((c) => ({ name: c.displayName, url: c.url }));
|
|
5
|
+
return { content: [{ type: "text", text: JSON.stringify(data) }] };
|
|
6
|
+
});
|
|
7
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const dateString = z.string().refine((val) => !isNaN(Date.parse(val)), {
|
|
3
|
+
message: "Invalid date string",
|
|
4
|
+
});
|
|
5
|
+
export function registerListEvents(client, server) {
|
|
6
|
+
server.tool("list-events", "List all events between start and end date in the calendar specified by its URL", { start: dateString, end: dateString, calendarUrl: z.string() }, async ({ calendarUrl, start, end }) => {
|
|
7
|
+
const options = {
|
|
8
|
+
start: new Date(start),
|
|
9
|
+
end: new Date(end),
|
|
10
|
+
};
|
|
11
|
+
const allEvents = await client.getEvents(calendarUrl, options);
|
|
12
|
+
const data = allEvents.map((e) => ({
|
|
13
|
+
summary: e.summary,
|
|
14
|
+
start: e.start,
|
|
15
|
+
end: e.end,
|
|
16
|
+
}));
|
|
17
|
+
return {
|
|
18
|
+
content: [{ type: "text", text: JSON.stringify(data) }],
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "caldav-mcp",
|
|
3
3
|
"description": "A CalDAV client using Model Context Protocol (MCP) to expose calendar operations as tools for AI assistants.",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.1",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
@@ -12,11 +12,15 @@
|
|
|
12
12
|
],
|
|
13
13
|
"scripts": {
|
|
14
14
|
"build": "tsc && shx chmod +x dist/*.js",
|
|
15
|
-
"prepare": "npm run build",
|
|
16
|
-
"test": "
|
|
15
|
+
"prepare": "npm run build && husky",
|
|
16
|
+
"test": "vitest run",
|
|
17
|
+
"test:watch": "vitest",
|
|
17
18
|
"lint": "eslint src/",
|
|
19
|
+
"lint:fix": "eslint src/ --fix",
|
|
18
20
|
"watch": "tsc --watch",
|
|
19
|
-
"semantic-release": "semantic-release"
|
|
21
|
+
"semantic-release": "semantic-release",
|
|
22
|
+
"format": "prettier --write src/.",
|
|
23
|
+
"format:check": "prettier --check src/."
|
|
20
24
|
},
|
|
21
25
|
"repository": {
|
|
22
26
|
"type": "git",
|
|
@@ -29,20 +33,31 @@
|
|
|
29
33
|
"author": "Dominik Grusemann",
|
|
30
34
|
"license": "MIT",
|
|
31
35
|
"dependencies": {
|
|
32
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
36
|
+
"@modelcontextprotocol/sdk": "^1.13.0",
|
|
33
37
|
"dotenv": "^16.5.0",
|
|
34
|
-
"ts-caldav": "^0.
|
|
38
|
+
"ts-caldav": "^0.2.0"
|
|
35
39
|
},
|
|
36
40
|
"devDependencies": {
|
|
37
|
-
"@eslint/js": "^9.
|
|
41
|
+
"@eslint/js": "^9.29.0",
|
|
38
42
|
"@semantic-release/changelog": "^6.0.3",
|
|
39
43
|
"@semantic-release/git": "^10.0.1",
|
|
40
44
|
"@semantic-release/github": "^11.0.3",
|
|
41
|
-
"@types/node": "^24.0.
|
|
42
|
-
"eslint": "^9.
|
|
45
|
+
"@types/node": "^24.0.3",
|
|
46
|
+
"eslint": "^9.29.0",
|
|
47
|
+
"eslint-config-prettier": "^10.1.5",
|
|
48
|
+
"husky": "^9.1.7",
|
|
49
|
+
"lint-staged": "^16.1.2",
|
|
50
|
+
"prettier": "3.5.3",
|
|
43
51
|
"semantic-release": "^24.2.5",
|
|
44
52
|
"shx": "^0.4.0",
|
|
45
53
|
"typescript": "^5.8.3",
|
|
46
|
-
"typescript-eslint": "^8.34.
|
|
54
|
+
"typescript-eslint": "^8.34.1",
|
|
55
|
+
"vitest": "^3.0.0"
|
|
56
|
+
},
|
|
57
|
+
"lint-staged": {
|
|
58
|
+
"src/**/*.{ts,tsx,js,jsx}": [
|
|
59
|
+
"eslint --fix",
|
|
60
|
+
"prettier --write"
|
|
61
|
+
]
|
|
47
62
|
}
|
|
48
63
|
}
|