# Liveblocks MCP

> Liveblocks MCP connects your AI agent to real-time collaboration infrastructure. Manage collaborative spaces, authorize user permissions, track shared document state (Yjs), and resolve comment threads directly from your client. Use this to build complex multiplayer features without leaving your IDE.

## Overview
- **Category:** productivity
- **Price:** Free
- **Tags:** real-time-collaboration, room-management, user-presence, shared-state, multiplayer-infrastructure, api-auth

## Description

This connector lets you control the hardest part of modern web apps: real-time state. Instead of building out a clunky backend just to handle user presence or shared document editing, you can orchestrate those experiences using natural language prompts through your AI client. Your agent handles room lifecycle—creating spaces, managing who gets in, and deleting them when they're done. You can read the current status of collaborative storage or patch it directly via commands. It also keeps track of conversations within a space, letting you query comment threads to see what was decided days ago. When working with complex real-time systems, having all this functionality centralized is huge. With Vinkius hosting this MCP, you connect once and get access to powerful tools for handling everything from user authentication to broadcasting custom events across any compatible client.

## Tools

### authorize_user
Generates an access token, allowing a client to join a specific room.

### broadcast_event
Sends a JSON event to all users currently connected in the specified room.

### create_room
Sets up an entirely new collaborative space with a unique ID.

### create_thread
Starts a new discussion thread and writes the first comment automatically.

### delete_room
Permanently removes an existing collaboration room.

### get_room
Retrieves all metadata and details for a specified room.

### get_storage
Reads the entire current state tree of the room's shared data storage.

### get_thread
Pulls up all comments and details for a specific discussion thread.

### get_ydoc
Outputs the collaborative document's current state as a JSON object representation from Yjs.

### identify_user
Obtains an ID token for a specific client, managing user permissions on the backend.

### initialize_storage
Sets up or resets the room's collaborative storage state.

### list_active_users
Retrieves a list of all user IDs currently connected and active in a specific room.

### list_rooms
Lists all available rooms, with options to filter by metadata or access level.

### list_threads
Fetches a list of every discussion thread that exists within a room.

### patch_storage
Applies precise JSON Patch operations to modify the room's storage state.

### resolve_thread
Marks a discussion thread as resolved, closing it out for future reference.

### update_room
Modifies the properties of an existing room, such as its name or description.

### update_ydoc
Sends a binary update to synchronize the shared Yjs document state across clients.

## Prompt Examples

**Prompt:** 
```
List the first 10 rooms in my Liveblocks project.
```

**Response:** 
```
I've retrieved your rooms. You have active rooms like 'main-editor', 'collaboration-hub', and 'test-room-1'. Would you like to see the metadata for any of these?
```

**Prompt:** 
```
Create a new room with ID 'sprint-planning' and set default access to room:write.
```

**Response:** 
```
Room 'sprint-planning' has been successfully created with 'room:write' as the default access level. You can now start authorizing users for this space.
```

**Prompt:** 
```
Who is currently active in the room 'main-editor'?
```

**Response:** 
```
Checking active users... I found 3 users currently connected to 'main-editor': 'alice_dev', 'bob_designer', and 'charlie_pm'.
```

## Capabilities

### Manage collaborative spaces
Create, read, update, or delete entire collaboration rooms.

### Control user access and identity
Obtain tokens to authorize users and identify them within a room for proper permissions.

### Work with shared document state
Inspect, patch, or update the raw JSON data of collaborative documents (Yjs).

### Track discussions and threads
Create new conversation threads and query existing comment history within a room.

### Monitor presence and events
Get lists of active users in a room or push custom data broadcasts to all connected clients.

## Use Cases

### The onboarding team needs to check permissions for a new project room.
A dev asks their agent: 'List all rooms associated with the marketing department, then authorize user X and get the full metadata.' The agent uses `list_rooms` first, identifies the correct space, runs `authorize_user`, and confirms access rights using `get_room`.

### A shared document needs a state correction.
The PM notices some data is corrupted. They ask their agent to 'Inspect and fix the main editor's storage.' The agent runs `get_storage`, identifies the faulty tree, and then uses `patch_storage` to apply the necessary JSON fix.

### Tracking a complex feature discussion.
A developer needs to know what was decided last week. They ask their agent: 'Check out the thread for the payment gateway design.' The agent uses `get_thread` and then runs `resolve_thread` after confirming the final decision.

### Multiplayer game session setup.
A developer needs to set up a new private gaming room. They prompt: 'Create a new room called 'Alpha Test' and broadcast an event saying it's open.' The agent uses `create_room` followed by `broadcast_event`.

## Benefits

- Debug complex storage issues instantly. Instead of manually connecting to a database, use `get_storage` or `patch_storage` to inspect and modify the room's shared state directly through your agent.
- Manage user entry points without writing auth middleware. Use `authorize_user` and `identify_user` to ensure only authorized clients can enter specific collaboration rooms.
- Keep track of project decisions efficiently. You can use `create_thread`, `list_threads`, or `resolve_thread` to manage the history of discussions, keeping context organized within a room.
- Monitor who is working right now. The `list_active_users` tool gives you an immediate list of all users connected to a given room, useful for status checks or presence systems.
- Control the entire lifecycle of collaborative spaces. Use `create_room`, `update_room`, and `delete_room` to provision and decommission collaboration environments programmatically.

## How It Works

The bottom line is that your agent treats complex real-time infrastructure like a simple set of commands you can type into conversation.

1. Subscribe to this MCP using your Vinkius credentials.
2. Input your Liveblocks Secret Key into the connection settings.
3. Tell your AI client what you need to do, like 'List all active users in the main editor room,' and it executes the command.

## Frequently Asked Questions

**How do I manage user access using Liveblocks MCP?**
You use `identify_user` to get an ID token for the client, and then you run `authorize_user` with that token. This sequence ensures the user has explicit permission to enter the room.

**Can I read the full shared document history with Liveblocks MCP?**
Yes. You can use `get_ydoc` to get a JSON representation of the current state, or you can use `get_storage` for more detailed tree information.

**What is the difference between listing rooms and getting room details with Liveblocks MCP?**
Listing rooms (`list_rooms`) gives you a directory of available spaces. Getting room details (`get_room`) fetches all the specific metadata for one, already identified, space.

**How do I prevent users from entering a room without permission?**
You must first use `identify_user` to get their ID token. Then, you invoke `authorize_user` using that token and specify the desired permissions for access.

**Can Liveblocks MCP handle simple messages in a room?**
While it doesn't send plain text messages directly, it handles structured discussions. You can use `create_thread` to start a discussion or `broadcast_event` for custom system alerts.