# PubNub MCP for AI Agents AI Agent Connect

> PubNub (Real-time Messaging) MCP lets your AI agent handle live data streams, manage real-time chat logs, and track user presence across a global network. It bridges the gap between your AI's reasoning and instant communication, allowing it to publish messages, monitor who's online, and manage app context like user profiles and channel metadata in real-time.

## Overview
- **Category:** communication-messaging
- **Price:** Free
- **Endpoint:** https://edge.vinkius.com/vk_preview_RCnBsSkUGMNTFGRb3L5phSfqwmHtbHFrYEYF7Aui/ai-agent-connect
- **Tags:** real-time-sync, pub-sub, data-streams, presence-tracking, messaging, low-latency

## Description

PubNub MCP lets your AI agent orchestrate real-time communication and monitor user presence across a global data stream network. It turns your agent into an active participant in your live infrastructure rather than just a reactive chat interface. You can have it push updates to specific channels the moment an event occurs or keep a running tally of who is currently active in a support lobby. It handles the heavy lifting of managing your app context, like creating user profiles and managing channel memberships, so you can focus on the results. This connection gives your agent a live seat at the table for auditing historical logs or generating secure links for file uploads. It's a major step up for anyone building systems that need to feel alive and responsive. You'll find this works great when you're building complex systems that need to feel alive, and it's one of the most reliable ways to connect those streams to your workflow via the Vinkius catalog. For example, an IoT setup can use this to send device heartbeats and control commands in real-time. A support team can use it to see exactly who is waiting in a queue at any second. It removes the friction of jumping between different dashboards and manual logs. By connecting your PubNub account, you give your agent the eyes and ears to see your live data and the hands to act on it immediately. Your agent doesn't just summarize what happened in the past; it helps manage what is happening right now.

## Tools

### get_channel
Pull specific details and metadata for a single channel in your app. This gives you a clear view of your channel configurations.

### presence_here_now
See a real-time list of everyone currently in a specific channel. This is great for managing live lobbies or chat rooms.

### presence_set_state
Manually update a user's presence state in a channel. Use this to force a status change for specific users.

### presence_where_now
Find out which channels a specific user is currently joined in. This helps you track user activity across multiple rooms.

### publish_message
Send a new JSON message payload to any channel in your network. This lets your agent push live updates to your users.

### delete_message_history
Purge old messages from specific channels to save space. This helps you meet data retention and compliance rules easily.

### generate_file_upload_url
Get a unique URL for uploading files directly to the PubNub network. This makes it easy to handle media in your real-time streams.

### get_all_users
Fetch a complete list of all users currently registered in your app context. Use this to see who has access to your system.

### get_file_url
Retrieve the specific URL for a file stored within a channel. Use this to share media links with your users.

### get_memberships
See which specific memberships are associated with a particular user. This helps you manage permissions and access levels.

### get_user
Pull the profile and data for a specific user in your app context. Use this to check user details instantly.

### get_message_history
Fetch past messages from a channel using specific timestamps. This is perfect for looking up old conversations or auditing activity.

### list_files
See every file currently stored in a specific channel. Use this to manage your media assets and storage.

### get_message_count
Check how many messages have been sent in a channel after a certain time. This helps you track engagement and activity levels.

### pam_grant_token
Issue a PAM v3 token to authorize specific actions. This provides a secure way to grant temporary permissions.

### pam_revoke_token
Cancel an existing PAM v3 token to secure your data. Use this to immediately take away access when it's no longer needed.

### presence_get_state
Check the current presence status of a user in a specific channel. Use this to see if someone is currently active.

### presence_heartbeat
Send a heartbeat to keep a user's presence status active. This prevents users from appearing offline during long sessions.

### presence_leave
Signal that a user is leaving a channel to update the presence list. This ensures your live occupancy data stays accurate.

### push_manage
List or manage push notification channels for a specific device. Use this to configure how users receive mobile alerts.

### push_remove_all
Clear all push notification channels for a device instantly. This is useful for resetting device permissions quickly.

### remove_user
Delete a specific user from your app context. Use this to manage your user base and remove inactive accounts.

### set_channel
Create or update the settings for a specific channel. This lets you manage your channel infrastructure via natural language.

### set_memberships
Update the membership list for a specific user. Use this to change user roles and access permissions.

### set_user
Create or update a user profile in your app context. This makes it easy to manage user data and profiles.

### admin_create_app
Set up a new PubNub app using the admin API. Use this to scale your infrastructure as your needs grow.

### admin_get_metrics
Pull usage metrics and performance data for your apps. This helps you monitor the health of your real-time streams.

### admin_list_apps
See a list of all apps currently registered in your account. Use this to get a high-level view of your PubNub setup.

