Skip to main content
Glama
by liveblocks

create-room

Generate a Liveblocks room with customizable access permissions for users and groups. Define default access levels and manage metadata to create collaborative spaces tailored to specific needs.

Instructions

Create a Liveblocks room

Input Schema

NameRequiredDescriptionDefault
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 }
metadataNo
roomIdYes
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 }

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "defaultAccesses": { "description": "The default access permissions for the room. Permissions can be: \n \n 1. [\"room:write\"] // public\n 2. [\"room:read\", \"room:presence:write\"] // read-only\n 3. [] // private \n ", "items": { "type": "string" }, "type": "array" }, "groupsAccesses": { "additionalProperties": { "items": { "type": [ "string", "null" ] }, "type": "array" }, "description": "\n The group ID accesses for the room. Permissions can be: \n \n 1. [\"room:write\"] // public\n 2. [\"room:read\", \"room:presence:write\"] // read-only\n 3. [] // private \n\n For example, when setting a \"design\" group to have full/public access:\n\n {\n design: [\"room:write\"]\n }\n\n Setting to null is used to remove an existing access level:\n\n {\n design: null\n }\n ", "type": "object" }, "metadata": { "additionalProperties": { "type": "string" }, "type": "object" }, "roomId": { "type": "string" }, "usersAccesses": { "additionalProperties": { "items": { "type": [ "string", "null" ] }, "type": "array" }, "description": "\n The user ID accesses for the room. Permissions can be: \n \n 1. [\"room:write\"] // public\n 2. [\"room:read\", \"room:presence:write\"] // read-only\n 3. [] // private \n\n For example, when setting \"charlie\" user ID to have full/public access:\n\n {\n charlie: [\"room:write\"]\n }\n\n Setting to null is used to remove an existing access level:\n\n {\n charlie: null\n }\n ", "type": "object" } }, "required": [ "roomId", "defaultAccesses" ], "type": "object" }

Implementation Reference

  • The handler function for the 'create-room' tool. It calls the Liveblocks createRoom method with the provided parameters and wraps the result using callLiveblocksApi.
    async ( { roomId, defaultAccesses, groupsAccesses, usersAccesses, metadata }, extra ) => { return await callLiveblocksApi( getLiveblocks().createRoom( roomId, { defaultAccesses: defaultAccesses as any, groupsAccesses: groupsAccesses as any, usersAccesses: usersAccesses as any, metadata, }, { signal: extra.signal } ) ); }
  • Input schema for the 'create-room' tool, defined using Zod and referencing imported schema types.
    { roomId: z.string(), defaultAccesses: DefaultAccesses, groupsAccesses: GroupsAccesses.optional(), usersAccesses: UsersAccesses.optional(), metadata: z.record(z.string(), z.string()).optional(), },
  • src/server.ts:61-88 (registration)
    Registration of the 'create-room' tool on the McpServer instance.
    server.tool( "create-room", "Create a Liveblocks room", { roomId: z.string(), defaultAccesses: DefaultAccesses, groupsAccesses: GroupsAccesses.optional(), usersAccesses: UsersAccesses.optional(), metadata: z.record(z.string(), z.string()).optional(), }, async ( { roomId, defaultAccesses, groupsAccesses, usersAccesses, metadata }, extra ) => { return await callLiveblocksApi( getLiveblocks().createRoom( roomId, { defaultAccesses: defaultAccesses as any, groupsAccesses: groupsAccesses as any, usersAccesses: usersAccesses as any, metadata, }, { signal: extra.signal } ) ); } );
  • Zod schema definition for DefaultAccesses used in create-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 to call Liveblocks API promises and format the response as MCP CallToolResult, handling success and error cases.
    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