Getting Started
Prerequisites
You need:
- Python 3.12+
uv- an MCP client such as Claude Code or Codex
- a Matrix homeserver account
Installation
Login
Matrix SSO
If the homeserver advertises multiple SSO providers, list them:
Then pass the provider ID explicitly:
SSO over SSH or on a Headless Machine
The SSO flow starts a temporary callback server on the machine running matrix-mcp and waits for the browser to be redirected to it.
If that machine is remote — an SSH session, a VM, a container — a browser on your local machine cannot reach the callback address printed in the SSO URL.
Pin the callback port on the remote machine:
While that command waits, forward the port from your local machine in a second terminal:
Open the printed SSO URL in your local browser.
After login, the homeserver redirects to http://127.0.0.1:8765/callback, which SSH forwards to the waiting command on the remote machine.
If port forwarding is not an option, print the SSO URL with a placeholder redirect URL:
Open that URL in any browser and log in.
The final redirect to http://127.0.0.1:8765/callback?loginToken=... fails to load — that is expected.
Copy the loginToken value from the browser address bar and exchange it on the remote machine right away (login tokens are single-use and expire within minutes):
If matrix-mcp is also installed on the machine with the browser, log in there:
Then copy the file printed by config-path to the path that matrix-mcp config-path prints on the remote machine, creating the directory if needed.
Encrypted rooms do not work with copied credentials: the device's encryption keys stay on the machine that logged in, and the remote machine refuses to publish new ones for the same device. Use one of the other methods when you need encrypted rooms on the remote machine.
Existing Matrix Access Token
matrix-mcp auth token https://mindroom.chat @alice:mindroom.chat "$MATRIX_ACCESS_TOKEN" --device-id DEVICEID
Password Auth
End-to-End Encryption
SSO, password, and login-token logins create a new Matrix device for Matrix MCP and publish its encryption keys, so encrypted rooms work from the start.
auth token reuses the device that the access token belongs to; encryption then works only if no other client has published keys for that device.
Messages sent before the login cannot be decrypted unless you import room keys exported from another client:
See End-to-End Encryption for details.
Configure an MCP Client
The server runs over stdio and does not expose a local HTTP port during normal MCP operation.
Verify
Ask the MCP client to call matrix_whoami.
It should return the Matrix user and device saved by the login command.