### admin_list_keysets
View all active keysets within your PubNub account. This is important for auditing your security configurations.

### delete_file
Remove a specific file from a channel's storage. Use this to free up space or remove sensitive media.

### get_all_channels
Get a complete list of all channels in your app context. This gives you a full overview of your messaging structure.

## Prompt Examples

**Prompt:** 
```
Who's in the lobby right now?
```

**Response:** 
```
There are currently 4 people in the 'lobby' channel: **user_12**, **user_88**, **admin_01**, and **guest_04**. They've been active for about 10 minutes.
```

**Prompt:** 
```
Send a message to the 'alerts' channel saying the server is restarting.
```

**Response:** 
```
I've sent that alert. The message was published to 'alerts' with the following details:

* **Message**: System restart initiated
* **Timestamp**: 1715634821000
```

**Prompt:** 
```
Check if the IoT device 'sensor_9' is still sending heartbeats.
```

**Response:** 
```
I checked the presence state for 'sensor_9'. It's currently showing as **online** and last sent a heartbeat 4 seconds ago.
```

## Capabilities

### Push live messages
Your agent can send JSON payloads to any channel instantly to alert users or update systems.

### Track live presence
See who is currently online or joined in specific channels in real-time.

### Manage app context
Let your agent create and update user profiles and channel metadata automatically.

### Retrieve chat history
Pull past messages from any channel using specific timestamps for auditing or context.

### Handle file uploads
Generate secure upload URLs and manage files stored within the network.

### Monitor push metrics
Track your push notification channels and app performance metrics through natural language.

## Use Cases

### IoT Dashboard Monitoring
An engineer asks the agent to check the heartbeat of device X, and the agent uses `presence_heartbeat` to confirm it is online.

### Live Support Queue Management
A manager asks who is waiting in the lobby, and the agent uses `presence_here_now` to list the 5 active users.

### Automated System Alerts
A system architect tells the agent to notify the dev team if the error count hits 10, and the agent uses `publish_message`.

### Compliance Data Audits
A legal lead asks to wipe the chat history for the last month, and the agent uses `delete_message_history`.

## Benefits

- Live interaction: Use `publish_message` to let your agent push updates to users instantly without waiting for a prompt.
- Real-time tracking: Use `presence_here_now` to see exactly who is online in a channel at any given second.
- Dynamic metadata: Manage your entire app context with tools like `set_user` and `set_channel` for a living database.
- Automated cleanup: Keep your logs lean by using `delete_message_history` to purge old data automatically.
- File management: Handle media easily by using `generate_file_upload_url` to give your agent the power to handle uploads.
- Admin oversight: Monitor your entire infrastructure with `admin_get_metrics` to see how your data is flowing.

## How It Works

The bottom line is your agent gets a live seat at the table for your real-time data streams.

1. Connect your PubNub Subscribe Key, Publish Key, and UUID to the Connector.
2. Give your AI client instructions on which channels to monitor or publish to.
3. Watch your agent send live updates and pull real-time presence data instantly.

## Frequently Asked Questions

**Can the PubNub MCP help me see who is online in my app?**
Yes, it uses presence tracking to show you exactly who is currently in a channel or online. You can ask your agent to list everyone in a lobby or check a specific user's status instantly.

**How does the PubNub MCP handle live chat history?**
Your agent can pull past messages from any channel using the history tools. This is great for looking up old conversations or auditing what was said in a specific timeframe.

**Can I use the PubNub MCP to send push notifications?**
Yes, it includes tools to manage and list push notification channels for your devices. You can tell your agent to configure these so your users get live mobile alerts.

**Is the PubNub MCP good for IoT device monitoring?**
It's perfect for that. You can use it to monitor device heartbeats and send control commands back to the devices through real-time channels.

**Can the PubNub MCP help with data compliance?**
Yes, it includes a tool to delete message history. You can ask your agent to purge old logs from specific channels to ensure you're following your data retention policies.

**How do I manage user profiles with the PubNub MCP?**
You can use the app context tools to create, update, or remove users. This allows your agent to manage memberships and user metadata without needing to touch your main database.

**How can I check if a specific user is currently online in a channel?**
You can use the `presence_here_now` tool to see a list of all active UUIDs in a specific channel, or `presence_where_now` to find all channels a specific UUID is currently subscribed to.

**Can the AI retrieve past messages from a channel?**
Yes, the `get_message_history` tool allows the agent to fetch historical messages from one or more channels, including metadata and specific time ranges.

**Is it possible to manage user profiles and metadata through this server?**
Absolutely. You can use `set_user` to create or update profiles and `get_user` to retrieve them. You can also manage channel metadata using `set_channel` and `get_channel`.