使用说明
矩阵mcp
一个MCP(模型上下文协议)服务器,将矩阵聊天操作作为AI代理的工具公开。建于 mcp走 和 毛特里克斯走.
工具
| 工具 | 说明 |
|---|---|
send_typing |
发送/清除打字指示器 |
send_message |
发送纯文本消息 |
send_formatted_message |
发送HTML格式的消息 |
reply_to_event |
对事件的线程回复 |
send_reaction |
使用表情符号对事件做出反应 |
get_room_messages |
获取房间消息历史记录 |
create_room |
创建新房间 |
invite_user |
邀请用户到房间 |
set_room_topic |
更新房间主题 |
send_attachment |
上传并发送文件 |
配置
设置以下环境变量:
| 变量 | 描述 | 示例 |
|---|---|---|
MATRIX_HOMESERVER |
家庭服务器URL | https://matrix.example.com |
MATRIX_USER_ID |
机器人用户ID | @bot:example.com |
MATRIX_ACCESS_TOKEN |
访问令牌 | syt_... |
构建与运行
go build -o matrix-mcp .
MATRIX_HOMESERVER=https://matrix.example.com \
MATRIX_USER_ID=@bot:example.com \
MATRIX_ACCESS_TOKEN=syt_xxx \
./matrix-mcp
MCP客户端配置
适用于克劳德桌面(claude_desktop_config.json):
{
"mcpServers": {
"matrix": {
"command": "/path/to/matrix-mcp",
"env": {
"MATRIX_HOMESERVER": "https://matrix.example.com",
"MATRIX_USER_ID": "@bot:example.com",
"MATRIX_ACCESS_TOKEN": "syt_xxx"
}
}
}
}
测试
go test ./...