Skip to main content
Glama
liveblocks

Liveblocks

Official
by liveblocks

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

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 }
          )
        );
      }
    );
  • 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 }
        )
      );
    }
  • Zod schema for tool input parameters: requires a 'userId' string.
    {
      userId: z.string(),
    },
  • 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;
    }
  • 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,
            },
          ],
        };
      }
    }

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