PubNub MCP Server

The PubNub Model Context Protocol (MCP) Server is an open-source tool that enables AI-powered development environments to interact with PubNub's SDKs and global infrastructure. It allows you to build, use, and troubleshoot real-time applications faster by describing your app's behavior in natural language.

With the PubNub MCP Server, you can:

  • Build real-time applications without extensive PubNub SDK knowledge
  • Use AI-powered environments (like Cursor IDE, Claude Code, or Claude Desktop) to understand and implement PubNub APIs
  • Access PubNub's resources dynamically, including SDK documentation and code examples
  • Leverage AI agents as coding assistants to build, test, and troubleshoot your applications

For example, you can ask your AI coding assistant to build a real-time chat with presence or publish a message to a PubNub channel using plain English descriptions.

Prerequisites

Before you begin, ensure you have:

Supported AI agents

The PubNub MCP Server is compatible with:

Setup

To set up the PubNub MCP Server, follow these steps:

To set up the PubNub MCP Server with Cursor IDE, follow these steps:

  1. Create a PubNub account on the Admin Portal, and create a new app and keyset.

  2. In your Cursor project, create or open the .cursor/mcp.json or ~/.cursor/mcp.json files and add your publish and subscribe keys:

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

    When you save the file, a notification is displayed. Cursor MCP Server Notification

  3. In the prompt, click Enable. Then, navigate to Cursor Settings (the gear icon in top right corner) -> MCP, and check if pubnub is enabled. Cursor MCP Server Settings

  4. Ask the AI agent to build your PubNub-powered app for you by describing the functionality yourself or by using a sample prompt.

Agent mode

Make sure to use the Agent mode. Depending on your Cursor rules, you may also need to explicitly ask the AI agent to use the PubNub MCP server.

Sample prompts

Happy vibe coding!

  • "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."
Last updated on