From a35fd1dcf2e2809042daf07d6c2da7e975705f36 Mon Sep 17 00:00:00 2001 From: iris Date: Wed, 1 Jul 2026 18:58:49 +0200 Subject: [PATCH 1/2] docs(matrix-mcp): document send_file, download_file, and unread guard in server instructions The MCP server instructions string omitted three behaviours added in earlier PRs, leaving agents without context on them: - send_file / download_file tools (#1829, #1830) - [file:]/[image:]/[audio:]/[video:] attachment markers in read_room (#1830) - unread guard: send_message, send_dm, send_file, send_reply all reject if the room has unread messages; read_room + mark_read are required first (#1828) Closes #1828. Closes #1829. Closes #1830. --- hive-matrix-mcp/src/bin/mcp.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/hive-matrix-mcp/src/bin/mcp.rs b/hive-matrix-mcp/src/bin/mcp.rs index 88fe5407..9adb8ff6 100644 --- a/hive-matrix-mcp/src/bin/mcp.rs +++ b/hive-matrix-mcp/src/bin/mcp.rs @@ -567,7 +567,18 @@ impl MatrixBridge { room with `join_room`. Room references accept ids (!abc:server) \ or aliases (#name:server); user references use @user:server. Every \ tool takes an optional `account` (a name from the agent's matrix \ - accounts) — omit it to act as the primary account.")] + accounts) — omit it to act as the primary account. \ + `send_file` uploads a local file and posts it as a room attachment \ + (MIME inferred from extension, 50 MiB cap); `send_file` is rejected \ + with a hint if the room has unread messages — read_room then mark_read \ + first. `download_file` downloads an attachment from a message event \ + to a local file and returns its path; pair with `read_room` which \ + surfaces attachments as `[file: name]`, `[image: name]`, \ + `[audio: name]`, `[video: name]` markers. \ + IMPORTANT: `send_message`, `send_dm`, `send_file`, `send_reply` are \ + all rejected if the room has unread messages — always call `read_room` \ + then `mark_read` on the latest event before sending to a room you \ + haven't read yet.")] impl ServerHandler for MatrixBridge {} #[tokio::main] From 26dd8b0d34590ccce8f9b722be3bd57a9725424e Mon Sep 17 00:00:00 2001 From: iris Date: Wed, 1 Jul 2026 19:07:25 +0200 Subject: [PATCH 2/2] docs(matrix-mcp): add send_file, download_file, unread guard to tools/matrix.md The human-readable matrix MCP reference was missing three behaviours documented only in the MCP server instructions string: - send_file / download_file tools (issues 1829, 1830) - [file:]/[image:]/[audio:]/[video:] attachment markers in read_room (issue 1830) - unread guard: send_message, send_dm, send_file, send_reply all reject if the room has unread messages (issue 1828) - send_redact (omitted from the tool list entirely) Add all four to docs/tools/matrix.md to match the MCP server instructions added in the previous commit. --- docs/tools/matrix.md | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/docs/tools/matrix.md b/docs/tools/matrix.md index b3ee31b3..bdf3f7fe 100644 --- a/docs/tools/matrix.md +++ b/docs/tools/matrix.md @@ -8,17 +8,35 @@ a second stdio MCP server. Tools land as `mcp__matrix__`: ### Messaging +**Unread guard**: `send_message`, `send_dm`, `send_file`, and +`send_reply` are all rejected if the room has unread messages — call +`read_room` then `mark_read` on the latest event before sending to a +room you haven't read yet. + - `send_message(room, body)` — send a markdown message; `room` accepts `!id:server` or `#alias:server`, daemon resolves either -- `send_dm(user_id, body)` — send a direct message to a matrix user +- `send_dm(user_id, body)` — open (or reuse) the DM room with + `user_id` and post `body` to it - `send_reply(room, event_id, body)` — threaded reply to a specific event - `send_reaction(room, event_id, key)` — react to a message with an emoji key +- `send_file(room, path, caption?)` — upload a local file and post it + as a room attachment; MIME type is inferred from the file extension, + 50 MiB cap; optional `caption` is sent as a follow-up text message +- `send_redact(room, event_id, reason?)` — redact (delete) a specific + event; works on your own events, redacting others' requires moderator + power level ### Reading -- `read_room(room, limit?)` — recent timeline events +- `read_room(room, limit?)` — recent timeline events; media attachments + appear inline as `[file: name]`, `[image: name]`, `[audio: name]`, + or `[video: name]` markers — pass the event id to `download_file` + to retrieve the attachment +- `download_file(room, event_id, dest_path?)` — download a media + attachment from a message event to a local file and return its path; + pair with `read_room` which surfaces attachments as the markers above - `list_rooms()` — enumerate joined rooms (`{ id, canonical_alias, name, member_count }` per room) - `list_room_members(room)` — members of a room