Skip to main content

Matrix MCP

License CI PyPI Python Versions Docs MCP

MindRoom Logo

Local-first Matrix access for MCP clients.

Matrix MCP lets Claude Code and other MCP clients read and write Matrix rooms. It is intended to make MindRoom conversations available to local coding agents without giving hosted agents access to the local filesystem.

Install

uv tool install matrix-mcp

For local development:

uv sync --extra dev

Login

Matrix SSO:

matrix-mcp auth sso https://mindroom.chat

If the homeserver advertises multiple SSO providers, list their provider IDs:

matrix-mcp auth providers https://mindroom.chat

Then pass the provider ID explicitly:

matrix-mcp auth sso https://mindroom.chat --idp-id github

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 (for example over SSH), a browser on your local machine cannot reach the callback. Pin the callback port and forward it from the machine with your browser:

# on the remote machine
matrix-mcp auth sso https://mindroom.chat --callback-port 8765
# on your local machine, in a second terminal
ssh -N -L 8765:127.0.0.1:8765 remote-host

Then 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, use the manual flow described in the getting started guide with matrix-mcp auth sso-url and matrix-mcp auth login-token.

If your homeserver is behind an access gateway that requires extra request headers, pass them during login. They are stored with the Matrix credentials and reused by MCP tools:

matrix-mcp auth sso https://mindroom.chat \
  --header "X-Access-Client-Id: ..." \
  --header "X-Access-Client-Secret: ..."

If the gateway header is short-lived, store a command that prints the current header value instead. The command is re-run when Matrix MCP creates a client for tool calls:

matrix-mcp auth sso https://mindroom.chat \
  --header-command "X-Access-Token: access-gateway-cli token --app https://mindroom.chat"

For homeservers behind Cloudflare Access, matrix-mcp can configure the dynamic cf-access-token header for you. This uses the local cloudflared CLI to log in when needed during setup, then stores a command that reads the current token:

brew install cloudflared
matrix-mcp auth sso https://mindroom.chat --cloudflare-access

For other platforms, install cloudflared from Cloudflare's downloads page.

Existing Matrix access token:

matrix-mcp auth token https://mindroom.chat @alice:mindroom.chat "$MATRIX_ACCESS_TOKEN" --device-id DEVICEID

Password auth, when enabled by the homeserver:

matrix-mcp auth password https://mindroom.chat @alice:mindroom.chat

Credentials are stored in the user config directory reported by:

matrix-mcp config-path

Remove stored credentials:

matrix-mcp auth logout

Claude Code

Add the local MCP server:

claude mcp add matrix -- matrix-mcp serve

Codex

Add the local MCP server:

codex mcp add matrix -- matrix-mcp serve

The server runs over stdio. It does not expose a local HTTP port during normal MCP operation.

Tools

  • matrix_whoami: show the configured Matrix user/device.
  • matrix_list_rooms: list rooms joined by the authenticated user.
  • matrix_read_room_recent: read recent text events from a room.
  • matrix_read_thread: read a Matrix thread root and its recent text replies.
  • matrix_send_message: send a text message or local file, optionally as a Matrix thread reply.

Rooms and events returned by read/list tools include stable numeric id fields. Thread replies also include thread_ref, which is the numeric event ref of the thread root. Use these integers in later tool calls instead of copying raw Matrix IDs:

matrix_read_room_recent(room_id=1)
matrix_read_thread(room_id=1, thread_id=42)
matrix_send_message(room_id=1, body="reply", thread_id=42)

The tool instructions tell clients to prefer read tools first and only send messages when the user explicitly asks.

Development

uv run --extra dev pytest
uv run --extra dev ruff check .
uv run --extra dev ruff format --check .
uv run --extra dev mypy src tests
uv run --extra dev ty check
uv build

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

matrix_mcp-0.5.4.tar.gz (160.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

matrix_mcp-0.5.4-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

Details for the file matrix_mcp-0.5.4.tar.gz.

File metadata

  • Download URL: matrix_mcp-0.5.4.tar.gz
  • Upload date:
  • Size: 160.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for matrix_mcp-0.5.4.tar.gz
Algorithm Hash digest
SHA256 599d7af0174be2a8d143830801068d6d73753395229b4e2e135ff3aa8de21600
MD5 501c5b81d17c94a9857b6aceb3c1ab88
BLAKE2b-256 d6f511aa39452a032d55d18f17ca9b702c76dc7212cfa6f17c47b9669e26a497

See more details on using hashes here.

Provenance

The following attestation bundles were made for matrix_mcp-0.5.4.tar.gz:

Publisher: release.yml on mindroom-ai/matrix-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file matrix_mcp-0.5.4-py3-none-any.whl.

File metadata

  • Download URL: matrix_mcp-0.5.4-py3-none-any.whl
  • Upload date:
  • Size: 19.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for matrix_mcp-0.5.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d64da1bd5d9ef929bdf250bbe79402f55ab630b25f297810c098b7da1ad78855
MD5 7ccecd0ccadb87a6e08478c81ae265d8
BLAKE2b-256 f987ca20ada587e88381d7bdfb73689bee19ab7282200295da8d870b3f997787

See more details on using hashes here.

Provenance

The following attestation bundles were made for matrix_mcp-0.5.4-py3-none-any.whl:

Publisher: release.yml on mindroom-ai/matrix-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page