Real-time is at the core of everything we do here at PubNub: multiplayer gaming, collaborative document editing, live location tracking, live sports and media scores, and notifications. Now, I’m excited to announce the next step in building real-time scalable applications: the PubNub MCP (Model Context Protocol) Server.
The PubNub MCP Server is designed for Generative Coding (Vibe Coding) with Agents. It is an open-source resource for AI-driven development environments, such as Cursor IDE and Windsurf, helping large language models quickly understand and interact with PubNub’s SDKs and global infrastructure. This means you can ask your AI coding assistant in natural language to "build a real-time chat with presence" or "publish a message to a PubNub channel," and it "just works."
Get ready to spin up real-time apps with PubNub in record time.
Cursor IDE MCP Installation
The easiest way to start with the MCP server is to edit your .cursor/mcp.json
or ~/.cursor/mcp.json
with your PubNub keys.
Claude Code MCP Installation
Claude Code MCP server installation is seamless. Just run a simple command like this:
Make sure you have Node 18+ installed. If you use nvm
, you may need to point to the full path of the node binary and the MCP index.js
file.
The PubNub MCP Server
This Model Context Protocol layer adds important up-to-date details to your AI dev environment with real-time context from PubNub’s SDKs and APIs. It leverages JSON-RPC over STDIN/STDOUT, hooking into your preferred LLM-based editor (like Cursor IDE) for almost magical results:
Ask your LLM: "Write a PubNub app for on-demand grocery delivery."
Watch the LLM AI Agent pull the relevant docs from the PubNub MCP server.
Implement real-time features in far fewer lines of human-written code.
As a result, you cut through the noise, scale quickly, and focus on building user-focused features.
The Challenge of Building Real-Time
Building real-time applications requires more than standard request-response loops. To handle busy traffic, you need low-latency communication channels, efficient message routing and presence, and transparent concurrency and data synchronization.
Wrangling these complexities manually can lead to massive overhead for devs. If you’re also bringing in LLMs to help you code, you need a way to seamlessly feed documentation about PubNub’s architecture into your AI environment. Otherwise, your AI assistant can only guess or rely on stale data.
Do You Even Need To Use An MCP?
You might ask, "Why do I need an MCP server? Can’t I just search the docs or manually copy/paste from the PubNub site?"
Faster Integration: One-liner commands that directly fetch docs and code snippets into your environment.
Zero-Context-Switching: No more alt-tabbing between browser docs and your code editor.
Consistent Updates: The MCP server gives LLMs the newest slices of PubNub knowledge at runtime, ensuring you never rely on stale references.
Please note that this is still an early version of our MCP server. We are actively working to make improvements.
If you’re building in real time, you want every advantage to shorten your development cycle. The PubNub MCP server is all about speed, consistency, and trust.
How It Works
Cursor IDE locates your local MCP server via config files. When you ask a question (e.g., "fetch the PubNub JavaScript SDK docs"), it sends a "tools/call" request to the MCP server. The MCP server responds with the required information, either in parts or directly, giving your LLM exactly what it needs for code generation without context gaps (e.g., "Publish a message to the my_channel channel with message Hello, PubNub!").
MCP Discovery: Cursor IDE scans your config files for available MCP servers and finds your local MCP server definition.
LLM Interaction: When you type "fetch the PubNub JavaScript SDK docs," Cursor IDE calls the MCP server with a JSON-RPC "tools/call" method.
PubNub Response: The MCP server returns the relevant information, chunked or direct, so your LLM sees exactly what it needs.
Your AI:
With that info, your LLM can write you new code, like "Publish a message to the my_channel
channel with message Hello, PubNub!
", with no context gap.
Explore Example Prompts: Ask your AI to "Write a PubNub app for real-time map tracking deliveries."
Common Questions about MCP Servers
What is an MCP Server? An MCP (Model Context Protocol) server allows large language models to fetch custom domain knowledge or actions. In this case, it’s specialized for the PubNub ecosystem, delivering real-time instructions and documentation to your AI tools.
Can I Use It with Other Editors or Tools? Absolutely! While the most straightforward integration is with Cursor IDE, you can pipe JSON-RPC data into or out of any environment you want. Native MCP support is available in Cursor, Windsurf, and Claude Code as of May 2025; it will soon be added to OpenAI’s Codex and Visual Studio Code.
Is This Production-Ready? Yes. Because it’s built on PubNub’s globally distributed platform, you can trust it will handle your traffic at scale. Our initial release of the PubNub MCP server focused on quality code generation. We have plans for an update that is currently in development, and we think you will like it.
Will I Need a PubNub Account? Yes. A PubNub account is necessary to build communication-related apps, such as chat, multiplayer games, delivery apps, and more. You can always leverage our free tier to get started.
What if I have a version of Node earlier than 18? You can still point to a specific Node.js installation path. Just update your mcp.json or tool config to the full path to your node executable.
More MCP Tools On The Way
Real-time is the future (and the present!). With the PubNub MCP Server, we’re making it easier to build blazing-fast, scalable apps, backed by PubNub’s unparalleled data streaming network.
Whether you’re building a streaming video chat, on-demand delivery service, or just want to fetch docs with a single typed command, look no further. Let’s push the boundaries of real-time, together.
Stay Real-Time, Stay Awesome, and happy coding!
Stephen Blum
PubNub CTO
Check out the official PubNub MCP Package on NPM, Docker or GitHub for more!