caldav-mcp 0.2.0 → 0.2.2

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
@@ -4,7 +4,10 @@
4
4
 
5
5
  🗓️ A CalDAV Model Context Protocol (MCP) server to expose calendar operations as tools for AI assistants.
6
6
 
7
+ [![Release](https://github.com/dominik1001/caldav-mcp/actions/workflows/release.yml/badge.svg)](https://github.com/dominik1001/caldav-mcp/actions/workflows/release.yml)
8
+ [![npm version](https://badge.fury.io/js/caldav-mcp.svg)](https://www.npmjs.com/package/caldav-mcp)
7
9
  [![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://choosealicense.com/licenses/mit/)
10
+ [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
8
11
  [![MCP Compatible](https://img.shields.io/badge/MCP-Compatible-purple.svg)](https://modelcontextprotocol.io)
9
12
  [![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)
10
13
 
@@ -13,8 +16,10 @@
13
16
  ## ✨ Features
14
17
 
15
18
  - Connect to CalDAV servers
16
- - Create calendar events
19
+ - List calendars
17
20
  - List calendar events within a specific timeframe
21
+ - Create calendar events
22
+ - Delete calendar events by UID
18
23
 
19
24
  ## Setup
20
25
 
@@ -37,7 +42,7 @@
37
42
  }
38
43
  ```
39
44
 
40
- ## Usage
45
+ ## Development
41
46
 
42
47
  1. Compile TypeScript to JavaScript:
43
48
  ```bash
@@ -46,7 +51,7 @@ npx tsc
46
51
 
47
52
  2. Run the MCP server:
48
53
  ```bash
49
- node index.js
54
+ node dist/index.js
50
55
  ```
51
56
 
52
57
  ## Available Tools
@@ -70,9 +75,34 @@ Lists events within a specified timeframe.
70
75
  Parameters:
71
76
  - `start`: DateTime string - Start of the timeframe
72
77
  - `end`: DateTime string - End of the timeframe
78
+ - `calendarUrl`: String - URL of the calendar
79
+
80
+ Returns:
81
+ - A list of events that fall within the given timeframe, each containing:
82
+ - `uid`: Unique identifier for the event (required for deletion)
83
+ - `summary`: Event title/summary
84
+ - `start`: Event start time
85
+ - `end`: Event end time
86
+
87
+ ### delete-event
88
+
89
+ Deletes an event from the calendar.
90
+
91
+ Parameters:
92
+ - `uid`: String - Unique identifier of the event to delete (obtained from list-events)
93
+ - `calendarUrl`: String - URL of the calendar
94
+
95
+ Returns:
96
+ - Confirmation message when the event is successfully deleted
97
+
98
+ ### list-calendars
99
+
100
+ Lists all available calendars.
101
+
102
+ Parameters: none
73
103
 
74
104
  Returns:
75
- - A list of event summaries that fall within the given timeframe
105
+ - List of all available calendars
76
106
 
77
107
  ## License
78
108
 
package/dist/index.js CHANGED
@@ -1,26 +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"
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,32 @@
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.registerTool("create-event", {
13
+ description: "Creates an event in the calendar specified by its URL",
14
+ inputSchema: {
15
+ summary: z.string(),
16
+ start: z.string().datetime(),
17
+ end: z.string().datetime(),
18
+ calendarUrl: z.string(),
19
+ recurrenceRule: recurrenceRuleSchema.optional(),
20
+ },
21
+ }, async ({ calendarUrl, summary, start, end, recurrenceRule }) => {
22
+ const event = await client.createEvent(calendarUrl, {
23
+ summary: summary,
24
+ start: new Date(start),
25
+ end: new Date(end),
26
+ recurrenceRule: recurrenceRule,
27
+ });
28
+ return {
29
+ content: [{ type: "text", text: event.uid }],
30
+ };
31
+ });
32
+ }
@@ -0,0 +1,12 @@
1
+ import { z } from "zod";
2
+ export function registerDeleteEvent(client, server) {
3
+ server.registerTool("delete-event", {
4
+ description: "Deletes an event in the calendar specified by its URL",
5
+ inputSchema: { uid: z.string(), calendarUrl: z.string() },
6
+ }, async ({ uid, calendarUrl }) => {
7
+ await client.deleteEvent(calendarUrl, uid);
8
+ return {
9
+ content: [{ type: "text", text: "Event deleted" }],
10
+ };
11
+ });
12
+ }
@@ -0,0 +1,9 @@
1
+ export async function registerListCalendars(client, server) {
2
+ const calendars = await client.getCalendars();
3
+ server.registerTool("list-calendars", {
4
+ description: "List all calendars returning both name and URL",
5
+ inputSchema: {},
6
+ }, async () => {
7
+ return { content: [{ type: "text", text: JSON.stringify(calendars) }] };
8
+ });
9
+ }
@@ -0,0 +1,29 @@
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.registerTool("list-events", {
7
+ description: "List all events between start and end date in the calendar specified by its URL",
8
+ inputSchema: {
9
+ start: dateString,
10
+ end: dateString,
11
+ calendarUrl: z.string(),
12
+ },
13
+ }, async ({ calendarUrl, start, end }) => {
14
+ const options = {
15
+ start: new Date(start),
16
+ end: new Date(end),
17
+ };
18
+ const allEvents = await client.getEvents(calendarUrl, options);
19
+ const data = allEvents.map((e) => ({
20
+ uid: e.uid,
21
+ summary: e.summary,
22
+ start: e.start,
23
+ end: e.end,
24
+ }));
25
+ return {
26
+ content: [{ type: "text", text: JSON.stringify(data) }],
27
+ };
28
+ });
29
+ }
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.0",
4
+ "version": "0.2.2",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
7
7
  "bin": {
@@ -12,11 +12,16 @@
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 0",
15
+ "prepare": "npm run build && husky",
16
+ "test": "vitest run",
17
+ "test:watch": "vitest",
18
+ "test:coverage": "vitest run --coverage",
17
19
  "lint": "eslint src/",
20
+ "lint:fix": "eslint src/ --fix",
18
21
  "watch": "tsc --watch",
19
- "semantic-release": "semantic-release"
22
+ "semantic-release": "semantic-release",
23
+ "format": "prettier --write src/.",
24
+ "format:check": "prettier --check src/."
20
25
  },
21
26
  "repository": {
22
27
  "type": "git",
@@ -28,21 +33,38 @@
28
33
  "homepage": "https://github.com/dominik1001/caldav-mcp#readme",
29
34
  "author": "Dominik Grusemann",
30
35
  "license": "MIT",
36
+ "engines": {
37
+ "node": ">=18.0.0",
38
+ "npm": ">=9.0.0"
39
+ },
31
40
  "dependencies": {
32
- "@modelcontextprotocol/sdk": "^1.12.1",
41
+ "@modelcontextprotocol/sdk": "^1.13.0",
33
42
  "dotenv": "^16.5.0",
34
- "ts-caldav": "^0.1.7"
43
+ "ts-caldav": "^0.2.7"
35
44
  },
36
45
  "devDependencies": {
37
- "@eslint/js": "^9.28.0",
46
+ "@eslint/js": "^9.29.0",
38
47
  "@semantic-release/changelog": "^6.0.3",
39
48
  "@semantic-release/git": "^10.0.1",
40
49
  "@semantic-release/github": "^11.0.3",
41
- "@types/node": "^24.0.1",
42
- "eslint": "^9.28.0",
43
- "semantic-release": "^24.2.5",
50
+ "@semantic-release/npm": "^13.1.4",
51
+ "@types/node": "^24.0.3",
52
+ "@vitest/coverage-v8": "^3.2.4",
53
+ "eslint": "^9.29.0",
54
+ "eslint-config-prettier": "^10.1.5",
55
+ "husky": "^9.1.7",
56
+ "lint-staged": "^16.1.2",
57
+ "prettier": "3.5.3",
58
+ "semantic-release": "^25.0.3",
44
59
  "shx": "^0.4.0",
45
60
  "typescript": "^5.8.3",
46
- "typescript-eslint": "^8.34.0"
61
+ "typescript-eslint": "^8.34.1",
62
+ "vitest": "^3.2.4"
63
+ },
64
+ "lint-staged": {
65
+ "src/**/*.{ts,tsx,js,jsx}": [
66
+ "eslint --fix",
67
+ "prettier --write"
68
+ ]
47
69
  }
48
70
  }