Skip to main content
Glama
README.md
# mcp-twake-dav

[![npm version](https://img.shields.io/npm/v/mcp-twake-dav)](https://www.npmjs.com/package/mcp-twake-dav)
[![CI](https://github.com/linagora/mcp-twake-dav/actions/workflows/ci.yml/badge.svg)](https://github.com/linagora/mcp-twake-dav/actions/workflows/ci.yml)
[![License: AGPL-3.0](https://img.shields.io/badge/License-AGPL--3.0-blue.svg)](LICENSE)
[![Node.js >= 20.3](https://img.shields.io/badge/node-%3E%3D20.3-brightgreen.svg)](https://nodejs.org/)

**Give your AI assistant secure access to Twake Calendar and your contacts, in the [Twake.ai](https://twake.ai) Digital Workplace.**

![Twake Calendar](assets/twake-calendar-screenshot.png)

## What is it?

`mcp-twake-dav` is a [Model Context Protocol](https://modelcontextprotocol.io) (MCP) server. MCP is the open standard that lets AI assistants (Claude Desktop, Claude Code, Hermes Agent, Cursor, VS Code and many others) use external tools. This server exposes your **calendars** and **address books** to the assistant as **21 tools**: agenda, availability, events, reminders, invitations and contacts.

It speaks the open standards **CalDAV** ([RFC 4791](https://www.rfc-editor.org/rfc/rfc4791)), **CardDAV** ([RFC 6352](https://www.rfc-editor.org/rfc/rfc6352)) and CalDAV scheduling ([RFC 6638](https://www.rfc-editor.org/rfc/rfc6638)). It is built for Twake Calendar and works with other SabreDAV-compatible servers (Nextcloud, SOGo, DAViCal, ownCloud…).

## Part of Twake.ai

[Twake.ai](https://twake.ai) is the truly open source and sovereign Digital Workplace developed by [LINAGORA](https://linagora.com): Twake Mail, Twake Calendar, Twake Drive, Twake Chat, Twake Space and Twake Visio with a single account, hosted in France or on your own infrastructure.

Five open source MCP servers connect AI assistants to the whole workplace:

| MCP server | Twake.ai service | Protocol |
|---|---|---|
| [mcp-twake-mail](https://github.com/linagora/mcp-twake-mail) | Twake Mail | JMAP |
| **mcp-twake-dav** (this project) | Twake Calendar and contacts | CalDAV / CardDAV |
| [mcp-twake-drive](https://github.com/linagora/mcp-twake-drive) | Twake Drive | cozy-stack API |
| [mcp-twake-chat](https://github.com/linagora/mcp-twake-chat) | Twake Chat | Matrix |
| [mcp-twake-space](https://github.com/linagora/mcp-twake-space) | Twake Space (team spaces) | Twake Space API |
| [mcp-twake-project](https://github.com/linagora/mcp-twake-project) | Twake Project (projects, boards, tasks) | Twake Project API |

Used together, they let one assistant prepare a meeting from the invitation, the related email thread, the chat discussion and the documents in the drive, without your data leaving your servers.

## What it brings

- **Your day at a glance**: "What's on my agenda today? Where is my 3 pm meeting?"
- **Finding a slot**: "When am I free for one hour with Marie next week?" Busy periods come from the events themselves; all-day events (holidays, trade shows, days off) are listed apart instead of blocking whole days.
- **Scheduling in natural language**: "Book a project review on Tuesday at 10 with Pierre and Marie" (dates like "next Monday" or "in two weeks" are understood).
- **Reminders and invitations**: add or remove reminders, list pending invitations and answer them.
- **Contacts**: find an email address or a phone number, create and update contact cards.
- **Your calendars, not your colleagues'**: `list_calendars` groups the calendars by access rights (yours, shared with write access, read-only) and the query tools take a group, so an assistant can read only the calendars you own with `calendar: "mine"`, or by default with `DAV_DEFAULT_CALENDAR=mine` (see [Your calendars and the ones shared with you](#your-calendars-and-the-ones-shared-with-you)).
- **One approval for a series of writes**: before several writes (several events, several contacts), the assistant can ask you once for the exact list with `approve_batch`. Each listed call then runs without another question, once, within 15 minutes, in the session that approved it; anything else, or anything changed since, asks as usual (see [Approving a series of writes at once](#approving-a-series-of-writes-at-once)).
- **From the command line**: `npx mcp-twake-dav call <tool>` and `npx mcp-twake-dav tools` run every tool from a terminal or a script, with the server's configuration. A write you type in a terminal is approved without a question (`--i` asks first); a write started by an agent is refused, since agents write through their MCP tools, which ask you; without a terminal (cron), a write needs `--yes --as <name>`, for a name you allowed once in a terminal (see [From the command line](#from-the-command-line)).
- **Sovereignty**: the server runs next to your assistant and talks directly to your calendar server. Pair it with a self-hosted or European AI model to keep the whole chain under your control.

## Features

### 21 MCP tools

| Category | Tools |
|---|---|
| Calendar, read | `get_next_event`, `get_todays_schedule`, `get_events_in_range`, `search_events`, `check_availability`, `list_calendars` |
| Calendar, write | `create_event` (with attendees and recurrence), `update_event`, `delete_event` ⚠️, `add_alarm`, `remove_alarm` |
| Invitations | `list_invitations` (events of your calendars awaiting your answer, next 30 days by default), `respond_to_invitation` ⚠️ |
| Contacts, read | `search_contacts`, `get_contact_details`, `list_contacts`, `list_addressbooks` |
| Contacts, write | `create_contact`, `update_contact`, `delete_contact` ⚠️ |
| Approval | `approve_batch` (one approval for a series of writes, see [below](#approving-a-series-of-writes-at-once)) |

⚠️ = deletes data or makes the server notify other people. Every tool carries MCP annotations (`readOnlyHint`, `destructiveHint`, `openWorldHint`).

**Every write is approved by you first.** Before `create_event`, `update_event`, `delete_event`, `add_alarm`, `remove_alarm`, `respond_to_invitation`, `create_contact`, `update_contact` or `delete_contact` writes anything, the server itself shows you the exact action through MCP elicitation (see [Prior approval](#prior-approval)) and acts only on your explicit OK.

### Highlights

- **Attendees and organizer**: `create_event` invites attendees, with the organizer taken from `DAV_ORGANIZER_EMAIL` / `DAV_ORGANIZER_NAME`; the server sends the invitations.
- **Recurring events**: RRULE expansion with safety limits, single-occurrence edits and deletions, and an opt-out (`DAV_RECURRING_WRITES=false`) for cautious deployments.
- **Reliable updates**: events are found by UID with a server-side query; updates use parse-modify-serialize, so alarms, attendees and `X-` properties are preserved.
- **Status display**: cancelled and tentative events, attendee participation status.
- **Pagination by date**: `get_events_in_range`, `get_todays_schedule` and `search_events` take `limit` (default 50, maximum 100) and `cursor`, and return a `nextCursor` while events remain. A range covers 92 days at most. An event shows its first 10 attendees; `all_attendees` lists them all, with a small `limit` since an answer can then reach hundreds of thousands of characters.
- **Visible failures**: a DAV read that fails or times out (30 seconds), including an error inside a 207, is reported to the assistant as an error, not as an empty result. Objects that could not be read are named next to the result. Cancelling a tool call cancels its requests. A read is retried only on 429, 503 and network errors, `Retry-After` honoured up to 10 seconds. A write is never retried: without an answer, the assistant is told its outcome is unknown.
- **Five authentication methods**: Basic, Bearer, OpenPaaS ESNToken, **token command** (short-lived tokens refreshed before every call) and an external credentials file.
- **Reverse proxy support**: `DAV_HREF_PREFIX` for servers published under a path prefix that their responses omit (Twake Calendar / OpenPaaS).
- CTag-based caching, retries with backoff, natural-language dates ([chrono-node](https://github.com/wanasit/chrono)), HTTPS enforced.

## Requirements

- **Node.js** >= 20.3
- A **CalDAV / CardDAV server**: Twake Calendar, Nextcloud, SOGo, DAViCal, ownCloud… (HTTPS required, except `localhost`)
- An **MCP client**: Claude Desktop, Claude Code, Hermes Agent, Cursor, VS Code, or any MCP-compatible assistant

## Installation

### Quick start with mcp-twake-ai (recommended)

```bash
npx mcp-twake-ai setup
```

[mcp-twake-ai](https://github.com/linagora/mcp-twake-ai) sets up this server and the other Twake.ai MCP servers for your Twake.ai account: it asks for your email, signs you in at the Twake.ai identity provider (in the browser, or with a code over SSH), and finds the agents on your computer (Claude Code, Hermes, Claude Desktop, Cursor, VS Code) and the services of your account. It then installs pinned versions of the servers, writes their entries in each agent's configuration and checks that each server starts. For any other agent, `mcp-twake-ai export --agent <id>` writes the configuration files.

### Manual installation

**Interactive setup of this server only:**

```bash
npx mcp-twake-dav setup
```

The wizard asks for your server URL and credentials, tests the connection, lists your calendars and address books, lets you pick the defaults, and can write the Claude Desktop configuration for you.

**Global install:**

```bash
npm install -g mcp-twake-dav
```

**From source:**

```bash
git clone https://github.com/linagora/mcp-twake-dav.git
cd mcp-twake-dav
npm install
npm run build          # then run: node build/index.js
```

## Configuration

The server is configured through environment variables, usually set in your MCP client configuration.

### Authentication

| Method | Variables |
|---|---|
| **Basic** (default) | `DAV_URL`, `DAV_USERNAME`, `DAV_PASSWORD` |
| **Bearer** | `DAV_URL`, `DAV_AUTH_METHOD=bearer`, `DAV_TOKEN` |
| **ESNToken** (OpenPaaS) | `DAV_URL`, `DAV_AUTH_METHOD=esntoken`, `DAV_TOKEN` |
| **Token command** | `DAV_URL`, `DAV_AUTH_METHOD=command`, `DAV_TOKEN_COMMAND` |

- With **token command**, the server runs `DAV_TOKEN_COMMAND` to get an access token, either raw on stdout or as JSON `{"access_token": "...", "expires_at": <epoch seconds>}`, and refreshes it before every call. A single broker you control can then own the OIDC grant for several tools. For Twake.ai, [mcp-twake-ai](https://github.com/linagora/mcp-twake-ai) is that broker: `mcp-twake-ai token dav`. Give the command with an absolute path, as some MCP clients do not see your `PATH`. It runs through the system shell (`sh`, or `cmd.exe` on Windows, where paths go in double quotes).
- `DAV_CREDENTIALS_FILE` points to a file holding `DAV_USERNAME=…`, `DAV_PASSWORD=…` or `DAV_TOKEN=…` lines, so secrets stay out of the MCP client configuration.

### Other options

| Variable | Description | Default |
|---|---|---|
| `DAV_DEFAULT_CALENDAR` | Calendar used when the assistant does not name one; a group of calendars works too (see [Your calendars and the ones shared with you](#your-calendars-and-the-ones-shared-with-you)) | all calendars |
| `DAV_DEFAULT_ADDRESSBOOK` | Address book used by default | all address books |
| `DAV_ORGANIZER_EMAIL` / `DAV_ORGANIZER_NAME` | Organizer written in events that have attendees; your address as an attendee for `list_invitations` and `respond_to_invitation` (required with an SSO token) | none |
| `DAV_RECURRING_WRITES` | `false` = `update_event` / `delete_event` refuse recurring series and occurrences | `true` |
| `DAV_HREF_PREFIX` | Path prefix stripped by a reverse proxy, e.g. `/dav` for Twake Calendar / OpenPaaS | none |
| `USER_TIMEZONE` | IANA time zone used to display and interpret dates, e.g. `Europe/Paris` | system time zone |
| `DAV_APPROVAL` | `elicit`: the server asks you before every write; `client`: your MCP client confirms | `elicit` |
| `DAV_APPROVAL_TIMEOUT_MS` | How long an approval prompt waits for your answer | `600000` |
| `USER_LANGUAGE` | Language of the approval prompts, `en` or `fr` | `en` |
| `LOG_LEVEL` | `fatal`, `error`, `warn`, `info`, `debug`, `trace` | `info` |

### Prior approval

With `DAV_APPROVAL=elicit` (the default), every write tool sends the MCP client an [elicitation](https://modelcontextprotocol.io/specification/draft/client/elicitation) request before it writes, for instance:

```
Twake Calendar: Delete an event (cannot be undone)
As: Jane DOE (your account)
Event: Budget review · 2026-11-05 14:00 → 15:00 (Europe/Paris)
Notified: Bob DURAND (the server may send them a cancellation)

Ref. 3f9a1c · Accept to do it now, refuse to cancel.
```

- The prompt shows the dates as the server understood them, the event being changed, the attendees who will receive an e-mail, and the contact's current values.
- The server writes only on *accept*. A refusal, a dismissal, a timeout (`DAV_APPROVAL_TIMEOUT_MS`, 10 minutes) or an error writes nothing, and the tool tells the assistant not to retry.
- A client without elicitation support gets an error and nothing is written. Set `DAV_APPROVAL=client` only if your MCP client asks you to confirm every write tool itself.
- `USER_LANGUAGE=fr` writes the prompts in French.

### Twake Calendar

Twake Calendar publishes its SabreDAV endpoint under `/dav/` and accepts OIDC Bearer tokens:

```bash
DAV_URL=https://calendar.example.com/dav/
DAV_HREF_PREFIX=/dav
DAV_AUTH_METHOD=command
DAV_TOKEN_COMMAND="/usr/local/bin/mcp-twake-ai token dav"
DAV_ORGANIZER_EMAIL=jane.doe@example.com
DAV_DEFAULT_CALENDAR="Jane Doe"
```

Without `DAV_HREF_PREFIX`, discovery fails with `cannot find homeUrl` or calendars come back empty.

#### Your calendars and the ones shared with you

An account often sees more than its own calendars: colleagues share theirs, read-only or with write access. `list_calendars` groups them, from the `DAV:current-user-privilege-set` and `DAV:owner` properties of RFC 3744 and from `DAV:share-access`, which the CalDAV sharing extension (`draft-pot-webdav-resource-sharing`) adds:

```text
Available calendars (15): 2 yours, 3 shared with write access, 10 read-only

My calendars (2): …
Shared with write access (3): …
Read-only (10): …
```

The query tools take the name of a group, so an assistant asked "what's on my calendar?" does not list other people's meetings:

```text
get_todays_schedule(calendar: "mine")         # the calendars you own
get_todays_schedule(calendar: "writable")     # every calendar you may write to, your own included
get_todays_schedule(calendar: "shared-write") # somebody else's calendars shared with write access
get_todays_schedule(calendar: "read-only")    # where you may only read: shared read-only, or your own
```

A group can also be the default calendar (`DAV_DEFAULT_CALENDAR=mine`): an assistant then reads the calendars you own unless it names another calendar. `calendar: "all"` follows that default — an assistant sends "all" on its own, and a user who configured a default did not ask for every calendar — and `DAV_DEFAULT_CALENDAR=all` means no default at all, every calendar being read only when none is configured. A name still targets one calendar — a calendar that really is called `mine` keeps its own name.

`create_event` needs a calendar name when the default is a group, since creating an event in several calendars at once has no meaning. The tools that find an event by UID — `update_event`, `delete_event`, `add_alarm`, `remove_alarm` — search the calendars of that group.

The rights come from three properties:

- `DAV:current-user-privilege-set` says whether the account may write: without `DAV:write`, `DAV:write-content` or `DAV:all`, the calendar is read-only;
- `DAV:share-access`, when the server publishes it, says that a calendar is shared with the account, and with which access — it wins over the privileges, and it is what tells a colleague's calendar shared with write access from one you own on a server that names the receiving account as its owner (upstream SabreDAV does; Twake Calendar names the account that shares it);
- `DAV:owner` separates your own calendars from somebody else's shared with write access, on servers that do not publish the sharing.

A subscription — a colleague's public calendar you subscribed to, which Twake Calendar lists as a calendar with the resource type `cs:subscribed` and you as its owner — is never in `mine`: it goes to `shared-write` when you may write to it, to `read-only` otherwise.

A server that publishes none of them gets the plain list, and asking for a group then says so instead of answering "No calendar with…": name a calendar, or use `"all"`. Calendars whose rights the server gives for some of them only are listed apart, under *Access rights unknown*.

## Use it with your assistant

### Claude Desktop

Edit `claude_desktop_config.json` (macOS: `~/Library/Application Support/Claude/`, Linux: `~/.config/Claude/`, Windows: `%APPDATA%\Claude\`), then restart Claude Desktop:

```json
{
  "mcpServers": {
    "twake-dav": {
      "command": "npx",
      "args": ["-y", "mcp-twake-dav"],
      "env": {
        "DAV_URL": "https://dav.example.com",
        "DAV_USERNAME": "jane.doe@example.com",
        "DAV_PASSWORD": "your-password",
        "DAV_DEFAULT_CALENDAR": "My Calendar",
        "DAV_DEFAULT_ADDRESSBOOK": "My Contacts",
        "USER_TIMEZONE": "Europe/Paris"
      }
    }
  }
}
```

### Claude Code

```bash
claude mcp add twake-dav --scope user \
  -e DAV_URL=https://dav.example.com \
  -e DAV_USERNAME=jane.doe@example.com \
  -e DAV_CREDENTIALS_FILE=~/.config/mcp-twake-dav/credentials \
  -- npx -y mcp-twake-dav
```

### Hermes Agent

```yaml
mcp_servers:
  twake_dav:
    command: npx
    args: ["-y", "mcp-twake-dav"]
    env:
      DAV_URL: https://calendar.example.com/dav/
      DAV_HREF_PREFIX: /dav
      DAV_AUTH_METHOD: command
      DAV_TOKEN_COMMAND: /usr/local/bin/mcp-twake-ai token dav
      DAV_ORGANIZER_EMAIL: jane.doe@example.com
      DAV_RECURRING_WRITES: "false"
      DAV_APPROVAL_TIMEOUT_MS: "330000"
      USER_LANGUAGE: fr
    timeout: 420            # longer than the approval wait
    elicitation:
      enabled: true
      timeout: 300
```

Hermes shows the approval prompts in the desktop app, the terminal or on your messaging platform, and declines them where nobody can answer (cron jobs, one-shot queries).

### Other MCP clients

Any client that can launch a stdio MCP server works: command `npx`, arguments `-y mcp-twake-dav`, and the environment variables above.

## From the command line

Every tool of this server can be called from a terminal or a script, with the same configuration (`DAV_*` variables) as the server:

```sh
npx mcp-twake-dav tools                      # one line per tool
npx mcp-twake-dav tools get_events_in_range  # its parameters
npx mcp-twake-dav call get_events_in_range --arg when="next week" --arg calendar=mine
npx mcp-twake-dav call create_event --json @event.json
```

- `--arg key=value` is converted to the type the tool gives `key`; `--json` takes the whole arguments object (`@file`, or `-` for stdin). The result goes to stdout (`--json-output` for the raw result), everything else to stderr.
- Exit codes: 0 done, 1 the tool answered with an error, 2 wrong command or argument, 3 a write was not approved, 4 the server could not be reached.
- **Writes:** typed by you in a terminal, a write is approved without a question (`--i` asks first). Started by an agent (`CLAUDECODE` or `HERMES_HOME` set), a write is refused: agents write through their MCP tools, which ask you. Without a terminal (cron), a write is refused unless it passes `--yes --as <name>` for a name you allowed once, in a terminal, with `npx mcp-twake-dav allow-unattended <name>`. The allowed names are shared by the six Twake.ai servers, in `~/.config/twake-ai/cli.json` (`%USERPROFILE%\AppData\Roaming\twake-ai\cli.json` on Windows).
- These rules stop an agent that follows instructions; they cannot stop a program that hides that it is an agent, or rewrites `cli.json`, under your account.
- With [mcp-twake-ai](https://github.com/linagora/mcp-twake-ai), `npx mcp-twake-ai call dav …` does the same with your Twake.ai sign-in.

## Approving a series of writes at once

Before a series of writes (several events, several contacts), an agent can ask you once for the whole list with `approve_batch`: you see every action, numbered, in one approval. Each call that then carries the `batchId` and matches a listed action exactly runs without another question, once, within 15 minutes. A call that is not in the list, or whose target changed since you approved, asks as usual. A batch approves exactly what each action's approval text shows; it belongs to the session that approved it, and is forgotten when that session ends. With `DAV_APPROVAL=client`, there is no batch.

## Recommended safe configuration

Creating, moving or deleting an event with attendees makes the server **email them in your name**, and contact deletion is final (CardDAV has no trash). For an assistant that acts on its own:

- keep `DAV_APPROVAL=elicit` (the default): every write waits for your OK on the exact action, whatever the assistant decides;
- set `DAV_RECURRING_WRITES=false` and edit recurring series in Twake Calendar;
- filter out `respond_to_invitation` (and `delete_contact` if not needed) in your MCP client, for example with Hermes Agent:

```yaml
    tools:
      exclude: [respond_to_invitation, delete_contact]
```

Event descriptions and contact notes may be written by third parties (prompt injection). See [SECURITY.md](SECURITY.md).

## Usage examples

- "What's my next meeting, and where is it?"
- "Show my schedule for this week."
- "Am I free tomorrow afternoon? Find me a 45-minute slot."
- "Create a meeting with Pierre on Thursday at 2 pm and invite him."
- "Add a 15-minute reminder to my dentist appointment."
- "Do I have pending invitations?"
- "What's Marie's email address? Update her phone number."

## Troubleshooting

| Symptom | Fix |
|---|---|
| `Configuration validation failed` | Set the variables required by your `DAV_AUTH_METHOD` (see *Authentication*). |
| `Not done: this MCP client cannot ask the user for approval` | Your MCP client does not support elicitation: use one that does, or `DAV_APPROVAL=client` if it confirms writes itself. |
| `Not done: no answer to the approval request` | The prompt timed out or nobody could answer (cron, one-shot query): nothing was written. |
| `401 Unauthorized` | Check the credentials; with a token, check that it is valid and not expired. |
| `URL must use HTTPS` | Use `https://` (HTTP is only accepted for `localhost` / `127.0.0.1`). |
| `cannot find homeUrl` / empty calendars | The server sits behind a path prefix: set `DAV_HREF_PREFIX` (e.g. `/dav`). |
| `Event not found` on update or delete | Pass the calendar name. `calendar: "all"` follows `DAV_DEFAULT_CALENDAR` when one is set, so naming it does not widen the search. |
| No calendars or address books | Check the account's permissions in the server's web interface. |
| Tools missing in the client | Restart the client after editing its configuration; check that `npx` is in the `PATH`. |

Run with `LOG_LEVEL=debug` for details (logs go to stderr).

## Architecture

```
MCP client ⇄ stdio (JSON-RPC) ⇄ mcp-twake-dav ⇄ HTTPS (CalDAV / CardDAV) ⇄ Twake Calendar / any DAV server
```

Layers: Zod configuration with HTTPS enforcement, Pino logger on stderr, [tsdav](https://github.com/natelindev/tsdav) clients with pluggable authentication and href-prefix rewriting, retry and CTag cache, calendar and address book services, [ical.js](https://github.com/kewisch/ical.js) transformers (iCalendar, vCard, RRULE, time zones), and the MCP tools.

## Development

```bash
npm install
npm run build    # compile TypeScript
npm test         # Vitest suite, no real server needed
npm run dev      # watch mode
node scripts/check-command-auth.mjs   # token-command refresh against a mock CalDAV server
```

## Contributing

Contributions are welcome: read [CONTRIBUTING.md](CONTRIBUTING.md) and our [Code of Conduct](CODE_OF_CONDUCT.md). Please report vulnerabilities privately as described in [SECURITY.md](SECURITY.md). Release notes are in [CHANGELOG.md](CHANGELOG.md).

## License

Licensed under the **GNU Affero General Public License v3.0** ([AGPL-3.0](LICENSE)).

Copyright © 2026 [LINAGORA](https://linagora.com)

## About

`mcp-twake-dav` is developed by [LINAGORA](https://linagora.com), French open source software publisher, as part of [Twake.ai](https://twake.ai). For support, hosting or integration of Twake.ai and its AI connectors, contact LINAGORA at <https://linagora.com>.