codebuddy-matrix-channel
Bridges Matrix chat rooms with CodeBuddy, allowing messages sent in Matrix to be injected into CodeBuddy sessions and responses to be sent back as replies. Supports media download and end-to-end encryption.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@codebuddy-matrix-channelBridge my Matrix room #design into CodeBuddy and relay messages both ways."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
codebuddy-matrix-channel
Bridge Matrix chat to the Channel plugin (MCP server) for local CodeBuddy Code sessions.
Works the same as CodeBuddy's built-in Telegram / Discord / WeChat channels:
Messages sent in a Matrix room appear in the CodeBuddy session as
#matrix · @alice:matrix.org: 你好CodeBuddy's replies are sent back to the Matrix room via the
replytoolOptional: forward CodeBuddy's permission request prompts to a “control room” to approve/deny tool calls from your phone
This plugin is based on CodeBuddy's Channel extension mechanism (see docs/cn/cli/channels.md and channels-reference.md) and does not require modifying CodeBuddy itself.
1. How it works
Matrix 房间 ──(matrix-js-sdk 收消息)──▶ matrix-channel (本插件)
│ notifications/claude/channel
▼
CodeBuddy Code 会话
│ reply 工具 / 权限请求
▼
matrix-channel ──(sendText)──▶ Matrix 房间The plugin is started by CodeBuddy as a child process over stdio and communicates via the MCP protocol.
Related MCP server: mcacp
2. Installation
cd matrix-channel
npm install
npm run build # 编译到 dist/(也可直接用 tsx 运行,无需构建)Requires Node >= 20 at runtime.
2.1 Quick start (digital avatar)
Install / build
cd matrix-channel && npm install && npm run buildFill in
.env(minimal usable set, see Section 3)MATRIX_HOMESERVER=https://im.yiq.pub MATRIX_ACCESS_TOKEN=<从 Element:设置 → 帮助 → 高级 → 访问令牌 复制> MATRIX_USER_ID=@evlon-ai:im.yiq.pub MATRIX_ALLOWLIST=@evlon:im.yiq.pub # 防 prompt 注入,必填 MATRIX_OWNER_ID=@evlon:im.yiq.pub # 分身管理者=你,审批权只认此身份 MATRIX_CONTROL_ROOM_ID=!<控制室房间ID>:im.yiq.pub MATRIX_MENTION_REQUIRED=true # 群里只响应 @分身 # 可选:MATRIX_TRUSTED_SENDERS / MATRIX_TRUSTED_ROOMS / MATRIX_AUTHORIZED_WORKSelf-check (run this after every
.envchange)npm run doctor # 期望:连接 ✅、账号 ✅、E2EE ✅Connect to CodeBuddy: register in the project
.mcp.json(absolute path), then startcodebuddy --channels server:matrix --dangerously-load-development-channelsDaily use
@avatar in a group to assign work → trusted/authorized work runs automatically; unfamiliar work first produces a plan and goes to the control room to wait for your
approve.High-risk tools (Bash/write file, etc.) always go to the control room to ask you.
You issue commands in the control room (only
MATRIX_OWNER_IDis recognized):approve(run/go, optionally followed by a room ID) → authorize tasks in that roomyes <id>/no <id>→ allow / deny pending high-risk permission requests
For encrypted rooms, set
MATRIX_E2EE=true; ifMATRIX_DEVICE_IDis left empty, it will be auto-selected from/devices; if an error occurs, fill in the device ID from “Settings → Devices”.
3. Configuration
Copy .env.example to .env and fill it in:
cp .env.example .envVariable | Description |
| Homeserver address, e.g. |
| Account access_token (recommended; copy from Element “Settings → Help”) |
| Optional, used to identify “own messages”, e.g. |
| Alternative authentication method; at startup it will call |
| Allowed sender user IDs that may send messages, comma-separated (be sure to configure) |
| Allowed room IDs to listen to, comma-separated (empty = all) |
| Permission relay control room room ID (optional, but required in digital avatar mode) |
| Matrix user ID of the avatar manager (owner) (required). Approval authority only recognizes this identity |
| Trusted colleague user IDs, comma-separated; work from them runs automatically (safe tools) |
| Trusted group IDs, comma-separated; all work in these rooms runs automatically |
| Description of authorized routine work (free text), for the avatar to judge “common vs unfamiliar” |
| Whether to only respond to messages that @-mention the bot in groups (default true; recommended when multiple avatars coexist) |
| High-risk tool list, comma-separated; default |
| Whether to download images/files locally and inject them as |
| Media download directory (default |
| Whether to enable end-to-end encryption (default false, see Section 6 below) |
| Has no effect in matrix-js-sdk 42.x (see Section 6): Rust crypto uses wasm + |
⚠️ Security: be sure to configure
MATRIX_ALLOWLIST(it checks by sender, not by room, to prevent any group member from injecting into the session). Leaving it empty allows everyone and is for local testing only.
4. Connecting to CodeBuddy
Method A: development period (bypassing the marketplace whitelist)
Register this plugin in your CodeBuddy project .mcp.json:
{
"mcpServers": {
"matrix": {
"command": "npx",
"args": ["tsx", "/绝对路径/matrix-channel/src/index.ts"]
}
}
}Then start CodeBuddy:
codebuddy --channels server:matrix --dangerously-load-development-channelsAfter compiling, you can run it with
nodeinstead:"args": ["node", "/绝对路径/matrix-channel/dist/index.js"]
Method B: package as a plugin (after submitting to the official marketplace)
npm run buildThen publish codebuddy-matrix-channel as a plugin, and afterwards use:
codebuddy --channels plugin:matrix-channel@<你的市场>5. Usage
After startup, send a message in an allowed Matrix room, and
#matrix · @你: ...will appear in the CodeBuddy sessionWhen CodeBuddy finishes processing, the reply appears in the Matrix room
If
MATRIX_CONTROL_ROOM_IDis configured: when CodeBuddy calls a tool that requires approval (Bash / Write, etc.), the control room receives a prompt (sent as anm.noticesystem message, which does not trigger unread/notifications); replyyes <id>to allow /no <id>to deny
reply tool parameters
Parameter | Description |
| Matrix room ID (taken from the |
| Text to send |
| Optional, HTML body (sent together with |
| Optional, |
For example, have CodeBuddy reply with an
m.noticestatus message:reply({ chat_id: "!abc:server", text: "已处理", msgtype: "m.notice" }).
health_check tool
Can be called directly in the CodeBuddy session, or triggered in the /mcp health check; equivalent to the connectivity/E2EE part of npm run doctor, returning JSON:
{ "ok": true, "userId": "@alice:matrix.org", "e2ee": true, "cryptoReady": true }When ok=false, an error field is included explaining the failure reason (connection/authentication/E2EE initialization).
6. Limitations and notes
End-to-end encrypted (E2EE) rooms: by default, only unencrypted rooms are supported. To bridge encrypted rooms, set
MATRIX_E2EE=true; the plugin reuses matrix-js-sdk's built-in Rust crypto (initRustCrypto), and the SDK automatically handles “decrypt on receive, encrypt on send” — no need to implement the encryption protocol yourself. When enabled:Encrypted messages arrive as
m.room.encrypted; after the SDK finishes decryption (Event.decrypted), the type changes to the real type, and the plugin then pushes it to the session;Replies sent to encrypted rooms are automatically encrypted by the SDK;
Key storage (important, version-dependent): under matrix-js-sdk 42.x, the Rust crypto backend only has a wasm/IndexedDB implementation (
@matrix-org/matrix-sdk-crypto-wasm), with no native Node backend. To make it run on Node, the plugin injects a globalindexedDBshim into Node at startup usingfake-indexeddb/auto— this shim is purely in-memory, so:Keys actually exist only in process memory;
MATRIX_CRYPTO_DBwill not create a real SQLite file on disk in this version; after restarting the process, keys need to be re-negotiated (this does not affect sending/receiving, it just requires redoing key forwarding/device verification once).True disk persistence requires upgrading to a matrix-js-sdk version that ships the native
@matrix-org/matrix-sdk-crypto-nodejsbackend, or a future version that supports the nodejs entry point (at that point, remove thefake-indexeddbshim and switch to the native backend).Note: the already-installed
@matrix-org/matrix-sdk-crypto-nodejsdependency is not called by the SDK in the current 42.2.0, and is only a fallback for future upgrades; the current encryption core works via wasm + thefake-indexeddbin-memory shim.
When a new device first enters an encrypted room, it is recommended to verify this bot's device in the Matrix client (otherwise the other party may see an “unverified device” warning, but messages will still send and receive normally).
Media: by default, only message text is bridged into the session; enabling
MATRIX_DOWNLOAD_MEDIAdownloads images/files locally and injects them as[file: path]so the Agent can read them.Permission relay depends on CodeBuddy's
claude/channel/permissioncapability; if the CodeBuddy version does not support it, the core chat bridge is unaffected.
7. Digital avatar: manager authorization model (core scenario)
Treat the avatar as a “colleague in the group”: anyone can @ it to assign work, yet it will not actually change anything until the manager approves.
Scenario
Colleagues create multiple groups (e.g.
#项目A,#客服), and there may be multiple avatar bots in a group at the same time. Colleagues @your avatar in the group to assign work; it only responds when @-mentioned (direct messages always respond).After receiving an assignment:
Common / authorized work (from your preset
MATRIX_TRUSTED_SENDERS/MATRIX_TRUSTED_ROOMS, or within the scope described byMATRIX_AUTHORIZED_WORK) → runs automatically (safe tools).Unfamiliar work (outside the authorized scope) → the avatar first produces a plan, calls
request_approvalto escalate to your control room; it only executes after you replyapprove.High-risk operations (
MATRIX_HIGH_RISK_TOOLS, such as Bash / writing files) → regardless of source, always asks you first.
Architecture layers
MCP plugin = secure transport + hard gate (enforced by code, not trusting the model):
@filtering and permission decisionsallow/denyrely only on verifiable facts (whether it is the owner, whether it is a trusted source, whether it is a high-risk tool); control room approval only recognizesMATRIX_OWNER_ID.SKILL = policy brain (semantic judgment, delegated to the Agent):
skills/matrix-avatar/SKILL.mdguides the avatar to judge “common vs unfamiliar”; when unfamiliar, it enters plan mode and callsrequest_approval. The Agent only requests approval and never grants itself permission; approval comes only from “the manager's trusted source presets” or “the manager'sapprove”.
The plugin's built-in channel
instructionsalready inline this policy, so it works without installing the SKILL separately;skills/matrix-avatar/SKILL.mdis provided for you to reuse/tweak in CodeBuddy.
Three-tier task status (per room)
Status | Meaning | Safe tools | High-risk tools |
| Trusted source / already | Auto-run | Ask the manager (control room |
| Escalated and pending review ( | Blocked | Blocked |
| Unfamiliar source, unauthorized | Blocked | Blocked (and prompts |
Control room commands (only valid for the manager MATRIX_OWNER_ID)
approve(orrun/go, optionally followed by a room ID, e.g.approve !projectA:server) → authorize the current task in that room, and the avatar starts executing.yes <id>/no <id>→ allow / deny pending high-risk permission requests.Control room replies from anyone else are ignored.
Configuration example (.env)
MATRIX_OWNER_ID=@you:matrix.org
MATRIX_TRUSTED_SENDERS=@alice:matrix.org,@bob:matrix.org
MATRIX_TRUSTED_ROOMS=!projectA:server
MATRIX_AUTHORIZED_WORK=回答产品问题、总结会议纪要、起草文档
MATRIX_MENTION_REQUIRED=true
MATRIX_HIGH_RISK_TOOLS=Bash,Write,Edit,MultiEdit,NotebookEdit8. Self-check (doctor)
After filling in .env, you can run the self-check first to confirm configuration, connectivity, and E2EE status before starting CodeBuddy:
npm run doctorThe self-check prints the current configuration (token masked), verifies that the homeserver is reachable and credentials are valid, and attempts to initialize Rust crypto when MATRIX_E2EE=true. Any failure gives a clear reason and exits with a non-zero exit code.
9. Directory structure
matrix-channel/
├── src/
│ ├── config.ts # 环境变量 / 白名单 / 授权配置读取与校验
│ ├── matrix.ts # Matrix 客户端封装(连接、@提及过滤、收/发、下载媒体、E2EE、自检)
│ ├── index.ts # MCP 服务:channel 通知、授权硬闸、reply / request_approval 工具、控制室审批
│ └── doctor.ts # `npm run doctor` 自检入口
├── skills/
│ └── matrix-avatar/
│ └── SKILL.md # 分身行为策略(语义判断:常用 vs 陌生)
├── package.json
├── tsconfig.json
├── .gitignore
├── .env.example
└── README.mdThis 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
- AlicenseAqualityBmaintenanceBridges OpenAI Codex CLI to any MCP client, allowing headless Codex sessions via tools like codex and codex-reply.229MIT
- AlicenseAqualityDmaintenanceBridges any MCP client (like Claude Code, Zed, VS Code) to any ACP coding agent, enabling multi-agent orchestration from a single chat interface.241309Apache 2.0
- AlicenseNot gradedqualityBmaintenanceBridges a Matrix room with Claude Code's claude/channel feature, enabling chat from Matrix to interact with a running Claude Code session.GPL 3.0
- 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
Telegram bridge for your MCP-compatible agent. Bidirectional, no LLM in our stack.
MCP server bridging holepunchto/keet-identity-key to the Hive agentic identity network
Official remote MCP server bridge for Muumuu Domain.
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/evlon/matrix-channel'
If you have feedback or need assistance with the MCP directory API, please join our Discord server