hive-matrix-mcp: add a leave_room tool
This commit is contained in:
parent
56ed2e07da
commit
d88a0cc526
1 changed files with 68 additions and 4 deletions
|
|
@ -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 \
|
||||
|
|
|
|||
Loading…
Reference in a new issue