mcp-twake-chat
OfficialProvides tools for interacting with Matrix Client-Server API homeservers, including Twake Chat, to list rooms, read messages and threads, find unread messages and mentions, search users and profiles, download attachments, manage drafts, and optionally send/react/edit/redact messages and files, including in end-to-end encrypted rooms.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
mcp-twake-chat
Give your AI assistant secure access to Twake Chat, the Matrix messaging of the Twake.ai Digital Workplace, end-to-end encrypted rooms included.
What is it?
mcp-twake-chat is a Model Context Protocol (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 chat to the assistant as 24 tools: rooms, messages, threads, unread messages, mentions, full-text search (encrypted rooms included), people, attachments, drafts and, when you allow it, sending and room management.
It speaks the open Matrix Client-Server API through matrix-js-sdk and its Rust cryptography, so it reads end-to-end encrypted rooms like any Matrix client. It works with Twake Chat and with any Matrix homeserver (Synapse, Conduit…); the Twake-specific extras (company directory, recovery vault) come from the ToM server.
Related MCP server: mcp-server-mattermost
Part of Twake.ai
Twake.ai is the truly open source and sovereign Digital Workplace developed by LINAGORA: 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.
MCP server | Twake.ai service | Protocol |
Twake Mail | JMAP | |
Twake Calendar and contacts | CalDAV / CardDAV | |
Twake Drive | cozy-stack API | |
mcp-twake-chat (this project) | Twake Chat | Matrix |
Twake Space (team spaces) | Twake Space API | |
Twake Project (projects, boards, tasks) | Twake Project API |
What it brings
Catch up: "What did I miss on the chat since yesterday? Who mentioned me this week?"
Summarise: "Summarise the project room for the last seven days."
Find: "What did Alice say about the contract?", "Find the messages about the Atlas budget since September", even in end-to-end encrypted rooms that the homeserver cannot search; "Who is Bob Martin, and do we have a direct conversation?"
Prepare answers safely: "Draft a reply to Alice": the draft lands in your private Drafts room, never in the conversation.
Encrypted rooms: the server is a real Matrix device of your account, verified by cross-signing, and restores your key backup, so encrypted history is readable as in a new Twake Chat session.
One approval for a series of actions: before several actions (several messages, several invitations), 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).From the command line:
npx mcp-twake-chat call <tool>andnpx mcp-twake-chat toolsrun 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 (--iasks 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).One server for several clients: in the shared HTTP mode, several clients share one server, and so one device: the server publishes its URL and token in a state file (
MCP_HTTP_STATE_FILE), and stops onPOST /mcp/shutdownwith its token or once idle (MCP_HTTP_EXIT_WHEN_IDLE_MS). mcp-twake-ai runs one Chat server per agent this way (see Shared mode under Other options).Sovereignty: the server runs next to your assistant and talks directly to your homeserver.
Features
24 MCP tools
Category | Tools |
Account |
|
Rooms |
|
Messages |
|
Search |
|
Invitations |
|
Attachments |
|
People |
|
Drafts |
|
Write ⚠️ |
|
Rooms ⚠️ |
|
Destructive ⚠️ |
|
Approval |
|
⚠️ = acts in your name, visible to other people. Read tools carry readOnlyHint; create_draft is closed-world (openWorldHint: false); write tools carry openWorldHint, and redact_message and leave_room destructiveHint.
Every action in your name is approved by you first. Before any ⚠️ tool acts, in a direct message, a group room or a space, the server itself shows you the exact action through MCP elicitation (see Prior approval) and acts only on your explicit OK. Reading, searching, downloading attachments and drafts need no approval.
Highlights
End-to-end encryption: Rust crypto (WASM) with a persistent store (IndexedDB emulated on SQLite, encrypted with a 32-byte key kept in a
0600file). On first start the server unlocks your secret storage with your recovery key, imports the cross-signing keys, signs its own device and restores the server key backup; later starts use the local store only.Recovery key: read from the Twake ToM vault, where Twake Chat stores it (
MATRIX_E2EE_RECOVERY=tom), or from a file (key), or not at all (off: only messages received after the first start are readable).One device, one process: the crypto store is locked by the running process. To share one device between several assistants, run the server once with the HTTP transport and point every client to it.
Unread messages computed like a client: from your read receipt and read marker, because servers often return no notification count when push rules mute rooms.
Mentions in encrypted rooms: found client-side (
m.mentions, or your name in the text), which server-side notifications cannot see.Rooms by name: every tool accepts a room id, an alias, a DM partner id or a name, case and accents ignored; ambiguous names return the candidates.
No password, no OAuth flow inside: short-lived access tokens come from an external broker you control.
Search in encrypted rooms
The homeserver never sees the text of end-to-end encrypted messages, so it cannot search them. Like Element's desktop search, the server keeps a local full-text index (SQLite FTS5, built into Node) of the messages it can decrypt: new messages as they arrive, messages read through the tools, and a background backfill of the history (MATRIX_SEARCH_BACKFILL_DAYS, one year by default). After a restart it catches up on the messages received in the meantime. search_messages combines this index for encrypted rooms with the homeserver search for unencrypted rooms, checks that local hits were not deleted since they were indexed, and reports how complete the index is. The index holds message text in clear: it is stored next to the crypto store with 0600 permissions (see SECURITY.md), and MATRIX_SEARCH_INDEX=off disables it.
Requirements
Node.js >= 22.13 (built-in
node:sqlite)A Matrix account on Twake Chat or any homeserver; key backup and secret storage set up for encrypted history
An MCP client
Installation
Quick start with mcp-twake-ai (recommended)
npx mcp-twake-ai setupmcp-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
git clone https://github.com/linagora/mcp-twake-chat.git
cd mcp-twake-chat
npm install
npm run build # then: node build/index.jsConfiguration
Authentication
The server never logs in by itself: it needs a Matrix access token and the device id it belongs to (the encryption store is bound to that device).
Method | Variables |
Token command (recommended) |
|
Static token (development) |
|
MATRIX_TOKEN_COMMAND prints {"access_token": "...", "expires_at": <epoch seconds>, "device_id": "...", "user_id": "..."} and is run again shortly before expiry. Your broker owns the login and the refresh-token rotation.
For Twake Chat, mcp-twake-ai is that broker, with one device per agent: mcp-twake-ai login --chat --agent <id> signs that agent's device in once (mcp-twake-ai setup does it for you), then MATRIX_TOKEN_COMMAND="/usr/local/bin/mcp-twake-ai token chat --agent <id>" prints the JSON above for that device. 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).
Any other broker printing this JSON works. With Synapse's SSO, a broker typically:
sends the user once to
/_matrix/client/v3/login/sso/redirect/<idp>?redirectUrl=…;exchanges the returned
loginTokenwithPOST /_matrix/client/v3/login(type: m.login.token,refresh_token: true, a clearinitial_device_display_name);refreshes with
POST /_matrix/client/v3/refreshunder a lock and prints the JSON above.
MATRIX_CREDENTIALS_FILE points to a file of KEY=VALUE lines (MATRIX_ACCESS_TOKEN=…, MATRIX_DEVICE_ID=…) to keep secrets out of the client configuration.
Prior approval
With MATRIX_APPROVAL=elicit (the default), every write tool sends the MCP client an elicitation request before it acts, for instance:
Twake Chat: Send a message
As: Jane DOE (@jane:example.com) (your account)
Room: Project X (group room, 12 members, end-to-end encrypted)
In reply to: Bob DURAND, 2026-11-01 18:02: « the contract is ready »
Text: Great news, thanks Bob!
Ref. 3f9a1c · Accept to do it now, refuse to cancel.The prompt names the room and its kind (direct message, group room, space) with its member count, quotes the message being answered, reacted to, edited or deleted, and shows the exact text, file or invitees.
The server acts only on accept. A refusal, a dismissal, a timeout (
MATRIX_APPROVAL_TIMEOUT_MS, 10 minutes) or an error sends nothing, and the tool tells the assistant not to retry.A client without elicitation support gets an error and nothing is sent. Set
MATRIX_APPROVAL=clientonly if your MCP client asks you to confirm every write tool itself.USER_LANGUAGE=frwrites the prompts in French.Over HTTP the server keeps one MCP session per client (
Mcp-Session-Id), so the prompt sent during a tool call reaches the right client and its answer comes back. Idle sessions are closed after 6 hours; the client then initializes again.
Other options
Variable | Description | Default |
| Client-Server API URL | discovered from |
| Twake ToM server (directory, profiles, recovery vault) | discovered ( |
|
|
|
| Private directory of the encrypted crypto store |
|
| Key encrypting the store (created on first start, |
|
| Name of the private drafts room |
|
| The only folder |
|
| The only folder |
|
|
|
|
| How long an approval prompt waits for your answer |
|
| Language of the approval prompts, |
|
|
|
|
|
|
|
| History indexed in the background, in days ( |
|
|
|
|
| HTTP listen address (keep it on loopback); port |
|
| File holding a bearer token required from HTTP clients | none |
| Shared mode: once the store is held and the port listens, the server writes this file (mode 600, folder 700) with its pid, URL, bearer token, account and device, and removes it when it stops. Without | none |
| Stop once no MCP session has been open for this long (a request without a session does not count). In the shared mode, a session whose client closed its event stream without ending it (killed) is closed after 1 minute without a request | none |
| IANA time zone for displayed and parsed dates | system |
|
|
|
Shared mode. This is the mode mcp-twake-ai uses to share one Chat server between the clients of an agent. With MCP_TRANSPORT=http, MCP_HTTP_PORT=0 and MCP_HTTP_STATE_FILE, a client reads the state file, checks the server with its token, and joins it. POST /mcp/shutdown with the bearer token answers 202 and stops the server as SIGTERM does (store closed, state file removed); it exists only with a token, and is refused from another host or from a web page (an Origin header). GET /mcp/proof?nonce=<32 to 128 hex characters> answers {"proof": HMAC-SHA256(token, "twake-chat-proof:" + nonce + ":" + port), "pid": …} (port: the port the server listens on) without asking for the token: loopback is shared by every account of the machine, so a client checks that what listens on the port holds the token before it sends it there (same Host and Origin rules). When the device store is already held by another living process, the server exits with code 75 (EX_TEMPFAIL): another start won, join it.
Check a configuration with node build/index.js check: it connects, prints the account, device, encryption state and room counts, and exits.
Use it with your assistant
Hermes Agent (shared HTTP daemon)
Run the server once (for example as a systemd user service with MCP_TRANSPORT=http and MCP_HTTP_TOKEN_FILE), put the token in Hermes' .env as TWAKE_CHAT_MCP_TOKEN, then:
mcp_servers:
twake_chat:
url: http://127.0.0.1:3995/mcp
headers:
Authorization: "Bearer ${TWAKE_CHAT_MCP_TOKEN}"
timeout: 420 # longer than the approval wait
elicitation:
enabled: true
timeout: 300Hermes 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). Start the daemon with MATRIX_APPROVAL_TIMEOUT_MS=330000 so that it waits a little longer than Hermes. For an assistant that must never act in your name, keep drafts only:
tools:
exclude: [send_message, react, edit_message, redact_message, send_file, join_room, leave_room, create_room, invite_user]Claude Code / Claude Desktop (stdio)
claude mcp add twake-chat --scope user \
-e MATRIX_USER_ID=@jane:example.com \
-e "MATRIX_TOKEN_COMMAND=/usr/local/bin/mcp-twake-ai token chat --agent claude-code" \
-- node /path/to/mcp-twake-chat/build/index.jsDo not configure the same device in two clients at once in stdio mode: the second one is refused by the store lock. Use the HTTP daemon instead, or give each client its own device (mcp-twake-ai login --chat --agent <id>).
From the command line
Every tool of this server can be called from a terminal or a script, with the same configuration (MATRIX_* variables) as the server:
npx mcp-twake-chat tools # one line per tool
npx mcp-twake-chat call list_rooms
npx mcp-twake-chat call send_message --json @message.json--arg key=valueis converted to the type the tool giveskey;--jsontakes the whole arguments object (@file, or-for stdin). The result goes to stdout (--json-outputfor 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 (
--iasks first). Started by an agent (CLAUDECODEorHERMES_HOMEset), 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, withnpx mcp-twake-chat 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.jsonon 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.While another mcp-twake-chat uses the same device,
callcannot open its store: usenpx mcp-twake-ai call chat …, which goes through the running server, or pointTWAKE_MCP_CLI_SERVERat it.With mcp-twake-ai,
npx mcp-twake-ai call chat …does the same with your Twake.ai sign-in.
Approving a series of writes at once
Before a series of actions (several messages, several invitations), 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 (over HTTP, one session), and is forgotten when that session ends. With MATRIX_APPROVAL=client, there is no batch.
Recommended safe configuration
Keep
MATRIX_APPROVAL=elicit(the default): every action in your name waits for your OK on the exact room and text, whatever the assistant decides. For an assistant that must never act in your name, exclude the write tools (drafts only, example above).MATRIX_SEND_SCOPE=dmadditionally keeps it out of group rooms.Chat messages are written by other people, possibly from other servers through federation: treat them as untrusted input (prompt injection). The tool descriptions say so to the model.
The access token gives access to your whole history once the recovery key is fetched from the ToM vault: protect the broker's files (
0600), never log tokens, and revoke the device from Twake Chat's session list if in doubt.Keep the HTTP transport on loopback with a bearer token.
See SECURITY.md.
Usage examples
"What's unread on the chat? Summarise by room."
"Who mentioned me since Friday?"
"Read the last 50 messages of the Atlas project room and list the decisions."
"Find Bob Martin in the directory."
"Draft an answer to Alice proposing Tuesday at 10."
"Download the PDF Bob posted in the Atlas room and summarise it."
"Search the chat for what was said about the Atlas budget since September."
"Do I have pending invitations?"
Troubleshooting
Symptom | Fix |
| Another server holds this device: stop it, or connect to it over HTTP. |
| Your MCP client does not support elicitation: use one that does, or |
| The prompt timed out or nobody could answer (cron, one-shot query): nothing was sent. |
| The broker must print the device id that owns the token. |
| The room key is in no backup you can open (messages older than your key backup, or never backed up). A new Twake Chat session has the same limit. |
| No recovery key in the ToM vault, or it does not unlock the secret storage: use |
| Set |
| The background backfill of the history is running (see |
An old encrypted message is not found | It could not be decrypted when indexed (no key in your backup), or it is older than |
Development
npm install
npm run build
npm test # Vitest, no real server needed
node build/index.js check
node scripts/smoke.mjs # live read-only tour of the tools against your account (counts only)
LIVE_ROOM='!room:server' node scripts/live-write.mjs # write tools, only in a private room where you are alone
LIVE_ROOM='!room:server' node scripts/live-search.mjs # search, invitations, create and leave a throwaway roomContributing
Contributions are welcome: read CONTRIBUTING.md and our Code of Conduct. Report vulnerabilities privately as described in SECURITY.md. Release notes are in CHANGELOG.md.
License
Licensed under the GNU Affero General Public License v3.0 (AGPL-3.0).
Copyright © 2026 LINAGORA
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Messaging tools for AI agents: send messages, manage chats, groups and channels.
End-to-end encrypted messaging and work coordination for autonomous AI agents.
Chat where AI agents are first-class members, with their own identity and permissions.
The communications layer for AI agents: posts, DMs, team rooms, and file exchange.
Related MCP Servers
- AlicenseAqualityDmaintenanceConnects Claude with Matrix/Element to read and search messages across rooms. Enables listing rooms, viewing room information, retrieving message history, and searching conversation content from your Matrix account.42MIT
- AlicenseAqualityAmaintenanceLets AI assistants read, search, and post messages in Mattermost channels, manage threads, reactions, files, and users with 38 tools.391,535 PyPI54MIT
- AlicenseAqualityDmaintenanceEnables AI assistants to interact with Matrix, the open decentralized communication protocol, allowing them to send and read messages, manage rooms, and perform other Matrix operations through natural language.1619 PyPI3MIT
- AlicenseAqualityDmaintenanceConnects AI assistants to Linagora's Twake Workplace, enabling interaction with chat, email, and drive services through natural language.10AGPL 3.0