PubNub MCP Server — Claude Code MCP server: features and setup
Gives AI agents access to PubNub SDK documentation and API tools for managing apps, messages, channels, and user presence.
claude mcp add --env PUBNUB_API_KEY=<PUBNUB_API_KEY> --env PUBNUB_PUBLISH_KEY=<PUBNUB_PUBLISH_KEY> --env PUBNUB_SUBSCRIBE_KEY=<PUBNUB_SUBSCRIBE_KEY> --env PUBNUB_USER_ID=<PUBNUB_USER_ID> --env PUBNUB_EMAIL=<PUBNUB_EMAIL> --transport stdio pubnub-mcp-server -- npx -y @pubnub/mcpWhat PubNub MCP Server does
The server connects an agent to PubNub documentation and API resources. It can help manage applications and keysets, send messages, work with user profiles and channel membership, and inspect presence. Usage data and analytics are also available. Real-time decisioning needs Illuminate; full analytics require Manage Premium.
For Claude Code, the local server runs through npx -y @pubnub/mcp. Its setup command passes API, publish, and subscribe keys, along with either PUBNUB_PASSWORD or PUBNUB_USER_ID and PUBNUB_EMAIL. The local process needs the supplied environment values to receive those credentials. Codex and Cursor are also listed as supported platforms.
What it helps with
- look up an SDK implementation example
- create an app and configure its keyset
- publish a message to a channel
- check user presence in a channel
- review app and keyset usage
Example prompts for the agent
- Find a PubNub SDK example for subscribing to a channel.
- Create a PubNub app and configure a keyset for messaging.
- Show user activity and channel analytics in PubNub.
How to install PubNub MCP Server
Platform CLI
claude mcp add --env PUBNUB_API_KEY=<PUBNUB_API_KEY> --env PUBNUB_PUBLISH_KEY=<PUBNUB_PUBLISH_KEY> --env PUBNUB_SUBSCRIBE_KEY=<PUBNUB_SUBSCRIBE_KEY> --env PUBNUB_USER_ID=<PUBNUB_USER_ID> --env PUBNUB_EMAIL=<PUBNUB_EMAIL> --transport stdio pubnub-mcp-server -- npx -y @pubnub/mcpReplace <…> with your own values. 1 more environment variable is in the server README
Platform CLI
codex mcp add pubnub-mcp-server --env PUBNUB_API_KEY=<PUBNUB_API_KEY> --env PUBNUB_PUBLISH_KEY=<PUBNUB_PUBLISH_KEY> --env PUBNUB_SUBSCRIBE_KEY=<PUBNUB_SUBSCRIBE_KEY> --env PUBNUB_USER_ID=<PUBNUB_USER_ID> --env PUBNUB_EMAIL=<PUBNUB_EMAIL> -- npx -y @pubnub/mcpReplace <…> with your own values. 1 more environment variable is in the server README
Config file
{
"mcpServers": {
"pubnub-mcp-server": {
"command": "npx",
"args": [
"-y",
"@pubnub/mcp"
],
"env": {
"PUBNUB_API_KEY": "<PUBNUB_API_KEY>",
"PUBNUB_PUBLISH_KEY": "<PUBNUB_PUBLISH_KEY>",
"PUBNUB_SUBSCRIBE_KEY": "<PUBNUB_SUBSCRIBE_KEY>",
"PUBNUB_USER_ID": "<PUBNUB_USER_ID>",
"PUBNUB_EMAIL": "<PUBNUB_EMAIL>"
}
}
}
}Replace <…> with your own values. 1 more environment variable is in the server README
Config file
{
"servers": {
"pubnub-mcp-server": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@pubnub/mcp"
],
"env": {
"PUBNUB_API_KEY": "<PUBNUB_API_KEY>",
"PUBNUB_PUBLISH_KEY": "<PUBNUB_PUBLISH_KEY>",
"PUBNUB_SUBSCRIBE_KEY": "<PUBNUB_SUBSCRIBE_KEY>",
"PUBNUB_USER_ID": "<PUBNUB_USER_ID>",
"PUBNUB_EMAIL": "<PUBNUB_EMAIL>"
}
}
}
}Replace <…> with your own values. 1 more environment variable is in the server README
Platform CLI
gemini mcp add -e PUBNUB_API_KEY=<PUBNUB_API_KEY> -e PUBNUB_PUBLISH_KEY=<PUBNUB_PUBLISH_KEY> -e PUBNUB_SUBSCRIBE_KEY=<PUBNUB_SUBSCRIBE_KEY> -e PUBNUB_USER_ID=<PUBNUB_USER_ID> -e PUBNUB_EMAIL=<PUBNUB_EMAIL> pubnub-mcp-server npx -y @pubnub/mcpReplace <…> with your own values. 1 more environment variable is in the server README
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about PubNub MCP Server
How do I install PubNub MCP Server in Claude Code?
Run `claude mcp add mcp-server -e PUBNUB_API_KEY=<PUBNUB_API_KEY> -e PUBNUB_PUBLISH_KEY=<PUBNUB_PUBLISH_KEY> -e PUBNUB_SUBSCRIBE_KEY=<PUBNUB_SUBSCRIBE_KEY> -e PUBNUB_PASSWORD=<PUBNUB_PASSWORD> -- npx -y @pubnub/mcp`. Replace the placeholders with your credentials.
What does PubNub MCP Server do?
It gives an AI agent access to PubNub docs and API resources. The agent can work with apps, messages, channels, user profiles, presence, and usage information.
Which PubNub features have extra requirements?
Real-time decisioning requires Illuminate. Full analytics require Manage Premium.