PubNub MCP Server

by pubnub
Integrations
  • Provides formatted SDK documentation for PubNub's JavaScript SDK, allowing developers to access reference materials for methods like subscribe() and publish() from within Cursor IDE.

  • Supports PubNub functionality through Node.js, allowing users to publish messages to channels, subscribe to channels, fetch message history, and retrieve presence information.

  • Offers access to PubNub's Python SDK documentation, enabling users to fetch docs for methods like publish() directly through Cursor IDE.

PubNub Model Context Protocol (MCP) Server for Cursor IDE

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.

Example Prompts

  • "Write a PubNub app that lets the user watch streaming videos with built-in multi-user chat with PubNub."
  • "Write a PubNub app for on-demand delivery of groceries with a map."
  • "Write a PubNub app that tracks the location of a package in real-time."
  • "Write a PubNub app that shows the weather forecast in real-time."
  • "Write a PubNub app that lets users play multiplayer games with friends."
  • "Write a PubNub app that shows live stock prices and news updates."
  • "Write a PubNub app that lets users create and share playlists with friends."
  • "Build a PubNub JavaScript app that subscribes to the my_channel channel and logs messages to the console."
  • "Publish a message to the my_channel channel with the message Hello, PubNub!."
  • "Show me the PubNub JavaScript SDK documentation for subscribe()."
  • "List all available PubNub Functions."
  • "Fetch the Python SDK docs for the publish() method."
  • "Fetch the message history for the test channel."
  • "Retrieve presence information (occupancy and UUIDs) for the test channel and the default channel group."

