caldav-mcp 0.1.3 → 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 CHANGED
@@ -1,8 +1,17 @@
1
1
  # caldav-mcp
2
2
 
3
- A CalDAV client using Model Context Protocol (MCP) to expose calendar operations as tools for AI assistants.
3
+ <div align="center">
4
4
 
5
- ## Features
5
+ 🗓️ A CalDAV Model Context Protocol (MCP) server to expose calendar operations as tools for AI assistants.
6
+
7
+ [![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://choosealicense.com/licenses/mit/)
8
+ [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
9
+ [![MCP Compatible](https://img.shields.io/badge/MCP-Compatible-purple.svg)](https://modelcontextprotocol.io)
10
+ [![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)
11
+
12
+ </div>
13
+
14
+ ## ✨ Features
6
15
 
7
16
  - Connect to CalDAV servers
8
17
  - Create calendar events
@@ -10,16 +19,23 @@ A CalDAV client using Model Context Protocol (MCP) to expose calendar operations
10
19
 
11
20
  ## Setup
12
21
 
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
22
  ```
20
- CALDAV_BASE_URL=<CalDAV server URL>
21
- CALDAV_USERNAME=<CalDAV username>
22
- CALDAV_PASSWORD=<CalDAV password>
23
+ {
24
+ "mcpServers": {
25
+ ...,
26
+ "calendar": {
27
+ "command": "npx",
28
+ "args": [
29
+ "caldav-mcp"
30
+ ],
31
+ "env": {
32
+ "CALDAV_BASE_URL": "<CalDAV server URL>",
33
+ "CALDAV_USERNAME": "<CalDAV username>",
34
+ "CALDAV_PASSWORD": "<CalDAV password>"
35
+ }
36
+ }
37
+ }
38
+ }
23
39
  ```
24
40
 
25
41
  ## Usage
package/dist/index.js CHANGED
@@ -1,12 +1,15 @@
1
1
  #!/usr/bin/env node
2
- import 'dotenv/config';
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 { z } from "zod";
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"
12
+ version: "0.1.0",
10
13
  });
11
14
  async function main() {
12
15
  const client = await CalDAVClient.create({
@@ -14,36 +17,13 @@ async function main() {
14
17
  auth: {
15
18
  type: "basic",
16
19
  username: process.env.CALDAV_USERNAME || "",
17
- password: process.env.CALDAV_PASSWORD || ""
18
- }
19
- });
20
- const calendars = await client.getCalendars();
21
- const calendar = calendars[0];
22
- server.tool("create-event", { summary: z.string(), start: z.string().datetime(), end: z.string().datetime() }, async ({ summary, start, end }) => {
23
- const event = await client.createEvent(calendar.url, {
24
- summary: summary,
25
- start: new Date(start),
26
- end: new Date(end),
27
- });
28
- return {
29
- content: [{ type: "text", text: event.uid }]
30
- };
31
- });
32
- server.tool("list-events", { start: z.string().datetime(), end: z.string().datetime() }, async ({ start, end }) => {
33
- const allEvents = await client.getEvents(calendar.url);
34
- // Filter events that fall within the specified time range
35
- const startDate = new Date(start);
36
- const endDate = new Date(end);
37
- const filteredEvents = allEvents.filter(event => {
38
- const eventStart = new Date(event.start);
39
- const eventEnd = new Date(event.end);
40
- // Event starts before the end time and ends after the start time
41
- return eventStart <= endDate && eventEnd >= startDate;
42
- });
43
- return {
44
- content: [{ type: "text", text: filteredEvents.map(e => `${e.summary}\nStart: ${e.start}\nEnd: ${e.end}`).join("\n") }]
45
- };
20
+ password: process.env.CALDAV_PASSWORD || "",
21
+ },
46
22
  });
23
+ registerCreateEvent(client, server);
24
+ registerListEvents(client, server);
25
+ registerDeleteEvent(client, server);
26
+ await registerListCalendars(client, server);
47
27
  // Start receiving messages on stdin and sending messages on stdout
48
28
  const transport = new StdioServerTransport();
49
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,4 @@
1
+ import { describe, test } from "vitest";
2
+ describe("registerCreateEvent", () => {
3
+ test("to be implemented", () => { });
4
+ });
@@ -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.1.3",
4
+ "version": "0.2.1",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
7
7
  "bin": {
@@ -12,24 +12,52 @@
12
12
  ],
13
13
  "scripts": {
14
14
  "build": "tsc && shx chmod +x dist/*.js",
15
- "prepare": "npm run build",
16
- "test": "echo \"Error: no test specified\" && exit 1",
15
+ "prepare": "npm run build && husky",
16
+ "test": "vitest run",
17
+ "test:watch": "vitest",
17
18
  "lint": "eslint src/",
18
- "watch": "tsc --watch"
19
+ "lint:fix": "eslint src/ --fix",
20
+ "watch": "tsc --watch",
21
+ "semantic-release": "semantic-release",
22
+ "format": "prettier --write src/.",
23
+ "format:check": "prettier --check src/."
19
24
  },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "https://github.com/dominik1001/caldav-mcp.git"
28
+ },
29
+ "bugs": {
30
+ "url": "https://github.com/dominik1001/caldav-mcp/issues"
31
+ },
32
+ "homepage": "https://github.com/dominik1001/caldav-mcp#readme",
20
33
  "author": "Dominik Grusemann",
21
34
  "license": "MIT",
22
35
  "dependencies": {
23
- "@modelcontextprotocol/sdk": "^1.11.3",
36
+ "@modelcontextprotocol/sdk": "^1.13.0",
24
37
  "dotenv": "^16.5.0",
25
- "ts-caldav": "^0.1.3"
38
+ "ts-caldav": "^0.2.0"
26
39
  },
27
40
  "devDependencies": {
28
- "@eslint/js": "^9.27.0",
29
- "@types/node": "^22.15.18",
30
- "eslint": "^9.27.0",
41
+ "@eslint/js": "^9.29.0",
42
+ "@semantic-release/changelog": "^6.0.3",
43
+ "@semantic-release/git": "^10.0.1",
44
+ "@semantic-release/github": "^11.0.3",
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",
51
+ "semantic-release": "^24.2.5",
31
52
  "shx": "^0.4.0",
32
53
  "typescript": "^5.8.3",
33
- "typescript-eslint": "^8.32.1"
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
+ ]
34
62
  }
35
63
  }