matrix
MCP Server for a Matrix home server integration; chat, manage rooms, etc.
claude mcp add --transport stdio mjknowles-matrix-mcp-server node dist/index.js \ --env PORT="3000" \ --env ENABLE_HTTPS="false" \ --env ENABLE_OAUTH="true" \ --env SSL_KEY_PATH="/path/to/private.key" \ --env IDP_TOKEN_URL="https://keycloak.example.com/realms/matrix/protocol/openid-connect/token" \ --env MATRIX_DOMAIN="matrix.example.com" \ --env SSL_CERT_PATH="/path/to/certificate.crt" \ --env IDP_ISSUER_URL="https://keycloak.example.com/realms/matrix" \ --env MATRIX_CLIENT_ID="your-matrix-client-id" \ --env OAUTH_CALLBACK_URL="http://localhost:3000/callback" \ --env CORS_ALLOWED_ORIGINS="" \ --env MATRIX_CLIENT_SECRET="your-matrix-client-secret" \ --env ENABLE_TOKEN_EXCHANGE="true" \ --env IDP_AUTHORIZATION_URL="https://keycloak.example.com/realms/matrix/protocol/openid-connect/auth" \ --env MATRIX_HOMESERVER_URL="https://matrix.example.com"
How to use
This MCP server exposes a Matrix-focused API that lets MCP clients interact with Matrix homeserver functionality through a standardized interface. It supports OAuth 2.0 authentication with token exchange, and provides a rich set of tools organized into tiers: Tier 0 offers read-only access to room, message, user, and search data, while Tier 1 adds actions such as sending messages, creating and managing rooms, and inviting or moderating participants. Use the provided endpoints to fetch room information, list members, retrieve messages, and perform operations like sending messages or creating rooms, all while leveraging the token management and real-time capabilities provided by the MCP layer.
To use, start the server (after configuring environment variables per the .env example). If OAuth is enabled, obtain an access token via your identity provider and exchange it through the MCP flow as required. Clients can then call the available MCP tools, e.g., list-joined-rooms, get-room-info, get-room-messages, send-message, create-room, invite-user, and manage room settings, depending on the user’s permissions and the tool tier. The server supports multi-homeserver setups, so you can configure multiple Matrix endpoints and route actions accordingly.
How to install
Prerequisites:
- Node.js 20+ and npm
- A Matrix homeserver (e.g., Synapse, Dendrite)
- A compatible MCP client (Claude Desktop, VS Code MCP extension, etc.)
Installation steps:
-
Clone the repository git clone <repository-url> cd matrix-mcp-server
-
Install dependencies npm install
-
Build the project npm run build
-
Configure environment cp .env.example .env
Edit .env with your settings (see example values in README)
-
Start the server npm start
Development mode (optional):
- Start with hot reload and OAuth disabled for easier testing npm run dev
- Or start with OAuth enabled ENABLE_OAUTH=true npm run dev
Additional notes
Environment variables and configuration:
- Core: PORT, ENABLE_OAUTH, ENABLE_TOKEN_EXCHANGE, CORS_ALLOWED_ORIGINS
- HTTPS: ENABLE_HTTPS, SSL_KEY_PATH, SSL_CERT_PATH (if using TLS)
- OAuth: IDP_ISSUER_URL, IDP_AUTHORIZATION_URL, IDP_TOKEN_URL, OAUTH_CALLBACK_URL
- Matrix: MATRIX_HOMESERVER_URL, MATRIX_DOMAIN, MATRIX_CLIENT_ID, MATRIX_CLIENT_SECRET If you encounter token exchange issues, verify your IDP URLs and client credentials, and ensure your MCP client is configured to request the required scopes. For development testing, you can disable OAuth (ENABLE_OAUTH=false) to bypass the OAuth flow, but do not use this in production. When running behind reverse proxies, ensure proper header forwarding and CORS settings. The server supports multi-homeserver setups; you can add additional entries under mcpServers with their own command/args/env blocks.
Related MCP Servers
obsidian -tools
Add Obsidian integrations like semantic search and custom Templater prompts to Claude or any MCP client.
Matryoshka
MCP server for token-efficient large document analysis via the use of REPL state
pluggedin-app
The Crossroads for AI Data Exchanges. A unified, self-hostable web interface for discovering, configuring, and managing Model Context Protocol (MCP) servers—bringing together AI tools, workspaces, prompts, and logs from multiple MCP sources (Claude, Cursor, etc.) under one roof.
Agentic -Skill
Agentic-MCP, Progressive MCP client with three-layer lazy loading. Validates AgentSkills.io pattern for efficient token usage. Use MCP without pre-install & wasting full-loading
mongo
MCP server that provide tools to LLMs such as claude in cursor to interact with MongoDB
vscode-context
MCP Server to Connect with VS Code IDE