Skip to main content
Glama
liveblocks

Liveblocks

Official
by liveblocks

update-room

Modify room permissions and metadata to control access for users, groups, or default settings in collaborative Liveblocks environments.

Instructions

Update a Liveblocks room

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
roomIdYes
defaultAccessesYesThe default access permissions for the room. Permissions can be: 1. ["room:write"] // public 2. ["room:read", "room:presence:write"] // read-only 3. [] // private
groupsAccessesNo The group ID accesses for the room. Permissions can be: 1. ["room:write"] // public 2. ["room:read", "room:presence:write"] // read-only 3. [] // private For example, when setting a "design" group to have full/public access: { design: ["room:write"] } Setting to null is used to remove an existing access level: { design: null }
usersAccessesNo The user ID accesses for the room. Permissions can be: 1. ["room:write"] // public 2. ["room:read", "room:presence:write"] // read-only 3. [] // private For example, when setting "charlie" user ID to have full/public access: { charlie: ["room:write"] } Setting to null is used to remove an existing access level: { charlie: null }
metadataNo

Implementation Reference

  • The handler function for the 'update-room' tool. It extracts parameters, calls the Liveblocks updateRoom method with the provided accesses and metadata, and wraps the result using callLiveblocksApi.
      async (
        { roomId, defaultAccesses, groupsAccesses, usersAccesses, metadata },
        extra
      ) => {
        return await callLiveblocksApi(
          getLiveblocks().updateRoom(
            roomId,
            {
              defaultAccesses: defaultAccesses as any,
              groupsAccesses: groupsAccesses as any,
              usersAccesses: usersAccesses as any,
              metadata,
            },
            { signal: extra.signal }
          )
        );
      }
    );
  • Input schema definition for the 'update-room' tool using Zod, referencing shared access schemas.
    {
      roomId: z.string(),
      defaultAccesses: DefaultAccesses,
      groupsAccesses: GroupsAccesses.optional(),
      usersAccesses: UsersAccesses.optional(),
      metadata: z.record(z.string(), z.union([z.string(), z.null()])).optional(),
    },
  • src/server.ts:103-130 (registration)
    Registration of the 'update-room' tool on the MCP server instance.
    server.tool(
      "update-room",
      "Update a Liveblocks room",
      {
        roomId: z.string(),
        defaultAccesses: DefaultAccesses,
        groupsAccesses: GroupsAccesses.optional(),
        usersAccesses: UsersAccesses.optional(),
        metadata: z.record(z.string(), z.union([z.string(), z.null()])).optional(),
      },
      async (
        { roomId, defaultAccesses, groupsAccesses, usersAccesses, metadata },
        extra
      ) => {
        return await callLiveblocksApi(
          getLiveblocks().updateRoom(
            roomId,
            {
              defaultAccesses: defaultAccesses as any,
              groupsAccesses: groupsAccesses as any,
              usersAccesses: usersAccesses as any,
              metadata,
            },
            { signal: extra.signal }
          )
        );
      }
    );
  • Shared Zod schema for defaultAccesses parameter used in 'update-room' tool.
    export const DefaultAccesses = z.array(z.string()).describe(
      `The default access permissions for the room. Permissions can be: 
            
            1. ["room:write"] // public
            2. ["room:read", "room:presence:write"] // read-only
            3. [] // private        
        `
    );
  • Utility function used by the 'update-room' handler to call Liveblocks API and format the MCP tool response.
    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