get-user-room-subscription-settings
Retrieve user-specific room subscription settings by providing their user ID, enabling precise configuration and access control within Liveblocks.
Instructions
Get a user's room subscription settings
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| userId | Yes |
Implementation Reference
- src/server.ts:646-653 (handler)The core handler logic for the 'get-user-room-subscription-settings' tool. It takes userId, calls the Liveblocks SDK method via getLiveblocks(), wraps with callLiveblocksApi, and handles the signal for cancellation.async ({ userId }, extra) => { return await callLiveblocksApi( getLiveblocks().getUserRoomSubscriptionSettings( { userId }, { signal: extra.signal } ) ); }
- src/server.ts:643-645 (schema)Zod input schema for the tool parameters, defining 'userId' as a required string.{ userId: z.string(), },
- src/server.ts:640-654 (registration)MCP server tool registration for 'get-user-room-subscription-settings', specifying name, description, input schema, and inline handler function.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/utils.ts:3-37 (helper)Utility helper function used in the handler (and all other tools) to execute Liveblocks API promises, format successful responses as JSON in MCP content blocks, 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, }, ], }; } }
- src/server.ts:21-28 (helper)Helper function to lazily initialize and retrieve the Liveblocks client instance, used in the handler to make the API call.function getLiveblocks() { if (!client) { client = new Liveblocks({ secret: process.env.LIVEBLOCKS_SECRET_KEY as string, }); } return client; }