# PubNub MCP

> PubNub enables your AI client to manage real-time communication, track user presence across channels, and handle message history. Use this MCP to publish messages instantly, monitor who is online right now, and retrieve past conversations for support or auditing purposes.

## Overview
- **Category:** communication-messaging
- **Price:** Free
- **Tags:** real-time-sync, pub-sub, data-streams, presence-tracking, messaging, low-latency

## Description

This MCP connects your agent directly into a global data stream network. It lets you orchestrate real-time communication—not just sending simple text messages, but managing complex interactions like tracking user activity or archiving entire chat logs through natural language prompts. You can monitor exactly who is in which conversation and even manage group memberships instantly. For instance, if your application needs to handle high volume data streams, the Vinkius catalog makes connecting this functionality straightforward, letting you focus on the logic rather than the connection details. With this MCP, you control everything from generating secure file upload links to purging old message logs for compliance.

## Tools

### admin_create_app
Creates a new PubNub application using the Admin API.

### admin_get_metrics
Retrieves current usage metrics for administrative oversight.

### admin_list_apps
Lists all existing PubNub applications on the account.

### admin_list_keysets
Retrieves a list of all keyset identifiers.

### delete_file
Removes a specific file from within a channel.

### delete_message_history
Purges message history records for selected channels.

### generate_file_upload_url
Creates a secure URL that allows another service to upload files directly.

### get_all_channels
Lists every channel the application has access to.

### get_all_users
Retrieves a list of all user accounts associated with the system.

### get_channel
Fetches details and metadata for one specific channel.

### get_file_url
Retrieves a direct, accessible URL for a file within the network.

### get_memberships
Checks which groups a specific user belongs to or is restricted by.

### get_user
Retrieves detailed information for a single user account.

### get_message_history
Fetches the chronological log of messages from a specified channel.

### list_files
Retrieves a list of all files stored within a given channel.

### get_message_count
Counts the total number of messages ever sent to a specific channel.

### pam_grant_token
Issues a temporary, secure token for internal system authentication (PAM v3).

### pam_revoke_token
Immediately invalidates and revokes an existing PAM v3 token.

### presence_get_state
Checks the current online status of a user within a specific channel.

### presence_heartbeat
Sends an update confirming that a user is still active in their session.

### presence_here_now
Gets a list of all users currently online and active in the network (Here Now).

### presence_leave
Signals that a user is manually exiting or leaving a channel.

### presence_set_state
Allows the system to set a custom online status for a user in a channel.

### presence_where_now
Determines all channels that a specific user is currently participating in (Where Now).

### publish_message
Sends an immediate, new message to a specified channel.

### push_manage
Manages or lists the push notification channels for connected devices.

### push_remove_all
Removes all registered push notification channels from a device's profile.

### remove_user
Permanently removes a user account from the application context.

### set_channel
Creates or updates metadata for an existing channel.

### set_memberships
Updates which groups a user belongs to, defining their access rights.

### set_user
Creates or updates the profile information for an existing user account.

## Prompt Examples

**Prompt:** 
```
Publish a message to the 'alerts' channel saying 'System update scheduled for midnight'.
```

**Response:** 
```
I've published the message to the 'alerts' channel. The timetoken for this message is 17156348210000000.
```

**Prompt:** 
```
Get the last 5 messages from the 'support-chat' channel.
```

**Response:** 
```
I retrieved the last 5 messages from 'support-chat'. They include inquiries about billing and a technical setup question from user UUID-987.
```

**Prompt:** 
```
Who is currently active in the 'lobby' channel?
```

**Response:** 
```
There are currently 3 users in the 'lobby' channel: 'admin-01', 'user-55', and 'guest-12'.
```

## Capabilities

### Publishing real-time content
Send a message payload instantly to any specified channel.

### Monitoring live presence
Determine which users are currently online, or what channels they have recently visited.

### Retrieving message history
Fetch logs of past messages from a channel and count how many total messages were sent.

### Managing user and group data
Get or update specific user profiles, list all available users, or change who belongs to which group.

### Handling shared files
Generate secure URLs for uploading assets or retrieving file content from the network.

### Maintaining data integrity
Delete old message histories in channels or remove specific user accounts when necessary.

## Use Cases

### A customer support queue needs real-time status updates.
The support team asked their agent, 'Who's online right now in the billing chat?' The agent used `presence_here_now` and reported a list of active users. This allowed the technician to immediately prioritize help for the most engaged customers.

### An internal tool needs to archive communications for legal reasons.
A compliance officer asked their agent, 'Get all messages from the 'project-x' channel last month.' The agent used `get_message_history` and also ran `delete_message_history` on older, irrelevant channels, keeping only what was required.

### An IoT dashboard needs to know if a device is communicating.
The system architect told their agent, 'Check the heartbeat status for Device-7.' The agent used `presence_heartbeat` and confirmed that the connection remained active, triggering the next scheduled check.

### A collaborative workspace needs to manage roles dynamically.
The team lead asked their agent, 'Add User A to the 'admin' channel.' The agent used `set_memberships` and then immediately updated the user profile using `set_user`, ensuring the permissions were correct.

## Benefits

- You can track who is currently online using the `presence_here_now` tool. This means your support agent knows instantly if a user has logged off, which drastically improves response quality.
- Building out an audit log? Use `get_message_history` to pull message logs for any channel and count them with `get_message_count`. This gives you the full context needed for compliance reports.
- Instead of relying on a separate directory service, use `get_all_users` and `get_user` to manage user metadata right from your agent. You can ensure every interaction is tied back to accurate profile data.
- File sharing becomes simple. The `generate_file_upload_url` tool gives you secure upload links, so users never have to send sensitive files through the chat itself.
- You gain granular control over group access using tools like `get_memberships`. You can let your agent check who is allowed in a private channel before attempting to publish anything.

## How It Works

The bottom line is you get a persistent, low-latency channel for all things real-time communication.

1. Subscribe to this MCP and provide your PubNub Subscribe Key, Publish Key, and UUID credentials.
2. Your AI client uses these keys to establish a connection to the real-time data stream network.
3. You interact with the system using natural language commands, allowing your agent to manage live communications and retrieve history.

## Frequently Asked Questions

**How do I check who is online using PubNub MCP?**
You use `presence_here_now` to get a list of all users currently active in the network. This tells you their real-time status without needing to query specific channels first.

**Can I delete old messages using PubNub MCP?**
Yes, use `delete_message_history` to purge message logs from entire channels. You can also target individual files with the `delete_file` tool for specific cleanup tasks.

**What is the difference between getting all users and getting a single user?**
Use `get_all_users` when you need to list every account for administrative purposes. Use `get_user` when you already know the ID and only need to retrieve specific profile details.

**How do I manage file uploads with PubNub MCP?**
First, call `generate_file_upload_url` to get a secure link. Then, instruct your agent on how to upload the file using that URL so it lands correctly in the channel.

**Can I update user permissions with PubNub MCP?**
Yes. You can manage this by first checking roles with `get_memberships`, and then updating them directly using `set_memberships` to control access rights.