NATS MCP Server
@bmorphism
MCP server for NATS messaging system using NATS CLI - enabling AI agents to interact with NATS messaging
Overview
What is NATS MCP Server?
NATS MCP Server is a Model Context Protocol server that provides access to NATS, a cloud-native messaging system, through the NATS CLI. It enables AI models to publish, subscribe to, and request-reply over NATS subjects.
How to use NATS MCP Server?
Install via npm (npm install @modelcontextprotocol/nats-mcp-server) or build from source. Configure with the NATS_URL environment variable (default nats://localhost:4222). Add the server to your MCP client’s configuration (e.g., Cline or Claude Desktop) and then invoke its tools: publish, subscribe, or request.
Key features of NATS MCP Server
- Publish messages with headers, templates, and reply subjects
- Subscribe to subjects with configurable timeouts and message counts
- Request-reply pattern support with optional headers
- Go template functions for dynamic message content
- Full NATS CLI integration and robust error handling
Use cases of NATS MCP Server
- AI assistants sending commands or events via NATS subjects
- Implementing request-reply service calls (e.g., asking a service for the time)
- Broadcasting messages to multiple subscribers with templates or headers
- Testing and debugging NATS messaging patterns from an MCP client
FAQ from NATS MCP Server
What are the required dependencies?
Node.js >= 14.0.0 and the NATS CLI (nats) installed on the system.
How do I install the NATS CLI?
Installation varies by OS: Homebrew on macOS (brew install nats), snap install nats on Linux, Chocolatey or Scoop on Windows, or build from source with Go.
How do I configure the NATS server URL?
Set the NATS_URL environment variable before starting the MCP server. Default is nats://localhost:4222.
What MCP tools does the server offer?
Three tools: publish (send messages with optional headers, templates, and reply subjects), subscribe (receive messages with timeout and count limits), and request (send a request and wait for a reply with optional headers).
Can I use templates in messages?
Yes. When template: true is set on publish, the message can use functions like {{Count}}, {{Time}}, {{Random min max}}, and others.