feat: matrix MCP invite_user tool
Adds an invite_user tool to the per-agent matrix MCP so an agent can invite
another user to a room it's already in (e.g. pull a peer into an existing
chat). Mirrors the existing join_room/send_dm wiring:
- protocol.rs: DaemonRequest::InviteUser { room, user_id }
- handlers.rs: invite_user — parse user_id, resolve room, room.invite_user_by_id
- socket.rs: dispatch arm
- bin/mcp.rs: invite_user tool + InviteUserArgs
room accepts an id or alias; the caller must hold a power level high enough
to invite (the homeserver error is surfaced verbatim otherwise). The invitee
then accepts via join_room. allowedTools is already '*' for the matrix server,
so the tool is exposed without a nix change.
This commit is contained in:
parent
df1ffdd504
commit
c85dcc0dec
4 changed files with 57 additions and 0 deletions
|
|
@ -127,6 +127,15 @@ struct JoinRoomArgs {
|
|||
room: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, JsonSchema)]
|
||||
struct InviteUserArgs {
|
||||
/// Matrix room id (`!abc:server`) or canonical alias (`#name:server`)
|
||||
/// to invite the user into. You must already be a member.
|
||||
room: String,
|
||||
/// Matrix user id of the invitee (`@user:server`).
|
||||
user_id: String,
|
||||
}
|
||||
|
||||
struct MatrixBridge {
|
||||
#[allow(dead_code)]
|
||||
tool_router: rmcp::handler::server::router::tool::ToolRouter<Self>,
|
||||
|
|
@ -237,6 +246,22 @@ impl MatrixBridge {
|
|||
render(round_trip(DaemonRequest::JoinRoom { room: args.room }).await)
|
||||
}
|
||||
|
||||
#[tool(
|
||||
description = "Invite a user to a matrix room you're already in. `room` is a \
|
||||
room id (!abc:server) or alias (#name:server); `user_id` is the invitee \
|
||||
(@user:server). You must have a high enough power level in the room to \
|
||||
invite. The invitee then sees a pending invite they accept with `join_room`."
|
||||
)]
|
||||
async fn invite_user(&self, Parameters(args): Parameters<InviteUserArgs>) -> String {
|
||||
render(
|
||||
round_trip(DaemonRequest::InviteUser {
|
||||
room: args.room,
|
||||
user_id: args.user_id,
|
||||
})
|
||||
.await,
|
||||
)
|
||||
}
|
||||
|
||||
#[tool(
|
||||
description = "List the members of a matrix room (joined-state only). \
|
||||
Each row carries the user id and resolved display name."
|
||||
|
|
|
|||
Loading…
Reference in a new issue