Watch
0
0
Fork
You've already forked hyperhive
0

hive-matrix-mcp: add a leave_room tool

This commit is contained in:
damocles 2026-11-22 19:01:51 +01:00 • committed by mara
commit d88a0cc526

View file

@ -212,6 +212,17 @@ struct ListInvitesArgs {
account: Option<String>,
}
#[derive(Debug, Deserialize, JsonSchema)]
struct LeaveRoomArgs {
/// Matrix room id (`!abc:server`) or canonical alias (`#name:server`) of a
/// room the account has joined.
room: String,
/// Matrix account to act as (a `name` from `services.hyperhive.agent.matrixAccounts`).
/// Omit to use the agent's primary account.
#[serde(default)]
account: Option<String>,
}
#[derive(Debug, Deserialize, JsonSchema)]
struct JoinRoomArgs {
/// Matrix room id (`!abc:server`) or canonical alias (`#name:server`).
@ -414,6 +425,20 @@ impl MatrixMcp {
render(handlers::join_room(&client, &args.room).await)
}
#[tool(
description = "Leave a matrix room you have joined, by id (!abc:server) or \
alias (#name:server). Use it to drop a room a retired account still sits \
in, so it stops getting that room's messages. To decline a pending \
invite use `resolve_invite`. The room leaves `list_rooms`."
)]
async fn leave_room(&self, Parameters(args): Parameters<LeaveRoomArgs>) -> String {
let client = match self.resolve(args.account.as_deref()) {
Ok(c) => c,
Err(e) => return format!("matrix error: {e}"),
};
render(handlers::leave_room(&client, &args.room).await)
}
#[tool(
description = "Accept or reject a pending matrix invite. `room` is a room id \
(!abc:server) or alias (#name:server) you were invited to; `action` is \