matrix-mcp-server
@guan-tends/matrix-mcp-server
Matrix のチャット操作を呼び出し可能なツールとして公開する、スタンドアロンの MCP(Model Context Protocol)ツールサーバーです。MCP 互換のクライアント — AI エージェント、自動化パイプライン、開発者ツール — は、これらのツールを使用して、メッセージの送信、ルームの管理、名前の解決、Matrix プロトコルとの対話を行うことができます。
@vector-im/matrix-bot-sdk をベースに構築され、完全な E2EE(エンドツーエンド暗号化)サポートを備えています。
機能
15 の MCP ツール — メッセージング、ルーム管理、ユーザー管理、インテリジェントな ID 解決
E2EE サポート — Rust 暗号化バックエンドによる完全な Megolm 暗号化
人間にわかりやすい名前解決 — 不透明な ID ではなく、名前でルームやユーザーを参照
エイリアスシステム — サーバーにカスタムショートカットを教える(例:
"eng"→"!abc123:matrix.org")スタンドアロン HTTP サーバー — 独立して動作し、HTTP 経由で任意の MCP クライアントを接続可能
cron なし、LLM なし — 純粋なツールサーバー。スケジューリングとインテリジェンスはエージェント層にあります
Related MCP server: ottoauthMCP
インストール
npm install @guan-tends/matrix-mcp-server要件
Node.js >= 22.0.0
アクセストークンを持つ Matrix アカウント
クイックスタート
1. クローンと設定
git clone https://github.com/guan-tends/matrix-mcp-server.git
cd matrix-mcp-server
npm install
cp config.example.json5 config.json5config.json5 を Matrix の認証情報で編集します:
{
homeserverUrl: "https://matrix.org",
accessToken: "syt_...",
serverName: "matrix.org",
port: 3456,
host: "0.0.0.0",
storePath: "./data/store.json",
cryptoPath: "./data/crypto",
}2. 実行
npm startサーバーは http://0.0.0.0:3456 で待ち受け、HTTP 経由で MCP プロトコルリクエストを受け付けます。
3. MCP クライアントを接続する
MCP 互換のクライアントをサーバーに接続します:
{
"mcpServers": {
"matrix": {
"url": "http://localhost:3456"
}
}
}または、@guan-tends/mcp-ai アグリゲーターと併用して、複数サーバーにまたがるツール構成を行うこともできます。
設定
ファイルベース
config.json5 を編集します(すべてのオプションは config.example.json5 を参照)。
環境変数
すべての設定値は環境変数で設定できます(最優先):
変数 | 設定キー |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ツール (15)
メッセージング
ツール | 説明 |
| テキストをルームに送信(ID または解決された名前で指定) |
| HTML 形式のメッセージを送信 |
| 絵文字でメッセージにリアクション |
| ダイレクトメッセージを送信(必要に応じて暗号化 DM を作成) |
ルーム管理
ツール | 説明 |
| ID またはエイリアスでルームに参加 |
| ルームから退出 |
| 参加中の全ルームを一覧表示 |
| ルームから最近のメッセージを取得 |
ユーザー管理
ツール | 説明 |
| ユーザーのプレゼンスステータスを取得 |
| ユーザーをルームに招待 |
| ユーザーをルームからキック |
ID 解決
ツール | 説明 |
| サーバーにルームエイリアスを教える(例: |
| サーバーにユーザーエイリアスを教える(例: |
| ルーム名を信頼度スコア付きで Matrix ID に解決 |
| ユーザー名を信頼度スコア付きで Matrix ID に解決 |
解決戦略
リゾルバーは、信頼度スコアリングを用いたハイブリッド方式を採用しています:
ユーザーエイリアス(信頼度: 1.0)— ユーザー定義のマッピング
完全一致(信頼度: 0.9)— 表示名または正規エイリアスとの完全一致
部分一致(信頼度: 0.7)— 名前の部分一致
曖昧性(信頼度: 0.5)— 複数一致した場合、候補を返す
アーキテクチャ
┌─────────────────────────┐
│ index.js │
│ (composition root) │
└──────────┬──────────────┘
│ wires
┌────────────────┼────────────────┐
▼ ▼ ▼
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ MatrixClient │ │ AliasStore │ │ McpDataStore │
│ (bot-sdk) │ │ (aliases) │ │ (DM cache) │
└──────┬───────┘ └──────┬───────┘ └──────┬───────┘
│ │ │
└────────┬────────┘ │
▼ │
┌──────────────────┐ │
│ MatrixIdResolver │◄────────────────┘
└────────┬─────────┘
│
▼
┌──────────────────┐
│ mcp-server.js │── MCP SDK SimpleServer
│ (15 tools) │── HTTP transport
└──────────────────┘Composition-Root IoC: index.js がすべての依存関係を配線します。どのモジュールも他のモジュールの依存関係をインポートしません。各モジュールは独立してテスト可能です。
設計上の決定
Composition-Root IoC —
index.jsがすべての依存関係を配線します。モジュールは相互インポートしません。最小限の AliasStore — ルーム/ユーザーエイリアス管理に必要なメソッドはわずか 4 つです。
シンプルな JSON 永続化 —
persist.jsがロード/セーブを処理します。データファイルは 2 つです。withErrorHandlingラッパー — 各ツールで繰り返される try/catch を DRY 化します。cron なし、LLM なし、ボットなし — 純粋な MCP ツールサーバー。エージェントが自身のスケジューリングを処理します。
テスト
# All tests (unit + E2E)
npm test
# Watch mode
npm run test:watch
# With coverage
npm run test:coverage65 件のテスト を 6 ファイル(単体テスト 5、E2E 1)で実施。
プロジェクト構成
src/
├── index.js — Composition root: config → Matrix client → wire → start
├── mcp-server.js — 15 MCP tools + helpers (withErrorHandling, resolveRoomInput, etc.)
├── matrix-id-resolver.js — Room/user name → Matrix ID resolution
├── alias-store.js — Minimal per-user alias storage
├── mcp-data-store.js — DM room ID cache
└── persist.js — Simple JSON load/save utility
__tests__/
├── unit/ — Unit tests (alias-store, mcp-data-store, resolver, mcp-server, persist)
├── e2e/ — E2E test (full server start → MCP client → tool calls)
├── mocks/ — Mock MatrixClient for testing
└── vitest.config.jsスポンサー
このプロジェクトが役に立つと思われたら、開発のサポートを検討してください:
Solana:
Eu8wQcW68TKMs1a6eqzZu8znzU52QLqQugAMG8uCD6y6EVM (Ethereum / Base / Arbitrum / Optimism / Polygon):
0x2733ff7c865C56d565a99BE1DC11B81cc76850A5XRP Ledger:
r4X6e7McAQj7e8vBCeued1RYu4mCJrREDG
ライセンス
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityAmaintenanceA self-hostable MCP server that turns a folder of skills into callable tools via MCP and REST APIs.2MIT
- FlicenseNot gradedqualityDmaintenanceStandalone MCP server that proxies tool calls to Ottoauth HTTP endpoints, enabling account creation and dynamic service interaction.
- FlicenseNot gradedqualityDmaintenanceMCP server for Rocket.Chat, enabling AI agents to interact with Rocket.Chat workspaces via tools like listing users, sending messages, and managing channels.2
- AlicenseNot gradedqualityCmaintenanceMCP server for Matrix that lets Claude list rooms, search/read messages, send messages and files, react, create rooms, and invite users, with multi-homeserver support and safe-by-default writes; no end-to-end encryption.MIT
Related MCP Connectors
Markdown-first MCP server for Notion API with 8 composite tools and 39 actions.
MCP server exposing the Backtest360 engine API as tools for AI agents.
MCP server for secureFlows: token-free URL builders and integration-linting tools for AI agents.
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/guan-tends/matrix-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server