update-room
Modify access permissions and metadata for a Liveblocks room to control user and group access levels. Define public, read-only, or private settings for default, group, and user-specific access.
Instructions
Update a Liveblocks room
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| defaultAccesses | Yes | The default access permissions for the room. Permissions can be: 1. ["room:write"] // public 2. ["room:read", "room:presence:write"] // read-only 3. [] // private | |
| groupsAccesses | No | 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 } | |
| metadata | No | ||
| roomId | Yes | ||
| usersAccesses | No | 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 } |
Implementation Reference
- src/server.ts:103-130 (registration)Registration of the 'update-room' MCP tool, including inline input schema (using imported Zod types) and the handler function that invokes the Liveblocks SDK's updateRoom method via callLiveblocksApi.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 } ) ); } );
- src/server.ts:113-129 (handler)The handler function for the 'update-room' tool. It destructures input parameters, calls getLiveblocks().updateRoom with the roomId and access/metadata updates, and wraps the result using callLiveblocksApi for MCP response formatting.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 } ) ); }
- src/zod.ts:41-48 (schema)Zod schema definition for DefaultAccesses, used in the input schema of 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 ` );
- src/zod.ts:50-72 (schema)Zod schema definition for GroupsAccesses, used optionally in the input schema of update-room tool.export const GroupsAccesses = z .record(z.string(), z.array(z.union([z.string(), z.null()]))) .describe( ` 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 } ` );
- src/zod.ts:74-96 (schema)Zod schema definition for UsersAccesses, used optionally in the input schema of update-room tool.export const UsersAccesses = z.record( z.string(), z.array(z.union([z.string(), z.null()])) ).describe(` 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 } `);
- src/utils.ts:1-37 (helper)Helper function callLiveblocksApi used by the update-room handler (and all tools) to handle API promises, format successful JSON responses, and catch errors for MCP tool results.import { CallToolResult } from "@modelcontextprotocol/sdk/types.js"; 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, }, ], }; } }