Skip to main content
Glama
liveblocks
by liveblocks

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
NameRequiredDescriptionDefault
userIdYes

Implementation Reference

  • 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 } ) ); }
  • 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 } ) ); } );
  • 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, }, ], }; } }
  • 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; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/liveblocks/liveblocks-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server