mcp-server-matrix
mcp-server-matrix
A Model Context Protocol (MCP) server for Matrix — the open, decentralized communication protocol.
Built on matrix-nio, this server lets any MCP-compatible AI assistant (Claude, OpenClaw, etc.) send and read messages, manage rooms, and interact with any Matrix homeserver (Synapse, Dendrite, Conduit).
Features
Tool | Description |
| Send a message (text, HTML, or Markdown) with optional reply |
| Read recent messages (with pagination) |
| Get messages filtered by date range |
| List all joined rooms |
| Room details — name, topic, members, encryption status |
| List joined members with display names and avatars |
| Unread and mention counts per room |
| List DM conversations with unread status |
| Send a DM (auto-creates room if needed) |
| User profile — display name, avatar |
| Join a room by ID or alias |
| Leave a room |
| Create a new room (with optional invites) |
| Invite a user to a room |
| React to a message with an emoji |
| Resolve |
Installation
pip install mcp-server-matrixOr with uv:
uvx mcp-server-matrixConfiguration
Set environment variables:
Variable | Required | Description |
| Yes | Homeserver URL (e.g. |
| Yes | Full user ID (e.g. |
| Yes* | Account password |
| Yes* | Access token (alternative to password) |
| No | Path for nio session store (default: |
| No | Log level: DEBUG, INFO, WARNING, ERROR (default: INFO) |
* Provide either MATRIX_PASSWORD or MATRIX_ACCESS_TOKEN.
Usage
Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"matrix": {
"command": "mcp-server-matrix",
"env": {
"MATRIX_HOMESERVER": "https://matrix.example.com",
"MATRIX_USER": "@bot:example.com",
"MATRIX_PASSWORD": "your-password"
}
}
}
}Claude Code
{
"mcpServers": {
"matrix": {
"command": "mcp-server-matrix",
"env": {
"MATRIX_HOMESERVER": "https://matrix.example.com",
"MATRIX_USER": "@bot:example.com",
"MATRIX_ACCESS_TOKEN": "syt_..."
}
}
}
}OpenClaw
Add to openclaw.json:
{
"mcp": {
"servers": {
"matrix": {
"command": "mcp-server-matrix",
"env": {
"MATRIX_HOMESERVER": "https://matrix.example.com",
"MATRIX_USER": "@bot:example.com",
"MATRIX_PASSWORD": "your-password"
}
}
}
}
}Direct (stdio)
export MATRIX_HOMESERVER=https://matrix.example.com
export MATRIX_USER=@bot:example.com
export MATRIX_PASSWORD=your-password
mcp-server-matrixExamples
Once connected, your AI assistant can:
Read messages: "What are the latest messages in #general?"
Send messages: "Send 'Hello everyone!' to #announcements"
Manage rooms: "Create a room called 'Project X' and invite @alice:matrix.org"
Get info: "How many members are in #team-chat?"
Supported Homeservers
Tested with:
Synapse (reference implementation)
Should work with any spec-compliant homeserver (Dendrite, Conduit, etc.)
Requirements
Python 3.10+
A Matrix account on any homeserver
Network access to the homeserver
License
MIT
Links
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Baho73/mcp-server-matrix'
If you have feedback or need assistance with the MCP directory API, please join our Discord server