mcp-twake-ai 0.1.0 → 0.3.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 +171 -58
- package/build/catalog.js +156 -4
- package/build/catalog.js.map +1 -1
- package/build/cli.js +77 -11
- package/build/cli.js.map +1 -1
- package/build/config.js +2 -0
- package/build/config.js.map +1 -1
- package/build/cozy.js +1 -1
- package/build/cozy.js.map +1 -1
- package/build/exporter.js +7 -1
- package/build/exporter.js.map +1 -1
- package/build/i18n.js +2 -0
- package/build/i18n.js.map +1 -1
- package/build/login.js +6 -2
- package/build/login.js.map +1 -1
- package/build/oidc.js +1 -1
- package/build/oidc.js.map +1 -1
- package/build/wizard.js +1 -1
- package/build/wizard.js.map +1 -1
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -1,103 +1,191 @@
|
|
|
1
1
|
# mcp-twake-ai
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/mcp-twake-ai)
|
|
4
|
+
[](https://github.com/linagora/mcp-twake-ai/actions/workflows/ci.yml)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](https://nodejs.org/)
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
<p align="center">
|
|
9
|
+
<img src="assets/banner.png" alt="MCP Twake.ai: sets up the MCP servers of the Twake.ai platform in your AI agents" width="660">
|
|
10
|
+
</p>
|
|
6
11
|
|
|
7
|
-
|
|
12
|
+
**One command connects your AI agent to [Twake.ai](https://twake.ai): Mail, Calendar, Drive, Chat, Space and Project, with a single sign-in.**
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npx mcp-twake-ai setup
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## What is it?
|
|
19
|
+
|
|
20
|
+
`mcp-twake-ai` sets up the six Twake.ai [Model Context Protocol](https://modelcontextprotocol.io) (MCP) servers in your AI agents (Claude Code, Hermes, Claude Desktop, Cursor and VS Code), and gives any other agent a ready-made configuration.
|
|
21
|
+
|
|
22
|
+
You type your email address and sign in once at your Twake.ai identity provider. `mcp-twake-ai` finds your services, writes them into the agents you choose, then stays behind as their token broker: the refresh token sits in your operating system's keychain, and each MCP server gets a fresh access token whenever it needs one. No password or token is written into an agent's configuration.
|
|
23
|
+
|
|
24
|
+
## Part of Twake.ai
|
|
25
|
+
|
|
26
|
+
[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.
|
|
27
|
+
|
|
28
|
+
`mcp-twake-ai` installs and connects its six open source MCP servers:
|
|
29
|
+
|
|
30
|
+
| MCP server | Twake.ai service | Protocol |
|
|
31
|
+
| ------------------------------------------------------------------ | --------------------------------------- | ----------------- |
|
|
32
|
+
| [mcp-twake-mail](https://github.com/linagora/mcp-twake-mail) | Twake Mail | JMAP |
|
|
33
|
+
| [mcp-twake-dav](https://github.com/linagora/mcp-twake-dav) | Twake Calendar and contacts | CalDAV / CardDAV |
|
|
34
|
+
| [mcp-twake-drive](https://github.com/linagora/mcp-twake-drive) | Twake Drive | cozy-stack API |
|
|
35
|
+
| [mcp-twake-chat](https://github.com/linagora/mcp-twake-chat) | Twake Chat | Matrix |
|
|
36
|
+
| [mcp-twake-space](https://github.com/linagora/mcp-twake-space) | Twake Space (team spaces) | Twake Space API |
|
|
37
|
+
| [mcp-twake-project](https://github.com/linagora/mcp-twake-project) | Twake Project (projects, boards, tasks) | Twake Project API |
|
|
8
38
|
|
|
9
39
|
## Requirements
|
|
10
40
|
|
|
11
41
|
- **Node.js** >= 22.13
|
|
12
42
|
- An account on the Twake.ai SaaS
|
|
13
|
-
-
|
|
43
|
+
- One of the agents above, or any MCP client for `export`
|
|
44
|
+
|
|
45
|
+
Your identity provider needs the public OIDC client `twake-ai-agents` (PKCE, `offline_access`, loopback redirect URIs `http://127.0.0.1:8765/callback` to `:8767`, device flow, and the audiences of the Twake.ai backends). It exists on the Twake.ai SaaS; another client can be used with `--client-id` or `TWAKE_AI_OIDC_CLIENT_ID`.
|
|
14
46
|
|
|
15
47
|
## Start here
|
|
16
48
|
|
|
49
|
+
Run it in a terminal, from any folder:
|
|
50
|
+
|
|
17
51
|
```bash
|
|
18
52
|
npx mcp-twake-ai setup
|
|
19
53
|
```
|
|
20
54
|
|
|
21
|
-
|
|
55
|
+
The guided setup asks a few questions and changes nothing before you confirm. It speaks English (`TWAKE_AI_LANGUAGE=fr` switches it to French), and pressing Escape at any question leaves everything as it was.
|
|
22
56
|
|
|
23
|
-
|
|
57
|
+
**1. Your Twake.ai email address.** It is enough to find your services.
|
|
24
58
|
|
|
25
|
-
|
|
59
|
+
<img src="assets/setup-1-email.png" alt="The banner of mcp-twake-ai setup, then the question: your Twake.ai email address" width="760">
|
|
26
60
|
|
|
27
|
-
|
|
28
|
-
npm install -g mcp-twake-ai
|
|
29
|
-
mcp-twake-ai login --email jane.doe@example.com
|
|
30
|
-
```
|
|
61
|
+
**2. Sign in once.** Your browser opens on your Twake.ai sign-in page. Over SSH, without a display or with `--no-browser`, the terminal shows a code to enter from your phone or another computer instead:
|
|
31
62
|
|
|
32
|
-
|
|
63
|
+
<img src="assets/setup-2-code.png" alt="The services found for jdoe@example.com, then the address to open and the code WDJB-MJHT" width="760">
|
|
33
64
|
|
|
34
|
-
|
|
65
|
+
<img src="assets/setup-3-sso.png" alt="The Device Authorization page of the identity provider, with the code WDJBMJHT ready to authorize" width="620">
|
|
35
66
|
|
|
36
|
-
|
|
67
|
+
**3. Choose the agents and the services.** The agents found on this computer, and the services of your account, are ticked in advance.
|
|
37
68
|
|
|
38
|
-
|
|
69
|
+
<img src="assets/setup-4-choose.png" alt="Claude Code and Cursor chosen; Mail, Calendar, Space and Project ticked among the services" width="760">
|
|
39
70
|
|
|
40
|
-
|
|
41
|
-
claude mcp add twake-project --scope user \
|
|
42
|
-
-e TWAKE_PROJECT_URL=https://projects.example.com \
|
|
43
|
-
-e "TWAKE_PROJECT_TOKEN_COMMAND=$(command -v mcp-twake-ai) token project" \
|
|
44
|
-
-e TWAKE_PROJECT_OIDC_ISSUER=https://sso.example.com/ \
|
|
45
|
-
-- npx -y mcp-twake-project
|
|
46
|
-
```
|
|
71
|
+
**4. Check the plan, and confirm.** Each agent gets one entry per service: `twake-mail`, `twake-dav`…
|
|
47
72
|
|
|
48
|
-
|
|
73
|
+
<img src="assets/setup-5-plan.png" alt="The plan: four twake entries to add in Claude Code and in Cursor, then Apply this plan? Yes" width="760">
|
|
49
74
|
|
|
50
|
-
|
|
75
|
+
**5. Done.** The servers are installed, written into your agents, and each one is started once to check it answers.
|
|
51
76
|
|
|
52
|
-
|
|
77
|
+
<img src="assets/setup-6-done.png" alt="The servers installed and written, each server checked, and what to do to finish in each agent" width="760">
|
|
53
78
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
79
|
+
Under `npx`, `mcp-twake-ai` copies itself into its private folder, so that your agents never depend on npx's cache, and puts a `mcp-twake-ai` command in `~/.local/bin` (`%LOCALAPPDATA%\twake-ai\bin` on Windows).
|
|
80
|
+
|
|
81
|
+
## Use it from Claude Code
|
|
82
|
+
|
|
83
|
+
Start a new `claude` session: `/mcp` lists the `twake-*` servers. Then ask in plain words. Reads happen at once; every write is shown to you for approval first (illustrative, abridged session):
|
|
84
|
+
|
|
85
|
+
```text
|
|
86
|
+
> What's on my calendar tomorrow? Draft a reply to Pierre's last email with my free slots.
|
|
87
|
+
|
|
88
|
+
⏺ twake-dav - get_events_in_range (MCP)(when: "tomorrow")
|
|
89
|
+
⎿ 3 events: 09:30 Team stand-up · 11:00 Budget review · 15:00 Call with Acme
|
|
90
|
+
|
|
91
|
+
⏺ twake-mail - search_emails (MCP)(from: "pierre", limit: 1)
|
|
92
|
+
⎿ "Workshop next week?" from Pierre Martin, yesterday at 17:42
|
|
93
|
+
|
|
94
|
+
⏺ twake-mail - create_draft (MCP)(to: ["pierre.martin@example.com"], subject: "Re: Workshop next week?", …)
|
|
95
|
+
|
|
96
|
+
╭─ twake-mail asks for your approval ────────────────╮
|
|
97
|
+
│ Create a draft │
|
|
98
|
+
│ to: pierre.martin@example.com │
|
|
99
|
+
│ subject: Re: Workshop next week? │
|
|
100
|
+
│ │
|
|
101
|
+
│ ❯ Accept Decline │
|
|
102
|
+
╰────────────────────────────────────────────────────╯
|
|
103
|
+
⎿ Draft saved
|
|
104
|
+
|
|
105
|
+
⏺ Tomorrow you have the stand-up at 9:30, the budget review at 11:00 and the
|
|
106
|
+
Acme call at 15:00. You are free from 13:00 to 15:00 and after 16:00: the
|
|
107
|
+
reply to Pierre proposing these slots is in your Drafts, ready to send.
|
|
57
108
|
```
|
|
58
109
|
|
|
59
|
-
|
|
60
|
-
- **Twake Chat** encrypts messages end to end, and the encryption keys belong to a device. Each agent therefore gets its own device, "Twake AI · <agent>", listed in your Twake Chat sessions. `mcp-twake-ai token chat --agent hermes` prints the token together with its `device_id` and `user_id`, as mcp-twake-chat expects. Signing in again for the same agent replaces its device and logs the old one out.
|
|
61
|
-
- **Over SSH or without a display:** `mcp-twake-ai` prints the address to open on a phone or another computer. At the end, the browser shows a page that cannot load: paste its address back into the terminal.
|
|
110
|
+
More to try:
|
|
62
111
|
|
|
63
|
-
|
|
112
|
+
- "Summarize my unread emails from today."
|
|
113
|
+
- "Find the latest version of the budget file in my Drive."
|
|
114
|
+
- "Which tasks are due this week in the Website project?"
|
|
115
|
+
- "Post the meeting notes in the #team room."
|
|
116
|
+
|
|
117
|
+
## Commands
|
|
118
|
+
|
|
119
|
+
### Setup without questions
|
|
64
120
|
|
|
65
121
|
```sh
|
|
122
|
+
mcp-twake-ai setup --email jane.doe@example.com --agents detected # signs in, shows what would change
|
|
66
123
|
mcp-twake-ai setup --agents detected # shows what would change, writes nothing
|
|
67
124
|
mcp-twake-ai setup --agents claude-code,hermes --yes # writes it
|
|
68
125
|
mcp-twake-ai setup --agents cursor --services mail,dav --yes
|
|
126
|
+
mcp-twake-ai setup --agents cursor --services mail,dav --yes --env 'dav.DAV_DEFAULT_CALENDAR=Jane Doe'
|
|
69
127
|
```
|
|
70
128
|
|
|
71
|
-
|
|
129
|
+
With `--email`, `setup` first signs in to that account if it is not the current one. With `--yes`, it connects Twake Drive and gives each agent its own Twake Chat device when those services are chosen, installs the pinned servers, then writes the agents.
|
|
130
|
+
|
|
131
|
+
`--env <service>.<VARIABLE>=<value>` adds a variable of your own to a server's environment (`--env` can be repeated). It is kept in `config.json` — never in an agent's file — and every entry, `run`, `status --print-env` and `export` builds it from there. A later sign-in to the same account keeps it; another account starts without it, since several of these variables name a calendar, an address or a prefix of one account. An empty value (`--env dav.DAV_DEFAULT_CALENDAR=`) forgets the variable. Services are `mail`, `dav`, `drive`, `chat`, `space` and `project`. `status --print-env dav` shows the environment a server gets, yours included.
|
|
132
|
+
|
|
133
|
+
Only a few names are accepted, on the command line and in a `config.json` edited by hand:
|
|
134
|
+
|
|
135
|
+
- the variables of the server itself — `JMAP_…` for Twake Mail, `DAV_…` for Twake Calendar, `TWAKE_DRIVE_…`, `MATRIX_…`, `TWAKE_SPACE_…`, `TWAKE_PROJECT_…` — for instance `DAV_DEFAULT_CALENDAR` or `JMAP_DEFAULT_FROM`;
|
|
136
|
+
- the `USER_…` ones (`USER_LANGUAGE`, `USER_TIMEZONE`);
|
|
137
|
+
- `LOG_LEVEL`, the one logging variable the servers document.
|
|
138
|
+
|
|
139
|
+
Everything else is refused: `PATH`, `HOME`, `TWAKE_AI_HOME`, `LD_PRELOAD`, `NODE_OPTIONS`… have nothing to do with a server, and listing the dangerous names of a process environment one by one is a losing game. Within the accepted prefixes, the names that point at a server, say how to sign in to it or whose account it is (`*_URL`, `*_AUTH_METHOD`, `*_OIDC_ISSUER`, `*_CLIENT_ID`, `MATRIX_USER_ID`) are refused too, since they come from your account, and so are the ones that may carry a secret (`*TOKEN*`, `*SECRET*`, `*PASSWORD*`, `*_API_KEY`), which the keychain and the token broker already handle. The folders for files (`*_DOWNLOAD_DIR`, `*_UPLOAD_DIR`) are refused as well, since Mail, Drive and Chat share `~/Downloads/Twake` for the files they save, send and upload, and so are the names of a file the server reads (`*_PATH`, `*_FILE`). The one exception is `JMAP_SIGNATURE_PATH`, accepted only for a file directly in `~/.mcp-twake-mail/` (for instance `~/.mcp-twake-mail/signature.md`), since Mail appends it to every mail it writes.
|
|
140
|
+
|
|
141
|
+
The approval of writes cannot be lifted here: `*_APPROVAL` and `*_APPROVAL_EXEMPT` are refused, since every write is approved by you first, in every agent; `*_APPROVAL_TIMEOUT_MS`, how long the prompt waits, can be set.
|
|
142
|
+
|
|
143
|
+
Two things to know: a variable set here applies to the service in every agent that runs it (`DAV_DEFAULT_CALENDAR` changes the calendar for all of them), and for Hermes a `*_APPROVAL_TIMEOUT_MS` you set replaces the value mcp-twake-ai chose for it. When a server is started through `run`, the environment the agent already sets for it still wins over the one written here.
|
|
72
144
|
|
|
73
|
-
| Agent (`--agents`)
|
|
74
|
-
|
|
75
|
-
| Claude Code (`claude-code`)
|
|
76
|
-
| Hermes (`hermes`)
|
|
77
|
-
| Claude Desktop (`claude-desktop`) | `claude_desktop_config.json`
|
|
78
|
-
| Cursor (`cursor`)
|
|
79
|
-
| VS Code (`vscode`)
|
|
145
|
+
| Agent (`--agents`) | Where | Approval of writes |
|
|
146
|
+
| --------------------------------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------- |
|
|
147
|
+
| Claude Code (`claude-code`) | `claude mcp add --scope user` | in Claude Code |
|
|
148
|
+
| Hermes (`hermes`) | `config.yaml` in `$HERMES_HOME`, `~/.hermes` (`%LOCALAPPDATA%\hermes` on Windows) or its active profile | in Hermes |
|
|
149
|
+
| Claude Desktop (`claude-desktop`) | `claude_desktop_config.json` | not supported: reads work, writes are refused |
|
|
150
|
+
| Cursor (`cursor`) | `~/.cursor/mcp.json` | in Cursor |
|
|
151
|
+
| VS Code (`vscode`) | `Code/User/mcp.json` of the default profile | in VS Code |
|
|
80
152
|
|
|
81
153
|
- It only changes the entries it wrote. An entry with the same name configured by hand, or changed since, is left alone unless you add `--force`.
|
|
82
154
|
- A file is copied to `<file>.bak-<date>` before it changes. Comments and other settings are kept.
|
|
83
155
|
- An agent whose write fails is put back as it was; the others are still written.
|
|
84
156
|
- Running it again changes nothing. With fewer `--services`, it removes the entries you left out.
|
|
157
|
+
- It exits with 1 when something you asked for was not done (an agent not installed, an entry left alone).
|
|
85
158
|
|
|
86
|
-
|
|
159
|
+
### Your calendars, not every calendar shared with you
|
|
160
|
+
|
|
161
|
+
Twake Calendar's server reads every calendar your account can see, the ones colleagues share with you included. A question such as "what's on my calendar today?" then lists their meetings too, sometimes the same meeting several times. Name the calendar it should use when the assistant does not name one:
|
|
162
|
+
|
|
163
|
+
```sh
|
|
164
|
+
mcp-twake-ai setup --agents claude-code --services mail,dav --yes --env 'dav.DAV_DEFAULT_CALENDAR=Jane Doe'
|
|
165
|
+
mcp-twake-ai status --print-env dav # DAV_DEFAULT_CALENDAR=Jane Doe is in the list
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
- The value is the calendar's name, as Twake Calendar shows it: ask your assistant to list your calendars to see them.
|
|
169
|
+
- Give the `--agents` and `--services` you set up (`mcp-twake-ai status` lists the entries): without `--services`, `setup` takes every service of your account, Twake Chat included.
|
|
170
|
+
- Start a new session of your agent: the server reads the variable when it starts.
|
|
171
|
+
- The assistant can still name another calendar, or search them all with `calendar: "all"`.
|
|
172
|
+
- Every agent that runs Twake Calendar gets it, a new sign-in to the same account keeps it, and `--env dav.DAV_DEFAULT_CALENDAR=` forgets it.
|
|
173
|
+
|
|
174
|
+
### Check, sign out, uninstall
|
|
87
175
|
|
|
88
176
|
```sh
|
|
89
|
-
mcp-twake-ai status
|
|
90
|
-
mcp-twake-ai status --no-start
|
|
91
|
-
mcp-twake-ai status --env mail --agent cursor # the environment run builds for a server
|
|
92
|
-
mcp-twake-ai logout
|
|
93
|
-
mcp-twake-ai uninstall
|
|
177
|
+
mcp-twake-ai status # session, Drive, every entry, and each server started once
|
|
178
|
+
mcp-twake-ai status --no-start # the same without starting the servers
|
|
179
|
+
mcp-twake-ai status --print-env mail --agent cursor # the environment run builds for a server
|
|
180
|
+
mcp-twake-ai logout # revokes every authorization and forgets the secrets
|
|
181
|
+
mcp-twake-ai uninstall # shows what it would remove; add --yes to do it
|
|
94
182
|
```
|
|
95
183
|
|
|
96
|
-
- `status` checks the Twake session
|
|
97
|
-
- `logout` revokes the session at the identity provider, removes "Twake AI" from the Drive connected devices, signs every Chat device out, then deletes the secrets and the cached tokens.
|
|
184
|
+
- `status` checks the Twake session, Twake Drive, each agent's Chat device, that every entry is the one mcp-twake-ai wrote, and that each server answers through its entry. It exits with 1 when something is wrong, and says what.
|
|
185
|
+
- `logout` revokes the session at the identity provider, removes "Twake AI" from the Drive connected devices, signs every Chat device out, then deletes the secrets and the cached tokens.
|
|
98
186
|
- `uninstall --yes` removes the entries it wrote (`--force` for those changed by hand), signs out, and deletes the servers, the configuration, the cache and the journal. The Twake Chat stores hold the local index of your messages: they are kept unless you add `--delete-chat-stores`.
|
|
99
187
|
|
|
100
|
-
|
|
188
|
+
### Any other agent: `export`
|
|
101
189
|
|
|
102
190
|
```bash
|
|
103
191
|
mcp-twake-ai export --agent zed # every service found and connected
|
|
@@ -105,22 +193,37 @@ mcp-twake-ai export --agent cursor --services mail,chat --out ./cursor-config
|
|
|
105
193
|
mcp-twake-ai export --agent zed --raw # the servers and their full environment
|
|
106
194
|
```
|
|
107
195
|
|
|
108
|
-
`export` installs the pinned
|
|
196
|
+
`export` installs the pinned servers into mcp-twake-ai's private folder and writes `mcpServers.json` (Claude Desktop, Cursor, Windsurf, Cline, Gemini CLI…), `vscode-mcp.json`, `hermes.yaml`, `codex.toml`, `claude-code.sh` and one `<service>.env` per service, with a README saying where each goes. No file holds a secret.
|
|
197
|
+
|
|
198
|
+
### Tokens for your own MCP configuration
|
|
199
|
+
|
|
200
|
+
`setup` and `export` write everything for you. To configure a Twake.ai MCP server by hand, install `mcp-twake-ai` for good (`npm install -g mcp-twake-ai`), sign in, and give the server its token command, with the absolute path of `mcp-twake-ai` (some agents, such as Claude Desktop started from the Finder, do not see your `PATH`):
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
mcp-twake-ai login --email jane.doe@example.com
|
|
204
|
+
claude mcp add twake-project --scope user \
|
|
205
|
+
-e TWAKE_PROJECT_URL=https://projects.example.com \
|
|
206
|
+
-e "TWAKE_PROJECT_TOKEN_COMMAND=$(command -v mcp-twake-ai) token project" \
|
|
207
|
+
-e TWAKE_PROJECT_OIDC_ISSUER=https://sso.example.com/ \
|
|
208
|
+
-- npx -y mcp-twake-project
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
`mcp-twake-ai token <mail|dav|space|project>` prints `{"access_token": "...", "expires_at": <epoch s>}`. It serves the cached token while it is valid for more than 60 seconds, and otherwise renews it under a lock shared by every process, so several servers in several agents never spend the same refresh token twice. When the session has expired, it says to run `mcp-twake-ai login`.
|
|
109
212
|
|
|
110
213
|
## Files
|
|
111
214
|
|
|
112
|
-
| What
|
|
113
|
-
|
|
114
|
-
| Configuration (no secret)
|
|
115
|
-
| Refresh token
|
|
116
|
-
| Cached access tokens
|
|
117
|
-
| Journal (steps and errors, secrets masked) | `~/.local/state/twake-ai/twake-ai.log`
|
|
215
|
+
| What | Where (Linux, macOS) |
|
|
216
|
+
| ------------------------------------------ | ----------------------------------------------------------------------------------------- |
|
|
217
|
+
| Configuration (no secret) | `~/.config/twake-ai/config.json` |
|
|
218
|
+
| Refresh token | the OS keychain, service `twake-ai`; otherwise `~/.config/twake-ai/secrets.json` (`0600`) |
|
|
219
|
+
| Cached access tokens | `~/.cache/twake-ai/tokens/` (`0600`) |
|
|
220
|
+
| Journal (steps and errors, secrets masked) | `~/.local/state/twake-ai/twake-ai.log` |
|
|
118
221
|
|
|
119
222
|
On Windows: `%APPDATA%\twake-ai` and `%LOCALAPPDATA%\twake-ai`. `TWAKE_AI_HOME` groups everything under one directory.
|
|
120
223
|
|
|
121
|
-
##
|
|
224
|
+
## Security
|
|
122
225
|
|
|
123
|
-
|
|
226
|
+
Sign-in with PKCE, the session in the OS keychain, no secret in your agents' files, tokens sent only to HTTPS servers of your own domain, and every write approved by you. [SECURITY.md](SECURITY.md) details the security model and how to report a vulnerability privately.
|
|
124
227
|
|
|
125
228
|
## Development
|
|
126
229
|
|
|
@@ -131,8 +234,18 @@ npm run typecheck
|
|
|
131
234
|
npm run build # then: node build/bin.js
|
|
132
235
|
```
|
|
133
236
|
|
|
237
|
+
`LIVE_EMAIL=jane.doe@example.com node scripts/live.mjs` signs in to a real account in a temporary folder, checks each backend and lists the calendars through the calendar's MCP server, then signs out and makes sure the session is revoked. [`docs/manual-checklist.md`](docs/manual-checklist.md) is the checklist to run in each agent.
|
|
238
|
+
|
|
239
|
+
## Contributing
|
|
240
|
+
|
|
241
|
+
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).
|
|
242
|
+
|
|
134
243
|
## License
|
|
135
244
|
|
|
136
245
|
Licensed under the **GNU Affero General Public License v3.0** ([AGPL-3.0](LICENSE)).
|
|
137
246
|
|
|
138
247
|
Copyright © 2026 [LINAGORA](https://linagora.com)
|
|
248
|
+
|
|
249
|
+
## About
|
|
250
|
+
|
|
251
|
+
`mcp-twake-ai` 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>.
|
package/build/catalog.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
|
+
import { isServiceId, SERVICE_IDS } from './broker.js';
|
|
2
3
|
import { TwakeAiError } from './errors.js';
|
|
3
4
|
import { checkAgentId, isSafeDeviceId } from './grants.js';
|
|
4
5
|
/**
|
|
@@ -6,7 +7,7 @@ import { checkAgentId, isSafeDeviceId } from './grants.js';
|
|
|
6
7
|
* These versions run *_TOKEN_COMMAND through the system shell, so they work on Windows too.
|
|
7
8
|
*/
|
|
8
9
|
export const CATALOG = {
|
|
9
|
-
mail: { name: 'mcp-twake-mail', version: '4.
|
|
10
|
+
mail: { name: 'mcp-twake-mail', version: '4.2.0', approval: 'JMAP' },
|
|
10
11
|
dav: { name: 'mcp-twake-dav', version: '4.2.1', approval: 'DAV' },
|
|
11
12
|
drive: { name: 'mcp-twake-drive', version: '0.4.1', approval: 'TWAKE_DRIVE' },
|
|
12
13
|
chat: { name: 'mcp-twake-chat', version: '0.6.1', approval: 'MATRIX' },
|
|
@@ -46,9 +47,29 @@ export function detectLanguage(env, locale = Intl.DateTimeFormat().resolvedOptio
|
|
|
46
47
|
export function systemTimezone() {
|
|
47
48
|
return Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC';
|
|
48
49
|
}
|
|
49
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* The one folder where Mail saves attachments, and where Drive and Chat download files and take the ones they upload:
|
|
52
|
+
* an attachment kept by Mail can go to the Drive or a room without passing through the model. `~` is the home folder.
|
|
53
|
+
*/
|
|
54
|
+
export const FILES_FOLDER = '~/Downloads/Twake';
|
|
55
|
+
/**
|
|
56
|
+
* The environment of one MCP server for one agent: URLs, token command, language, time zone, agent-specific settings,
|
|
57
|
+
* then what the user added for this service (`setup --env 'dav.DAV_DEFAULT_CALENDAR=Jane Doe'`), which has the last word.
|
|
58
|
+
*/
|
|
50
59
|
export function serviceEnv(service, agent, ctx) {
|
|
51
60
|
checkAgentId(agent);
|
|
61
|
+
const extra = ctx.config.env?.[service] ?? {};
|
|
62
|
+
// a config.json edited by hand must not send a token to another server, run code in the server, nor send a file out
|
|
63
|
+
for (const [name, value] of Object.entries(extra)) {
|
|
64
|
+
const refusal = EXTRA_ENV_NAME.test(name) ? (envNameRefusal(name, service) ?? envValueRefusal(name, value)) : `${name} is not an upper-case variable name`;
|
|
65
|
+
if (refusal) {
|
|
66
|
+
throw new TwakeAiError('unsupported', `${ctx.paths.configFile} sets ${name} for ${service}: ${refusal}. Remove it from ${ctx.paths.configFile}.`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return { ...builtinServiceEnv(service, agent, ctx), ...extra };
|
|
70
|
+
}
|
|
71
|
+
/** The environment mcp-twake-ai builds itself, before the user's own variables */
|
|
72
|
+
function builtinServiceEnv(service, agent, ctx) {
|
|
52
73
|
const { config } = ctx;
|
|
53
74
|
const env = config.environment;
|
|
54
75
|
const common = { USER_LANGUAGE: ctx.language, USER_TIMEZONE: ctx.timezone };
|
|
@@ -60,7 +81,13 @@ export function serviceEnv(service, agent, ctx) {
|
|
|
60
81
|
const url = env.services.mail?.url;
|
|
61
82
|
if (!url)
|
|
62
83
|
throw notFound('Twake Mail (JMAP) server');
|
|
63
|
-
return {
|
|
84
|
+
return {
|
|
85
|
+
JMAP_SESSION_URL: url,
|
|
86
|
+
JMAP_AUTH_METHOD: 'command',
|
|
87
|
+
JMAP_TOKEN_COMMAND: tokenCommand('mail', undefined, ctx),
|
|
88
|
+
JMAP_DOWNLOAD_DIR: FILES_FOLDER,
|
|
89
|
+
...common,
|
|
90
|
+
};
|
|
64
91
|
}
|
|
65
92
|
case 'dav': {
|
|
66
93
|
const url = env.services.dav?.url;
|
|
@@ -81,7 +108,8 @@ export function serviceEnv(service, agent, ctx) {
|
|
|
81
108
|
const instance = env.cozy.instance;
|
|
82
109
|
if (!instance || !config.drive)
|
|
83
110
|
throw new TwakeAiError('login_required', 'Twake Drive is not connected: run `mcp-twake-ai login --drive`.');
|
|
84
|
-
|
|
111
|
+
// its upload folder defaults to its download folder
|
|
112
|
+
return { TWAKE_DRIVE_URL: instance, TWAKE_DRIVE_TOKEN_COMMAND: tokenCommand('drive', undefined, ctx), TWAKE_DRIVE_DOWNLOAD_DIR: FILES_FOLDER, ...common };
|
|
85
113
|
}
|
|
86
114
|
case 'chat': {
|
|
87
115
|
const device = config.chat?.[agent];
|
|
@@ -94,6 +122,8 @@ export function serviceEnv(service, agent, ctx) {
|
|
|
94
122
|
MATRIX_USER_ID: device.userId,
|
|
95
123
|
MATRIX_TOKEN_COMMAND: tokenCommand('chat', agent, ctx),
|
|
96
124
|
MATRIX_HOMESERVER_URL: env.matrix.homeserver,
|
|
125
|
+
// its upload folder defaults to its download folder
|
|
126
|
+
MATRIX_DOWNLOAD_DIR: FILES_FOLDER,
|
|
97
127
|
...(env.matrix.tom ? { TOM_URL: env.matrix.tom } : {}),
|
|
98
128
|
MATRIX_E2EE_RECOVERY: 'tom',
|
|
99
129
|
// the end-to-end encryption store belongs to one device: a new device gets a new store
|
|
@@ -115,4 +145,126 @@ export function serviceEnv(service, agent, ctx) {
|
|
|
115
145
|
}
|
|
116
146
|
}
|
|
117
147
|
}
|
|
148
|
+
/** An environment variable name a user may set: upper case, digits and underscores, as the servers document them */
|
|
149
|
+
const EXTRA_ENV_NAME = /^[A-Z][A-Z0-9_]*$/;
|
|
150
|
+
/**
|
|
151
|
+
* A variable a user may not set: it names a server, how to sign in to it, or whose account it is — the account's discovery says so.
|
|
152
|
+
* JMAP_DEFAULT_FROM is accepted on purpose: the send tools already take a sender per message, and a user may send from one of
|
|
153
|
+
* their aliases. It does not identify the account as MATRIX_USER_ID does, from whose domain Chat also finds its ToM server.
|
|
154
|
+
*/
|
|
155
|
+
const SERVER_ENV_NAME = /(^|_)(URL|URI|HOMESERVER|AUTH_METHOD|OIDC|HREF_PREFIX|ORGANIZER_EMAIL|USERNAME|USER_ID)($|_)/;
|
|
156
|
+
/** A variable a user may not set: it carries a secret, which mcp-twake-ai keeps in the keychain */
|
|
157
|
+
const SECRET_ENV_NAME = /TOKEN|SECRET|PASSWORD|PASSWD|PASSPHRASE|CREDENTIAL|(^|_)KEYS?($|_)/;
|
|
158
|
+
/** The only logging variable the servers read */
|
|
159
|
+
const LOGGING_ENV_NAME = /^LOG_LEVEL$/;
|
|
160
|
+
/** A variable mcp-twake-ai manages itself for the agent: one encryption store per device */
|
|
161
|
+
const MANAGED_ENV_NAME = /^MATRIX_STORE_DIR$/;
|
|
162
|
+
/**
|
|
163
|
+
* A variable that lifts the approval of writes: `client` mode, or tools that write without asking. --env applies to every
|
|
164
|
+
* agent that runs the service, so a pasted one would let every agent write without you. *_APPROVAL_TIMEOUT_MS stays free:
|
|
165
|
+
* it changes how long the prompt waits, not whether it is shown.
|
|
166
|
+
*/
|
|
167
|
+
const APPROVAL_ENV_NAME = /_APPROVAL(_EXEMPT)?$/;
|
|
168
|
+
/** A folder the servers write files into or read them from: FILES_FOLDER, shared by Mail, Drive and Chat */
|
|
169
|
+
const FILES_ENV_NAME = /_(DOWNLOAD|UPLOAD)_DIR$/;
|
|
170
|
+
/**
|
|
171
|
+
* The signature Mail appends to every mail it writes: a file directly in ~/.mcp-twake-mail/, the folder its README uses.
|
|
172
|
+
* The server only expands a leading `~`, so no sub-folder, no `..` and no hidden file can lead elsewhere.
|
|
173
|
+
*/
|
|
174
|
+
const SIGNATURE_PATH = /^~[\\/]\.mcp-twake-mail[\\/][^.\\/][^\\/]*$/;
|
|
175
|
+
/** Any other variable naming a file the server reads: a pasted path would give it any file of this computer */
|
|
176
|
+
const FILE_ENV_NAME = /_(PATH|FILE)$/;
|
|
177
|
+
/** The prefix of a service's own variables: DAV_ for Twake Calendar, JMAP_ for Twake Mail… */
|
|
178
|
+
export function serviceEnvPrefix(service) {
|
|
179
|
+
return `${CATALOG[service].approval}_`;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Why a variable name may not be set, if it may not
|
|
183
|
+
*
|
|
184
|
+
* Only the variables of the server itself (`DAV_…` for Twake Calendar), the `USER_…` ones and
|
|
185
|
+
* `LOG_LEVEL` are accepted: listing the dangerous names of a process environment is a losing game
|
|
186
|
+
* (LD_PRELOAD, DYLD_INSERT_LIBRARIES, COMSPEC, TWAKE_AI_HOME, NODE_OPTIONS…), and no server has a
|
|
187
|
+
* business with any of them.
|
|
188
|
+
*
|
|
189
|
+
* @param name - the variable name, as it would be given to a server
|
|
190
|
+
* @param service - the service whose environment receives it
|
|
191
|
+
* @returns the reason, or undefined when the name is free
|
|
192
|
+
*/
|
|
193
|
+
export function envNameRefusal(name, service) {
|
|
194
|
+
const prefix = serviceEnvPrefix(service);
|
|
195
|
+
if (!name.startsWith(prefix) && !name.startsWith('USER_') && !LOGGING_ENV_NAME.test(name)) {
|
|
196
|
+
return `${name} is not a variable of ${CATALOG[service].name}: only ${prefix}…, USER_… and LOG_LEVEL may be set`;
|
|
197
|
+
}
|
|
198
|
+
if (MANAGED_ENV_NAME.test(name))
|
|
199
|
+
return `${name} is managed by mcp-twake-ai, which keeps one store per device`;
|
|
200
|
+
if (APPROVAL_ENV_NAME.test(name)) {
|
|
201
|
+
return `${name} would lift the approval of writes in every agent that runs ${CATALOG[service].name}: each write is approved by you first`;
|
|
202
|
+
}
|
|
203
|
+
// the reason that matters most comes first: JMAP_TOKEN_PATH is a secret before being a file
|
|
204
|
+
if (SECRET_ENV_NAME.test(name))
|
|
205
|
+
return `${name} may carry a secret: secrets stay in the keychain, and every server gets its own token command`;
|
|
206
|
+
if (FILES_ENV_NAME.test(name)) {
|
|
207
|
+
return `${name} is managed by mcp-twake-ai: Mail, Drive and Chat share one folder for files, ${FILES_FOLDER}`;
|
|
208
|
+
}
|
|
209
|
+
// the signature is the one file accepted, from its own folder: envValueRefusal() checks where
|
|
210
|
+
if (FILE_ENV_NAME.test(name) && name !== 'JMAP_SIGNATURE_PATH')
|
|
211
|
+
return `${name} names a file the server reads: a pasted path would give it any file of this computer`;
|
|
212
|
+
if (SERVER_ENV_NAME.test(name))
|
|
213
|
+
return `${name} names a server, how to sign in to it, or whose account it is: those come from the account, not from the user`;
|
|
214
|
+
return undefined;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Why a value may not be set, if it may not: a variable that names a file the server reads and sends out
|
|
218
|
+
*
|
|
219
|
+
* @param name - a name envNameRefusal() accepts
|
|
220
|
+
* @param value - its value, not empty
|
|
221
|
+
* @returns the reason, or undefined when the value is free
|
|
222
|
+
*/
|
|
223
|
+
export function envValueRefusal(name, value) {
|
|
224
|
+
if (name === 'JMAP_SIGNATURE_PATH' && !SIGNATURE_PATH.test(value)) {
|
|
225
|
+
return `${name} goes out in every mail: it must name a file directly in ~/.mcp-twake-mail/, such as ~/.mcp-twake-mail/signature.md`;
|
|
226
|
+
}
|
|
227
|
+
return undefined;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Read `--env <service>.<VARIABLE>=<value>` options. An empty value (`dav.DAV_DEFAULT_CALENDAR=`) forgets the variable.
|
|
231
|
+
*
|
|
232
|
+
* @param values - one option per variable, as given on the command line
|
|
233
|
+
* @returns the variables to set and to remove, per service
|
|
234
|
+
* @throws TwakeAiError('usage') when an option is malformed, names an unknown service, or would set a reserved variable
|
|
235
|
+
*/
|
|
236
|
+
export function parseEnvOption(values) {
|
|
237
|
+
// the last option given for a variable wins, as on a command line
|
|
238
|
+
const decisions = new Map();
|
|
239
|
+
for (const raw of values) {
|
|
240
|
+
const equals = raw.indexOf('=');
|
|
241
|
+
const target = equals < 0 ? '' : raw.slice(0, equals);
|
|
242
|
+
const value = equals < 0 ? '' : raw.slice(equals + 1);
|
|
243
|
+
const dot = target.indexOf('.');
|
|
244
|
+
const service = dot < 0 ? '' : target.slice(0, dot);
|
|
245
|
+
const name = dot < 0 ? '' : target.slice(dot + 1);
|
|
246
|
+
if (!isServiceId(service) || !EXTRA_ENV_NAME.test(name)) {
|
|
247
|
+
throw new TwakeAiError('usage', `--env takes <service>.<VARIABLE>=<value>, with a service among ${SERVICE_IDS.join(', ')}, and an upper-case variable name, not "${raw}".`);
|
|
248
|
+
}
|
|
249
|
+
// an empty value forgets the variable, which needs no other check
|
|
250
|
+
if (value === '') {
|
|
251
|
+
decisions.set(`${service}.${name}`, { service, name });
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
if (/[\r\n\0]/.test(value))
|
|
255
|
+
throw new TwakeAiError('usage', `--env ${service}.${name}: a value cannot hold a line break.`);
|
|
256
|
+
const refusal = envNameRefusal(name, service) ?? envValueRefusal(name, value);
|
|
257
|
+
if (refusal)
|
|
258
|
+
throw new TwakeAiError('usage', `--env ${service}.${name}: ${refusal}.`);
|
|
259
|
+
decisions.set(`${service}.${name}`, { service, name, value });
|
|
260
|
+
}
|
|
261
|
+
const change = { set: {}, unset: {} };
|
|
262
|
+
for (const { service, name, value } of decisions.values()) {
|
|
263
|
+
if (value === undefined)
|
|
264
|
+
change.unset[service] = [...(change.unset[service] ?? []), name];
|
|
265
|
+
else
|
|
266
|
+
change.set[service] = { ...(change.set[service] ?? {}), [name]: value };
|
|
267
|
+
}
|
|
268
|
+
return change;
|
|
269
|
+
}
|
|
118
270
|
//# sourceMappingURL=catalog.js.map
|
package/build/catalog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAkB,MAAM,aAAa,CAAC;AAEvE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAU3D;;;GAGG;AACH,MAAM,CAAC,MAAM,OAAO,GAAkC;IACpD,IAAI,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE;IACpE,GAAG,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK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