PU
OfficialAI & ML

PubNub MCP Server for Cursor IDE and Claude

Enable LLM tools to access PubNub SDK docs and APIs with an MCP server for Cursor IDE and Claude, improving AI agent understanding and integration.

Quick Install
npx -y @pubnub/mcp

Overview

The PubNub MCP Server is a Model Context Protocol (MCP) adapter that exposes PubNub SDK documentation, code samples, and API resources to LLM-powered developer tools (Cursor IDE, Claude, Codex, VS Code MCP extensions, etc.). By serving structured PubNub context over MCP, the server helps AI assistants understand PubNub concepts (keysets, channels, presence, persistence, file transfer, etc.) and enables agents to guide or automate integration tasks more accurately.

The server runs as a lightweight CLI (or container) and can operate in two modes: a documentation-only mode that enriches LLM responses with SDK docs and examples, and a key-enabled mode that also allows realtime operations and account-level actions when appropriate keys are supplied. This makes it useful both for code-completion and for agent-driven workflows that need to query or manipulate PubNub resources.

Features

  • Access to PubNub SDK documentation and code examples for 20+ languages (JS, Python, Java, Swift, Kotlin, C#, Go, Ruby, etc.)
  • Exposes PubNub REST API resources and endpoint descriptions for LLM consumption
  • App and keyset creation / management (when a PubNub API key is provided)
  • Realtime operations support (publish/subscribe, signals) when publish/subscribe keys are set
  • Presence, user/channel metadata, membership, and persistence management guidance and examples
  • Works with Cursor, Claude Code, VS Code MCP installers, Codex and other MCP-compatible tools
  • TypeScript codebase, CLI entrypoint, and optional Docker image for deployment

Installation / Configuration

Requirements:

  • Node.js v20.0.0 or higher (for CLI install)
  • Docker (optional, for running as a container)

Install and run via npx (recommended for quick start):

# start server via npx (single-run, auto-download)
npx -y @pubnub/mcp@latest

Run with environment variables (example):

PUBNUB_API_KEY=pn-XXXXXXXXXXXX npx -y @pubnub/mcp@latest

Docker run example:

docker run --rm -e PUBNUB_API_KEY=pn-XXXXXXXXXXXX ghcr.io/pubnub/pubnub-mcp-server:latest

Claude Code / MCP add example:

# adds MCP server to Claude configuration (user scope)
claude mcp add PubNub --env PUBNUB_API_KEY=<your-api-key> --scope user --transport stdio -- npx -y @pubnub/mcp@latest

VS Code (MCP install link or npx command):

# From a terminal or task, install the MCP for VS Code usage
npx -y @pubnub/mcp@latest

Gemini CLI settings.json snippet:

"mcpServers": {
  "pubnub": {
    "command": "npx",
    "args": ["-y","@pubnub/mcp@latest"],
    "env": {"PUBNUB_API_KEY":"<your-api-key>"}
  }
}

Configuration environment variables

VariablePurpose
PUBNUB_API_KEYRecommended: Service Integration API key for account/keyset management
PUBNUB_PUBLISH_KEYOptional: publish key for realtime publish operations
PUBNUB_SUBSCRIBE_KEYOptional: subscribe key for realtime subscribe operations
PUBNUB_USER_IDOptional: user id for realtime SDK actions (default: pubnub-mcp)
PUBNUB_EMAIL (deprecated)Legacy email login (prefer API key)
PUBNUB_PASSWORD (deprecated)Legacy password login (prefer API key)

If publish/subscribe keys are not provided, the server still serves docs and API descriptions but will not perform live realtime actions on your behalf.

Available Resources

When connected, the MCP server exposes structured resources and tools useful to LLM agents:

  • SDK documentation and language-specific code examples
  • REST API endpoint descriptions, parameters and response shapes
  • Keyset and application management operations (create, update, delete)
  • Channels, messages, signals, and presence workflows
  • User/profile, channel metadata and membership APIs
  • Persistence and file-API usage examples
  • Example snippets for common tasks (chat, notifications, presence)

These resources are provided in a format MCP-compatible tools can query, summarize, and include in generated code or guidance.

Use Cases

  • AI-assisted integration: A Claude or Cursor agent can read the SDK docs and generate idiomatic code snippets (e.g., publish/subscribe examples for JavaScript or Python) tailored to your keyset and user ID.
  • Troubleshooting and guidance: Ask an LLM-enabled IDE to explain PubNub error codes, show the correct REST parameters for message persistence, or suggest migration steps between SDK versions.
  • Automated setup: Use the MCP + API key to let an assistant create a PubNub application and keyset, enable persistence, and output ready-to-use client configuration blocks.
  • Realtime demo generation: Quickly scaffold a small chat demo using language-specific SDK examples provided by the MCP server.
  • Documentation-aware code completion: Improve code-completion quality by giving the language model direct access to official SDK docs and examples for the exact API surface it needs to call.

Getting help and source

Source, issues and contribution instructions are on the project repository: https://github.com/pubnub/pubnub-mcp-server

For implementation-specific questions, open issues or follow the README and examples in the repo.