feat(#1102): add list_invites and join_room to matrix MCP
This commit is contained in:
parent
b13a6911b7
commit
7e5a21522a
4 changed files with 85 additions and 3 deletions
|
|
@ -118,6 +118,15 @@ struct ReadRoomArgs {
|
|||
limit: Option<usize>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, JsonSchema)]
|
||||
struct ListInvitesArgs {}
|
||||
|
||||
#[derive(Debug, Deserialize, JsonSchema)]
|
||||
struct JoinRoomArgs {
|
||||
/// Matrix room id (`!abc:server`) or canonical alias (`#name:server`).
|
||||
room: String,
|
||||
}
|
||||
|
||||
struct MatrixBridge {
|
||||
#[allow(dead_code)]
|
||||
tool_router: rmcp::handler::server::router::tool::ToolRouter<Self>,
|
||||
|
|
@ -210,6 +219,24 @@ impl MatrixBridge {
|
|||
render(round_trip(DaemonRequest::ListRooms).await)
|
||||
}
|
||||
|
||||
#[tool(
|
||||
description = "List rooms this agent has been invited to but not yet joined. \
|
||||
Each row has the room id, canonical alias (when set), and display name. \
|
||||
Use `join_room` to accept an invite."
|
||||
)]
|
||||
async fn list_invites(&self, Parameters(_): Parameters<ListInvitesArgs>) -> String {
|
||||
render(round_trip(DaemonRequest::ListInvites).await)
|
||||
}
|
||||
|
||||
#[tool(
|
||||
description = "Join a matrix room by id (!abc:server) or alias (#name:server). \
|
||||
Accepts a pending invite if one exists; also joins public rooms. \
|
||||
After joining the room will appear in `list_rooms`."
|
||||
)]
|
||||
async fn join_room(&self, Parameters(args): Parameters<JoinRoomArgs>) -> String {
|
||||
render(round_trip(DaemonRequest::JoinRoom { room: args.room }).await)
|
||||
}
|
||||
|
||||
#[tool(
|
||||
description = "List the members of a matrix room (joined-state only). \
|
||||
Each row carries the user id and resolved display name."
|
||||
|
|
@ -237,8 +264,10 @@ impl MatrixBridge {
|
|||
specific user, `send_reaction` to react with an emoji, `send_reply` \
|
||||
to thread a reply, `mark_read` to acknowledge an event. Discover \
|
||||
rooms with `list_rooms`, members with `list_room_members`, recent \
|
||||
timeline with `read_room`. Room references accept ids (!abc:server) \
|
||||
or aliases (#name:server); user references use @user:server.")]
|
||||
timeline with `read_room`. See pending invites with `list_invites`; \
|
||||
accept an invite or join a public room with `join_room`. Room \
|
||||
references accept ids (!abc:server) or aliases (#name:server); \
|
||||
user references use @user:server.")]
|
||||
impl ServerHandler for MatrixBridge {}
|
||||
|
||||
#[tokio::main]
|
||||
|
|
|
|||
Loading…
Reference in a new issue