Available MCP Tools
The PubNub Model Context Protocol (MCP) Server provides three types of primitives that AI assistants can use:
- Tools, which are functions that perform actions or retrieve data
- Resources, which are data sources that can be read by the AI assistant
- Prompts, which are pre-built prompt templates for common use cases
Tools
The MCP server exposes 11 tools organized into three categories.
| Category | Tools |
|---|---|
| Documentation access | |
| App & Keyset management | |
| Real-time communication |
Documentation access
These tools retrieve SDK documentation to help you understand and implement PubNub features.
get_sdk_documentation
Retrieves SDK documentation for a specific programming language and feature.
| Parameter | Description |
|---|---|
language *Type: String Default: n/a | Programming language to retrieve documentation for. Supported languages: asyncio, c-core, c-sharp, dart, freertos, go, java, javascript, kotlin, mbed, objective-c, php, posix-c, posix-cpp, python, ruby, rust, swift, unity, unreal, windows-c, windows-cpp. |
feature *Type: String Default: n/a | SDK feature to retrieve documentation for. Supported features: access-manager, access-manager-v2, channel-groups, configuration, encryption, files, message-actions, misc, mobile-push, objects, presence, publish-and-subscribe, storage-and-playback. |
Supported features
Not all features are available for all languages. The tool returns an error if you request an unsupported combination.
Sample prompt
Get the JS SDK docs for publish and subscribe.
get_chat_sdk_documentation
Retrieves Chat SDK documentation for a specific programming language and feature.
| Parameter | Description |
|---|---|
language *Type: String Default: n/a | Chat SDK language to retrieve documentation for. Supported languages: javascript, kotlin, swift, unity, unreal. |
feature *Type: String Default: n/a | Chat SDK feature to retrieve documentation for. Supported features: channels-create, channels-delete, channels-details, channels-invite, channels-join, channels-leave, channels-list, channels-membership, channels-typing-indicator, channels-updates, messages-delete, messages-details, messages-drafts, messages-files, messages-forward, messages-history, messages-reactions, messages-read-receipts, messages-send-receive, messages-threads, messages-unread, users-create, users-delete, users-details, users-list, users-mentions, users-presence, users-updates, and more. |
Sample prompt
Get the Swift Chat SDK docs for sending and receiving messages.
how_to
Retrieves PubNub conceptual guides with detailed instructions for implementing specific features and use cases.
| Parameter | Description |
|---|---|
slug *Type: String Default: n/a | Guide identifier. Available guides include topics like Unity/Unreal game development, Chat SDK features, Admin Portal configuration, IoT solutions, presence, push notifications, moderation, and more. |
When to use
Use this tool for overviews, integration instructions, best practices, and troubleshooting tips. For detailed API reference and SDK code samples, also use get_sdk_documentation or get_chat_sdk_documentation.
Sample prompt
Show me how to add real-time chat to my Unity game.
get_best_practices
Retrieves the comprehensive PubNub best practices guide covering architecture, security, channel modeling, and optimization.
The guide covers:
- Architecture and project setup (environments, payload sizes)
- Security (Access Manager tokens, least privilege, PII hygiene)
- Channel and data modeling (naming conventions, message schemas)
- Publish/Subscribe patterns
- History usage
- Client reliability (reconnect, idempotency, ordering)
- Functions and edge logic
- Presence and state
- App Context
- Mobile specifics (push notifications, caching)
- Web specifics (tab lifecycle, Service Workers)
- Observability and operations
- Performance and cost optimization
Sample prompt
What are the best practices for building PubNub applications?
App & Keyset management
These tools manage your PubNub applications and keysets.
manage_apps
Manages PubNub apps with operations: list, create, and update.
| Parameter | Description |
|---|---|
operation *Type: String Default: n/a | Operation to perform: list, create, or update. |
dataType: Object Default: n/a | Operation-specific data. Required for create and update operations. |
Data object by operation
-
list: No data required. -
createField Type Required Description nameString Yes Name of the app to create. -
updateField Type Required Description idString Yes App ID to update. nameString Yes New name for the app.
Sample prompts
List all my PubNub apps.
Create a new PubNub app called MyRealtimeApp.
Rename app 12345 to ProductionApp.
manage_keysets
Manages PubNub keysets with operations: get, list, create, and update. New keysets are created with Message Persistence, App Context, Files, and Presence enabled by default.
| Parameter | Description |
|---|---|
operation *Type: String Default: n/a | Operation to perform: get, list, create, or update. |
dataType: Object Default: n/a | Operation-specific data. Required for get, create, and update. Optional for list. |
Data object by operation
get
| Field | Type | Required | Description |
|---|---|---|---|
id | String | Yes | Keyset ID to retrieve. |
list
| Field | Type | Required | Description |
|---|---|---|---|
appId | String | No | App ID to list keysets for. If not provided, lists keysets for the entire account. |
create
| Field | Type | Required | Description |
|---|---|---|---|
name | String | Yes | Name of the keyset. |
appId | String | No | App ID to create keyset in. If not provided, a new app is created. |
type | String | Yes | Keyset type: testing for testing/development or production for live environments. |
config | Object | Yes | Keyset feature configuration. Refer to the Config object section below. |
update
| Field | Type | Required | Description |
|---|---|---|---|
id | String | Yes | Keyset ID to update. |
config | Object | Yes | Config to update. Same structure as for create. |
Config object
The config object contains four optional sub-objects for configuring keyset features:
messagePersistence- Message storage configuration:
| Field | Type | Required | Description |
|---|---|---|---|
enabled | Boolean | Yes | Enable or disable message persistence. |
retention | Number | Conditional | Days to retain messages (1, 7, 30, 90, 180, 365, or 0 for unlimited). Required when enabled=true. |
includePresenceEvents | Boolean | No | Store presence event messages in history. |
deleteFromHistory | Boolean | No | Allow API calls to delete specific messages from history. |
appContext- User and channel metadata configuration:
| Field | Type | Required | Description |
|---|---|---|---|
enabled | Boolean | Yes | Enable or disable App Context (Objects). |
region | String | Conditional | Storage region. Required when enabled=true. Cannot be changed once set. Values: aws-iad-1, aws-pdx-1, aws-fra-1, aws-bom-1, aws-hnd-1. |
userMetadataEvents | Boolean | No | Trigger events when user metadata changes. |
channelMetadataEvents | Boolean | No | Trigger events when channel metadata changes. |
membershipEvents | Boolean | No | Trigger events when memberships are added, updated, or removed. |
disallowGetAllChannelMetadata | Boolean | No | Disallow the "Get All Channel Metadata" call. |
disallowGetAllUserMetadata | Boolean | No | Disallow the "Get All User Metadata" call. |
referentialIntegrity | Boolean | No | Require user/channel to exist before creating memberships. |
files- File sharing configuration:
| Field | Type | Required | Description |
|---|---|---|---|
enabled | Boolean | Yes | Enable or disable file sharing. |
region | String | Conditional | Storage region. Required when enabled=true. Cannot be changed once set. Values: us-east-1, us-west-1, eu-central-1, ap-south-1, ap-northeast-1. |
retention | Number | Conditional | Days to retain files (1, 7, 30, or 0 for unlimited). Required when enabled=true. |
presence- Real-time subscriber tracking configuration:
| Field | Type | Required | Description |
|---|---|---|---|
enabled | Boolean | Yes | Enable or disable presence. |
announceMax | Number | No | Max occupants before switching to occupancy counts (0-100). |
interval | Number | No | Seconds between occupancy announcements (min 10). |
deltas | Boolean | No | Include joined/left UUIDs in interval events. |
generateLeaveOnDisconnect | Boolean | No | Trigger leave events on connection close. |
streamFiltering | Boolean | No | Filter presence events at client level. |
activeNoticeChannel | String | No | Channel for active/inactive notifications. |
debounce | Number | No | Seconds to wait before allowing joins after leaves. |
Immutable settings
The region settings in appContext and files cannot be changed after the keyset is created. Always confirm these values with the user before creating a keyset.
Sample prompts
Get details for keyset abc123.
List all keysets for app 12345.
Create a production keyset with Message Persistence (30 days retention), Presence, and App Context in US East.
Enable Presence with interval events on keyset 67890.
Real-time communication
These tools interact with PubNub's real-time messaging infrastructure for publishing, subscribing, and managing presence and App Context data.
Optional keys with fixed mode
When PUBNUB_PUBLISH_KEY and PUBNUB_SUBSCRIBE_KEY environment variables are configured, the publishKey and subscribeKey parameters are not required for these tools. The server automatically uses the configured keys. Refer to PubNub keys configuration for details.
send_pubnub_message
Sends a message or signal to a PubNub channel. Returns a publish timetoken confirming successful delivery.
| Parameter | Description |
|---|---|
channel *Type: String Default: n/a | Channel to publish to. |
message *Type: String or Object Default: n/a | Message payload (string or JSON object). |
typeType: String Default: message | Type of message: message (regular) or signal (lightweight). |
publishKey *Type: String Default: n/a | Publish key from your keyset. |
subscribeKey *Type: String Default: n/a | Subscribe key from your keyset. |
Signals
Signals are limited to 64 bytes and are not stored in message history. Use them for lightweight, ephemeral data like typing indicators.
Sample prompt
Send "Hello, World!" to the chat-room channel.
subscribe_and_receive_pubnub_messages
Subscribes to a channel and waits for messages. Returns an array of received messages with their content and metadata.
| Parameter | Description |
|---|---|
channel *Type: String Default: n/a | Channel to subscribe to. |
messageCountType: Number Default: 1 | Number of messages to wait for before returning. |
timeoutType: Number Default: 10 | Maximum wait time in seconds. Maximum value is 30. |
publishKey *Type: String Default: n/a | Publish key from your keyset. |
subscribeKey *Type: String Default: n/a | Subscribe key from your keyset. |
Sample prompt
Subscribe to the notifications channel and wait for 3 messages.
get_pubnub_messages
Retrieves historical messages from channels using Message Persistence. Returns historical messages with content, timetokens, and metadata.
| Parameter | Description |
|---|---|
channels *Type: Array Default: n/a | List of channel names to fetch history from. |
startType: String Default: n/a | Start timetoken (exclusive) for pagination. |
endType: String Default: n/a | End timetoken (inclusive) for pagination. |
countType: Number Default: 100 | Number of messages to return per channel. |
publishKey *Type: String Default: n/a | Publish key from your keyset. |
subscribeKey *Type: String Default: n/a | Subscribe key from your keyset. |
Sample prompt
Get the last 50 messages from the chat-room channel.
get_pubnub_presence
Retrieves real-time Presence information. Returns presence data including occupancy counts and user UUIDs.
| Parameter | Description |
|---|---|
channelsType: Array Default: [] | Channels to query presence for (HereNow). |
channelGroupsType: Array Default: [] | Channel groups to query presence for. |
uuidType: String Default: n/a | UUID to query channel subscriptions for (WhereNow). |
publishKey *Type: String Default: n/a | Publish key from your keyset. |
subscribeKey *Type: String Default: n/a | Subscribe key from your keyset. |
Sample prompt
How many users are in the lobby channel?
manage_app_context
Performs CRUD operations on App Context objects.
| Parameter | Description |
|---|---|
type *Type: String Default: n/a | Object type: user, channel, or membership. |
operation *Type: String Default: n/a | Operation: get, set, remove, or getAll. |
id *Type: String Default: n/a | Identifier: UUID for user and membership operations, channel ID (for example, team.red) for channel metadata and channel member operations. |
publishKey *Type: String Default: n/a | Publish key from your keyset. |
subscribeKey *Type: String Default: n/a | Subscribe key from your keyset. |
dataType: Object Default: n/a | Data for set/remove operations. Refer to the data object tables for more details. |
optionsType: Object Default: n/a | Additional options like filters, pagination, and includes. |
User data object (for type: "user")
For details, refer to User metadata.
| Field | Type | Description |
|---|---|---|
name | String | User's display name. |
email | String | User's email address. |
externalId | String | External system identifier. |
profileUrl | String | URL to profile picture. |
type | String | User type. |
status | String | User status. |
custom | Object | Custom key-value pairs (scalar values only). |
Channel data object (for type: "channel")
For details, refer to Channel metadata.
| Field | Type | Description |
|---|---|---|
name | String | Channel display name. |
description | String | Channel description. |
type | String | Channel type. |
status | String | Channel status. |
custom | Object | Custom key-value pairs (scalar values only). |
Membership data object (for type: "membership")
For details, refer to Membership metadata.
For setting memberships, provide:
{
"channels": ["channel-1", "channel-2"]
}
Or with custom data:
{
"channels": [
{ "id": "channel-1", "custom": { "role": "admin" } }
]
}
Sample prompts
Create a user profile for UUID user-123 with name John Doe.
Add user-123 to the general-chat channel.
List all members of the team-red channel.
Resources
Resources provide read-only access to documentation through URI-based lookups.
pubnub_sdk_docs
Access PubNub SDK documentation.
| Property | Value |
|---|---|
| URI format | pubnub-docs://sdk/{language}/{feature} |
| Supported languages | 22 programming languages |
| Supported features | 13 feature categories |
Sample URI
pubnub-docs://sdk/javascript/publish-and-subscribe
pubnub_chat_sdk_docs
Access PubNub Chat SDK documentation.
| Property | Value |
|---|---|
| URI format | pubnub-docs://chat-sdk/{language}/{feature} |
| Supported languages | JavaScript, Kotlin, Swift, Unity, Unreal |
| Supported features | 40+ feature categories |
Sample URI
pubnub-docs://chat-sdk/swift/messages-send-receive
Prompt templates
The MCP server includes pre-built prompt templates for common use cases which you can use as a starting point for your own prompts.
Healthcare and HIPAA compliance
Build secure, compliant chat applications using PubNub's Pub/Sub messaging, Presence, and App Context features.
hipaa-chat-short
Quick prompt to create a HIPAA-compliant chat application.
Generated prompt
Act as a senior software engineer and use PubNub MCP server to create a chat application for healthcare that is HIPAA compliant.
hipaa-chat-long
Detailed prompt for HIPAA-compliant chat with specific feature requirements.
Generated prompt
Act as a senior software engineer and use PubNub MCP server to create a chat application for healthcare that is HIPAA compliant, with Pub/Sub messaging for real-time chat, Presence for patient/doctor availability, and App Context for roles.
React development
react-app-short
Scaffold a basic React application with PubNub.
Generated prompt
Act as a frontend developer and use PubNub MCP server to scaffold a React app with Pub/Sub messaging and Presence.
react-app-long
Comprehensive React application with real-time features like Pub/Sub messaging, Presence, and App Context.
Generated prompt
Act as a frontend developer and use PubNub MCP server to scaffold a React app with Pub/Sub messaging for real-time updates, Presence to show when users are online or typing, and App Context to handle user metadata. Include sample React components for subscribing to a channel, publishing messages, and displaying presence indicators for active participants.
Gaming applications
Build multiplayer game lobbies using PubNub's Unity or Unreal SDKs.
gamelobby-short
Build a multiplayer game lobby with basic features.
Generated prompt
Act as a game developer and use PubNub MCP server to build a multiplayer lobby with chat and Presence indicators.
gamelobby-long
Advanced multiplayer lobby with team management.
Generated prompt
As a game developer, use PubNub MCP server to build a multiplayer game lobby that supports real-time chat using Pub/Sub, Presence for tracking when players come online or leave, and App Context for managing team assignments (e.g., red vs. blue team).
OEM and multi-tenant solutions
These prompts help with programmatic account management for OEM and multi-tenant use cases.
oem-client-management
Create apps and configure keysets for OEM (building resources used by someone else) client deployments.
Generated prompt
[OEM (building resources used by someone else)] As a developer, use PubNub MCP to create a new app, configure and assign keysets to clients.
multi-tenant-onboarding-short
Implement automated tenant onboarding for SaaS applications.
Generated prompt
[OEM] Act as a senior developer and use PubNub MCP server to implement automated tenant onboarding for a multi-tenant chat application in SaaS or healthcare industries.
multi-tenant-onboarding-long
Enterprise-grade multi-tenant onboarding with data isolation and error handling.
Generated prompt
Act as a senior developer and use PubNub MCP (which leverages Admin API for Keysets and Usage & Monitoring) to implement a multi-tenant chat application with automated tenant onboarding. The tenant Application will use: pubsub, History, App-Context, Presence For every new tenant or end-customer the application should: Create a new App (if required by your OEM model). Create and configure a new Keyset to ensure data isolation Make sure publish and subscribe keys are properly retrieved and propagated to the tenant's application as configuration variables The implementation should be fully automated, idempotent, and include error handling, and retries.