GitHub - pubnub/pubnub-mcp-server: PubNub MCP Model Context Protocol Server for use in Cursor, Windsurf, Claude Desktop, Claude Code and OpenAI Codex and more! (original) (raw)

PubNub MCP Server v2

This repository provides a CLI-based Model Context Protocol (MCP) server that exposes PubNub SDK documentation and PubNub API resources to LLM-powered tools. This improves the LLM AI Agent's ability to understand and interact with PubNub's SDKs and APIs.

PubNub MCP Server v2

Features

Quick Start

API Key

Before you begin, we highly recommend creating a Service Integration in the PubNub Admin Portal and providing your API key to the MCP server. While some basic features will work without it, adding an API key unlocks much more functionality. Alternatively, see Advanced Usage for instructions on configuring the server to work with a single PubNub keyset.

The installation process for an MCP server depends on the AI assistant you’re using. For the standard setup, you’ll need Node.js.

VS Code

Open in VS Code

Just click the link above, then select “Open in Visual Studio Code” on the page that appears. Back in VS Code, click “Install”. You’ll be prompted to enter your PubNub API Key. Once provided, your MCP server is ready to use. For additional configuration options, see Advanced usage.

Cursor

Add to Cursor

Click the link above, then select "Open Cursor" on the page that appears. Back in Cursor, there's a "Install MCP Server?" prompt. Make sure to provide the value for variable holding your PubNub API Key. Once you do, click "Install". Your MCP server is now ready to use. For additional configuration options, see Advanced usage.

Claude

With Claude installed run this command to have the MCP added to your configuration. Make sure to replace the value of <your-api-key>:

claude mcp add --env PUBNUB_API_KEY=<your-api-key> --scope user --transport stdio PubNub -- npx -y @pubnub/mcp@latest

Server is added in the "User" scope which means it will be available accross all projects. For additional configuration options, see Advanced usage.

Advanced usage

Configuration

PubNub Keys Configuration

The MCP server supports two modes for handling PubNub publish/subscribe keys:

Dynamic Mode (No env keys set)

When PUBNUB_PUBLISH_KEY and PUBNUB_SUBSCRIBE_KEY are not provided, the server operates in dynamic mode:

This mode is ideal when you want the AI to help manage multiple applications or when the keyset should be determined at runtime.

Fixed Mode (Env keys set)

When both PUBNUB_PUBLISH_KEY and PUBNUB_SUBSCRIBE_KEY are provided, the server operates in fixed mode:

This mode is ideal for focused workflows where you're working with a specific application and want streamlined interactions.

Example configuration with fixed keys:

{ "env": { "PUBNUB_API_KEY": "", "PUBNUB_PUBLISH_KEY": "pub-c-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "PUBNUB_SUBSCRIBE_KEY": "sub-c-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } }

Docker-Based Usage

If you prefer to run the MCP server via Docker, use the snippet below in your editor's config file mcpServers or servers section of the mcp.json:

{ "mcpServers": { "PubNub": { "command": "docker", "args": [ "run", "-i", "--rm", "-e", "PUBNUB_API_KEY", "pubnub/pubnub-mcp-server" ], "env": { "PUBNUB_API_KEY": "", } } } }

API Reference

This PubNub MCP server provides a comprehensive set of tools, resources, and prompts to help you build real-time applications. Below is a complete reference of all available functionality:

Tools

Documentation Access

Account & App Management

Keyset Management

Real-time Communication

Other PubNub features

Prompts

Healthcare & HIPAA Compliance

React Development

Gaming Applications

OEM & Multi-Tenant Solutions

Resources

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

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 Languages: javascript, kotlin, swift, unity, unreal

Supported Features: channels-create, channels-delete, channels-details, channels-invite, channels-join, channels-leave, channels-list, channels-membership, channels-references, channels-typing-indicator, channels-updates, channels-watch, connection-management, custom-events, error-logging, messages-delete, messages-details, messages-drafts, messages-files, messages-forward, messages-history, messages-links, messages-moderation, messages-pinned, messages-quotes, messages-reactions, messages-read-receipts, messages-restore, messages-send-receive, messages-threads, messages-unread, messages-updates, moderation, push-notifications, users-create, users-delete, users-details, users-list, users-mentions, users-moderation, users-moderation-user, users-permissions, users-presence, users-updates, utility-methods