caldav-mcp 0.1.2 → 0.2.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 +26 -11
- package/dist/index.js +36 -15
- package/package.json +22 -9
package/README.md
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
# caldav-mcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<div align="center">
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
🗓️ A CalDAV Model Context Protocol (MCP) server to expose calendar operations as tools for AI assistants.
|
|
6
|
+
|
|
7
|
+
[](https://choosealicense.com/licenses/mit/)
|
|
8
|
+
[](https://modelcontextprotocol.io)
|
|
9
|
+
[](https://github.com/semantic-release/semantic-release)
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
## ✨ Features
|
|
6
14
|
|
|
7
15
|
- Connect to CalDAV servers
|
|
8
16
|
- Create calendar events
|
|
@@ -10,16 +18,23 @@ A CalDAV client using Model Context Protocol (MCP) to expose calendar operations
|
|
|
10
18
|
|
|
11
19
|
## Setup
|
|
12
20
|
|
|
13
|
-
1. Install dependencies:
|
|
14
|
-
```bash
|
|
15
|
-
npm install
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
2. Create a `.env` file in the project root with your CalDAV credentials:
|
|
19
21
|
```
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
{
|
|
23
|
+
"mcpServers": {
|
|
24
|
+
...,
|
|
25
|
+
"calendar": {
|
|
26
|
+
"command": "npx",
|
|
27
|
+
"args": [
|
|
28
|
+
"caldav-mcp"
|
|
29
|
+
],
|
|
30
|
+
"env": {
|
|
31
|
+
"CALDAV_BASE_URL": "<CalDAV server URL>",
|
|
32
|
+
"CALDAV_USERNAME": "<CalDAV username>",
|
|
33
|
+
"CALDAV_PASSWORD": "<CalDAV password>"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
23
38
|
```
|
|
24
39
|
|
|
25
40
|
## Usage
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
import 'dotenv/config';
|
|
2
3
|
import { CalDAVClient } from "ts-caldav";
|
|
3
4
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
@@ -7,6 +8,20 @@ const server = new McpServer({
|
|
|
7
8
|
name: "caldav-mcp",
|
|
8
9
|
version: "0.1.0"
|
|
9
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",
|
|
24
|
+
});
|
|
10
25
|
async function main() {
|
|
11
26
|
const client = await CalDAVClient.create({
|
|
12
27
|
baseUrl: process.env.CALDAV_BASE_URL || "",
|
|
@@ -17,32 +32,38 @@ async function main() {
|
|
|
17
32
|
}
|
|
18
33
|
});
|
|
19
34
|
const calendars = await client.getCalendars();
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const event = await client.createEvent(calendar.url, {
|
|
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, {
|
|
23
37
|
summary: summary,
|
|
24
38
|
start: new Date(start),
|
|
25
39
|
end: new Date(end),
|
|
40
|
+
recurrenceRule: recurrenceRule,
|
|
26
41
|
});
|
|
27
42
|
return {
|
|
28
43
|
content: [{ type: "text", text: event.uid }]
|
|
29
44
|
};
|
|
30
45
|
});
|
|
31
|
-
server.tool("list-events", { start:
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
const eventEnd = new Date(event.end);
|
|
39
|
-
// Event starts before the end time and ends after the start time
|
|
40
|
-
return eventStart <= endDate && eventEnd >= startDate;
|
|
41
|
-
});
|
|
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 }));
|
|
42
53
|
return {
|
|
43
|
-
content: [{ type: "text", text:
|
|
54
|
+
content: [{ type: "text", text: JSON.stringify(data) }]
|
|
44
55
|
};
|
|
45
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) }] };
|
|
66
|
+
});
|
|
46
67
|
// Start receiving messages on stdin and sending messages on stdout
|
|
47
68
|
const transport = new StdioServerTransport();
|
|
48
69
|
await server.connect(transport);
|
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.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
@@ -13,23 +13,36 @@
|
|
|
13
13
|
"scripts": {
|
|
14
14
|
"build": "tsc && shx chmod +x dist/*.js",
|
|
15
15
|
"prepare": "npm run build",
|
|
16
|
-
"test": "echo \"Error: no test specified\" && exit
|
|
16
|
+
"test": "echo \"Error: no test specified\" && exit 0",
|
|
17
17
|
"lint": "eslint src/",
|
|
18
|
-
"watch": "tsc --watch"
|
|
18
|
+
"watch": "tsc --watch",
|
|
19
|
+
"semantic-release": "semantic-release"
|
|
19
20
|
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/dominik1001/caldav-mcp.git"
|
|
24
|
+
},
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/dominik1001/caldav-mcp/issues"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/dominik1001/caldav-mcp#readme",
|
|
20
29
|
"author": "Dominik Grusemann",
|
|
21
30
|
"license": "MIT",
|
|
22
31
|
"dependencies": {
|
|
23
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
32
|
+
"@modelcontextprotocol/sdk": "^1.12.1",
|
|
24
33
|
"dotenv": "^16.5.0",
|
|
25
|
-
"ts-caldav": "^0.1.
|
|
34
|
+
"ts-caldav": "^0.1.7"
|
|
26
35
|
},
|
|
27
36
|
"devDependencies": {
|
|
28
|
-
"@eslint/js": "^9.
|
|
29
|
-
"@
|
|
30
|
-
"
|
|
37
|
+
"@eslint/js": "^9.28.0",
|
|
38
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
39
|
+
"@semantic-release/git": "^10.0.1",
|
|
40
|
+
"@semantic-release/github": "^11.0.3",
|
|
41
|
+
"@types/node": "^24.0.1",
|
|
42
|
+
"eslint": "^9.28.0",
|
|
43
|
+
"semantic-release": "^24.2.5",
|
|
31
44
|
"shx": "^0.4.0",
|
|
32
45
|
"typescript": "^5.8.3",
|
|
33
|
-
"typescript-eslint": "^8.
|
|
46
|
+
"typescript-eslint": "^8.34.0"
|
|
34
47
|
}
|
|
35
48
|
}
|