get-active-users
Retrieve a list of active users in a Liveblocks room by specifying the room ID. Enables real-time monitoring of user activity within collaborative spaces.
Instructions
Get a Liveblocks room's active users
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| roomId | Yes |
Implementation Reference
- src/server.ts:168-172 (handler)The handler function for the 'get-active-users' tool. It takes a roomId, calls getLiveblocks().getActiveUsers via the callLiveblocksApi wrapper, passing the abort signal.async ({ roomId }, extra) => { return await callLiveblocksApi( getLiveblocks().getActiveUsers(roomId, { signal: extra.signal }) ); }
- src/server.ts:165-167 (schema)The input schema for the 'get-active-users' tool, requiring a single 'roomId' string parameter.{ roomId: z.string(), },
- src/server.ts:162-173 (registration)The registration of the 'get-active-users' tool using McpServer.tool, including name, description, schema, and handler.server.tool( "get-active-users", "Get a Liveblocks room's active users", { roomId: z.string(), }, async ({ roomId }, extra) => { return await callLiveblocksApi( getLiveblocks().getActiveUsers(roomId, { signal: extra.signal }) ); } );
- src/utils.ts:3-37 (helper)Shared helper function callLiveblocksApi used by the handler to wrap Liveblocks API calls and format responses as MCP CallToolResult with JSON output or error messages.export async function callLiveblocksApi( liveblocksPromise: Promise<any> ): Promise<CallToolResult> { try { const data = await liveblocksPromise; if (!data) { return { content: [{ type: "text", text: "Success. No data returned." }], }; } return { content: [ { type: "text", text: "Here is the data. If the user has no specific questions, return it in a JSON code block", }, { type: "text", text: JSON.stringify(data, null, 2), }, ], }; } catch (err) { return { content: [ { type: "text", text: "" + err, }, ], }; } }