This requires Node.js (>= 18) and npm (https://nodejs.org/). npx will automatically fetch and run the latest MCP server.

Prerequisites

  • Node.js (>= 18) and npm
  • Cursor IDE with MCP support
  • (Optional) PubNub account and API keys for live examples

Installation

The preferred way to run the PubNub MCP server locally or add it to Cursor IDE via npx:

npx -y @pubnub/mcp

Configuration

Cursor must be in AGENT MODE to use MCP servers.

Cursor IDE discovers MCP servers via a JSON config file. Configure the PubNub MCP server globally or per project.

Global Configuration

Edit or create ~/.cursor/mcp.json:

{ "mcpServers": { "pubnub": { "command": "npx", "args": ["-y", "@pubnub/mcp"], "env": { "PUBNUB_PUBLISH_KEY": "YOUR_PUBLISH_KEY", "PUBNUB_SUBSCRIBE_KEY": "YOUR_SUBSCRIBE_KEY" } } } }

Project Configuration

In your project directory, create .cursor/mcp.json:

{ "mcpServers": { "pubnub": { "command": "npx", "args": ["-y", "@pubnub/mcp"], "env": { "PUBNUB_PUBLISH_KEY": "YOUR_PUBLISH_KEY", "PUBNUB_SUBSCRIBE_KEY": "YOUR_SUBSCRIBE_KEY" } } } }

Docker-Based Configuration

If you prefer to run the MCP server via Docker, set your PubNub keys as environment variables:

export PUBNUB_PUBLISH_KEY=YOUR_PUBLISH_KEY export PUBNUB_SUBSCRIBE_KEY=YOUR_SUBSCRIBE_KEY

Then configure your ~/.cursor/mcp.json (or .cursor/mcp.json in your project):

{ "mcpServers": { "pubnub": { "command": "docker", "args": [ "run", "-i", "-e", "PUBNUB_PUBLISH_KEY", "-e", "PUBNUB_SUBSCRIBE_KEY", "pubnub/pubnub-mcp-server" ] } } }
  • command specifies the executable to launch the MCP server.
  • args specifies the arguments to pass to the command.
  • env sets environment variables for the server process.

Using in Cursor IDE

  1. Restart Cursor IDE or open a new session.
  2. Open the MCP settings pane and verify the pubnub server is listed under Available Tools & Resources.
  3. In chat, invoke available resources:
    • pubnub://docs/javascript — Fetch PubNub JavaScript SDK documentation
    • pubnub://docs/python — Fetch PubNub Python SDK documentation
    • pubnub://docs/java — Fetch PubNub Java SDK documentation
    • pubnub://functions — List PubNub Functions (static content from resources/pubnub_functions.md)
  4. Approve resource execution when prompted, or enable auto-run in settings for trusted resources.

Claude Code

## Install the MCP server if you have node >= 18 claude mcp add pubnub -e PUBNUB_PUBLISH_KEY=your_publish_key -e PUBNUB_SUBSCRIBE_KEY=your_subscribe_key -- npx -y @pubnub/mcp ## Install the MCP server if you have node < 18 and need to point to the full path of node claude mcp add pubnub -e PUBNUB_PUBLISH_KEY=your_publish_key -e PUBNUB_SUBSCRIBE_KEY=your_subscribe_key -- /Users/stephen/.nvm/versions/node/v22.14.0/bin/node /Users/stephen/Projects/mcp-pubnub/index.js ## Install the MCP server using Docker # Ensure your PubNub keys are set as environment variables: export PUBNUB_PUBLISH_KEY=your_publish_key export PUBNUB_SUBSCRIBE_KEY=your_subscribe_key # Depending on your machine’s CPU architecture, you may need to specify the target platform. # For example: # docker run --platform linux/arm64 -i pubnub/pubnub-mcp-server # docker run --platform linux/amd64 -i pubnub/pubnub-mcp-server claude mcp add pubnub -- docker run -i \ -e PUBNUB_PUBLISH_KEY=$PUBNUB_PUBLISH_KEY \ -e PUBNUB_SUBSCRIBE_KEY=$PUBNUB_SUBSCRIBE_KEY \ pubnub/pubnub-mcp-server

And the output will be:

Added stdio MCP server pubnub with command: npx -y @pubnub/mcp to local config

Example prompt

claude "publish a message 'hi' to the 'my_channel' pubnub channel."
claude "publish a message 'hi' to the 'my_channel' pubnub channel." ╭───────────────────────────────────────────────────╮ │ ✻ Welcome to Claude Code research preview! │ │ │ │ /help for help, /status for your current setup │ │ │ │ cwd: /Users/stephen/Projects/mcp-pubnub │ ╰───────────────────────────────────────────────────╯ ※ Tip: Press Option+Enter to send a multi-line message > publish a message 'hi' to the 'my_channel' pubnub channel. ⏺ I'll publish a message to the PubNub channel for you. ⏺ pubnub:publish_pubnub_message (MCP)(channel: "my_channel", message: "hi")… ⎿  Message published successfully. Timetoken: 17467422499409217 ⏺ Message published successfully to "my_channel".

Remove the MCP server with:

claude mcp remove pubnub

Using Claude Desktop

If you prefer the Docker-based MCP server in Claude Desktop:

  1. Ensure your PubNub keys are exported in your shell:
    export PUBNUB_PUBLISH_KEY=your_publish_key export PUBNUB_SUBSCRIBE_KEY=your_subscribe_key
  2. In the Tools section of Claude Desktop, add a new tool named pubnub.
  3. Set the Command to docker.
  4. Set Arguments to:
    [ "run", "-i", "-e", "PUBNUB_PUBLISH_KEY", "-e", "PUBNUB_SUBSCRIBE_KEY", "pubnub/pubnub-mcp-server" ]

Note: On some machines (e.g., Apple Silicon), you may need to specify the Docker platform. Insert --platform linux/arm64 (or --platform linux/amd64) immediately after "run" in the Arguments array. For example:

[ "run", "--platform", "linux/arm64", "-i", "-e", "PUBNUB_PUBLISH_KEY", "-e", "PUBNUB_SUBSCRIBE_KEY", "pubnub/pubnub-mcp-server" ]
  1. Save the configuration.

Claude Desktop will invoke the PubNub MCP server container via Docker.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Troubleshooting

  • Must be in agent mode to use MCP servers.
  • Verify Node.js and npm installation.
  • Ensure index.js has execute permission.
  • Check that the command, args, and env settings are correct.
  • Review Cursor IDE logs for MCP startup errors.

Direct JSON-RPC Command-Line Usage

You can invoke the MCP server directly over STDIN/STDOUT using JSON-RPC v2.0. Ensure your PubNub keys are set in the environment, for example:

PUBNUB_PUBLISH_KEY=YOUR_PUBLISH_KEY \ PUBNUB_SUBSCRIBE_KEY=YOUR_SUBSCRIBE_KEY \ node index.js

Once the server is running (or using a one-off invocation), send requests by piping JSON into node index.js. Examples:

# 1) List available tools echo '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' \ | node index.js # 2) Read PubNub JavaScript SDK documentation echo '{"jsonrpc":"2.0","id":2,"method":"tools/call","params": {"name":"read_pubnub_sdk_docs","arguments":{"language":"javascript"}}}' \ | node index.js # 3) Read PubNub Functions Resource docs (static Markdown) echo '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"read_pubnub_resources","arguments":{"document":"pubnub_functions"}}}' \ | node index.js

Quick JSON-RPC Examples

Below are simplified JSON-RPC v2.0 command-line examples using STDIN/STDOUT to fetch PubNub SDK documentation and publish messages.

1) Fetch PubNub JavaScript SDK documentation

