get-user-room-subscription-settings
Retrieve user subscription settings for Liveblocks rooms to manage access and permissions.
Instructions
Get a user's room subscription settings
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| userId | Yes |
Implementation Reference
- src/server.ts:640-654 (registration)Registration of the MCP tool 'get-user-room-subscription-settings' using server.tool, specifying the name, description, Zod input schema, and inline async handler function that calls the Liveblocks API.server.tool( "get-user-room-subscription-settings", `Get a user's room subscription settings`, { userId: z.string(), }, async ({ userId }, extra) => { return await callLiveblocksApi( getLiveblocks().getUserRoomSubscriptionSettings( { userId }, { signal: extra.signal } ) ); } );
- src/server.ts:646-653 (handler)Inline handler function implementing the tool logic: calls getLiveblocks().getUserRoomSubscriptionSettings with the userId and formats the response using callLiveblocksApi.async ({ userId }, extra) => { return await callLiveblocksApi( getLiveblocks().getUserRoomSubscriptionSettings( { userId }, { signal: extra.signal } ) ); }
- src/server.ts:643-645 (schema)Zod schema for tool input parameters: requires a 'userId' string.{ userId: z.string(), },
- src/server.ts:21-28 (helper)Helper function that lazily creates and returns a Liveblocks client instance using the LIVEBLOCKS_SECRET_KEY environment variable.function getLiveblocks() { if (!client) { client = new Liveblocks({ secret: process.env.LIVEBLOCKS_SECRET_KEY as string, }); } return client; }
- src/utils.ts:3-37 (helper)Helper utility that executes a Liveblocks API promise, handles success by returning formatted JSON in MCP content or error message, used by all tools.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, }, ], }; } }