echo '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"read_pubnub_sdk_docs","arguments":{"language":"javascript"}}}' | node index.js

2) Publish a message to a PubNub channel

PUBNUB_PUBLISH_KEY=demo \ PUBNUB_SUBSCRIBE_KEY=demo \ echo '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"publish_pubnub_message","arguments":{"channel":"my_channel","message":"Hello, PubNub MCP JSON-RPC!"}}}' \ | node index.js

You must be authenticated.

A
security – no known vulnerabilities
F
license - not found
A
quality - confirmed to work

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

A CLI-based Model Context Protocol server that exposes PubNub SDK documentation and Functions resources to LLM-powered tools like Cursor IDE, enabling users to fetch documentation and interact with PubNub channels via natural language prompts.

  1. Example Prompts
    1. Prerequisites
      1. Installation
        1. Configuration
          1. Global Configuration
          2. Project Configuration
          3. Docker-Based Configuration
        2. Using in Cursor IDE
          1. Claude Code
            1. Example prompt
          2. Using Claude Desktop
            1. License
              1. Troubleshooting
                1. Direct JSON-RPC Command-Line Usage
                  1. Quick JSON-RPC Examples
                    1. 1) Fetch PubNub JavaScript SDK documentation
                    2. 2) Publish a message to a PubNub channel

                  Related MCP Servers

                  • -
                    security
                    F
                    license
                    -
                    quality
                    A simple Model Context Protocol server that enables searching and retrieving relevant documentation snippets from Langchain, Llama Index, and OpenAI official documentation.
                    Last updated -
                    Python
                    • Apple
                    • Linux
                  • -
                    security
                    F
                    license
                    -
                    quality
                    A customized MCP server that enables integration between LLM applications and documentation sources, providing AI-assisted access to LangGraph and Model Context Protocol documentation.
                    Last updated -
                    Python
                    • Linux
                    • Apple
                  • A
                    security
                    A
                    license
                    A
                    quality
                    A Model Context Protocol server that loads multiple OpenAPI specifications and exposes them to LLM-powered IDE integrations, enabling AI to understand and work with your APIs directly in development tools like Cursor.
                    Last updated -
                    7
                    292
                    7
                    TypeScript
                    MIT License

                  View all related MCP servers

                  MCP directory API

                  We provide all the information about MCP servers via our MCP API.

                  curl -X GET 'https://glama.ai/api/mcp/v1/servers/pubnub/pubnub-mcp-server'

                  If you have feedback or need assistance with the MCP directory API, please join our Discord server