npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mcp-nats

v0.1.7

Published

MCP server for NATS messaging - publish, subscribe, JetStream, and KV operations

Downloads

608

Readme

NATS MCP Server

npm version npm downloads License: MIT Node.js CI

An MCP (Model Context Protocol) server that exposes NATS messaging capabilities to LLMs like Claude. This enables AI assistants to interact with NATS messaging infrastructure - publishing messages, subscribing, performing request-reply operations, managing JetStream streams and consumers, and working with Key-Value stores.

Features

  • Core NATS Operations: Publish messages, subscribe to subjects, request-reply pattern
  • Real-time Subscriptions: Listen for messages with timeout and max message limits, wildcard support
  • JetStream: Stream management, health monitoring, persistent publishing with acknowledgment
  • Consumer Management: Create, list, pause, resume, fetch, and delete JetStream consumers
  • Key-Value Store: Get, put, delete, and list keys with filtering support
  • Object Store: Store and retrieve large objects with metadata
  • Embedded Documentation: Access NATS documentation directly through tools and resources
  • Resources: Query server info, list streams, KV buckets, and documentation
  • Multiple Transports: Stdio (default) or SSE for network-accessible HTTP server

Requirements

  • Node.js 20+ (or Bun for development)
  • NATS server with JetStream enabled
  • Docker (optional, for running tests)

Installation

Via npx (recommended)

No installation needed - run directly:

npx mcp-nats

Install globally

npm install -g mcp-nats
mcp-nats

From source (for development)

git clone https://github.com/Gooseus/mcp-nats.git
cd mcp-nats
bun install
bun run start

Quick Start

  1. Start a NATS server with JetStream:
docker run -p 4222:4222 nats:latest -js
  1. Run the MCP server:
# Via npx
npx mcp-nats

# Or if installed globally
mcp-nats

# Or from source
bun run start
  1. Or run with HTTP/SSE transport for network access:
npx mcp-nats --transport=sse --port=3000
# Server will be available at http://localhost:3000/mcp
  1. Test with MCP Inspector:
npx @modelcontextprotocol/inspector npx mcp-nats

Configuration

Environment Variables

| Variable | Description | Default | |----------|-------------|---------| | NATS_URL | NATS server URL | nats://localhost:4222 | | NATS_USER | Username for auth | - | | NATS_PASS | Password for auth | - | | NATS_TOKEN | Token authentication | - | | NATS_CREDS_PATH | Credentials file path (NGS/Synadia) | - |

Using Synadia Cloud? See SYNADIA.md for a complete setup guide.

Command Line Options

bun run src/index.ts [options]

Options:
  --transport=<type>  Transport type: 'stdio' (default) or 'sse'
  --port=<port>       HTTP port for SSE transport (default: 3000)
  --host=<host>       Host to bind for SSE transport (default: 0.0.0.0)
  --help, -h          Show help message

Claude Desktop Integration

Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json on Mac):

{
  "mcpServers": {
    "nats": {
      "command": "npx",
      "args": ["mcp-nats"],
      "env": {
        "NATS_URL": "nats://localhost:4222"
      }
    }
  }
}

Or if installed globally:

{
  "mcpServers": {
    "nats": {
      "command": "mcp-nats",
      "env": {
        "NATS_URL": "nats://localhost:4222"
      }
    }
  }
}

Or from source with Bun:

{
  "mcpServers": {
    "nats": {
      "command": "bun",
      "args": ["/absolute/path/to/mcp-nats/src/index.ts"],
      "env": {
        "NATS_URL": "nats://localhost:4222"
      }
    }
  }
}

Available Tools

Core NATS

| Tool | Description | Parameters | |------|-------------|------------| | nats_publish | Publish a message to a subject | subject, payload, headers? | | nats_request | Request-reply pattern | subject, payload, timeout? | | nats_subscribe | Subscribe and collect messages | subject, timeout?, max_messages?, queue? | | nats_server_info | Get NATS server connection info | - |

Key-Value Store

| Tool | Description | Parameters | |------|-------------|------------| | nats_kv_get | Get value from KV bucket | bucket, key | | nats_kv_put | Store value in KV bucket | bucket, key, value | | nats_kv_delete | Delete key from KV bucket | bucket, key | | nats_kv_list_keys | List keys in bucket | bucket, filter? |

JetStream Streams

| Tool | Description | Parameters | |------|-------------|------------| | nats_stream_list | List all JetStream streams | - | | nats_stream_info | Get stream information | stream | | nats_stream_publish | Publish to JetStream | subject, payload | | nats_stream_get_messages | Fetch messages from stream | stream, count?, startSeq? | | nats_stream_health | Get stream health with consumer states | stream, lag_threshold?, ack_pending_threshold? |

JetStream Consumers

| Tool | Description | Parameters | |------|-------------|------------| | nats_consumer_create | Create a consumer | stream, name, deliver_policy?, ack_policy?, filter_subject? | | nats_consumer_info | Get consumer details | stream, consumer | | nats_consumer_list | List consumers for stream | stream | | nats_consumer_delete | Delete a consumer | stream, consumer | | nats_consumer_pause | Pause a consumer | stream, consumer, until? | | nats_consumer_resume | Resume a consumer | stream, consumer | | nats_consumer_fetch | Fetch messages from durable consumer | stream, consumer, batch?, expires? |

Object Store

| Tool | Description | Parameters | |------|-------------|------------| | nats_obj_list_buckets | List all object store buckets | - | | nats_obj_create_bucket | Create a new object store bucket | bucket, description?, max_bytes?, storage?, ttl? | | nats_obj_delete_bucket | Delete an object store bucket | bucket | | nats_obj_list | List objects in a bucket | bucket | | nats_obj_put | Store an object | bucket, name, data, description? | | nats_obj_get | Get an object | bucket, name | | nats_obj_delete | Delete an object | bucket, name | | nats_obj_info | Get object metadata | bucket, name |

Documentation

| Tool | Description | Parameters | |------|-------------|------------| | nats_docs_list | List available NATS documentation topics | - | | nats_docs_read | Read NATS documentation on a topic | topic |

Available Resources

Server Resources

| Resource | URI | Description | |----------|-----|-------------| | Streams | nats://streams | List all JetStream streams with metadata | | KV Buckets | nats://kv | KV bucket information | | Server Info | nats://server | NATS server connection details |

Documentation Resources

| Resource | URI | Description | |----------|-----|-------------| | Subjects | nats://docs/subjects | NATS subject naming conventions and wildcards | | Acks | nats://docs/acks | NATS acknowledgment patterns and semantics | | Pub/Sub | nats://docs/pubsub | Core NATS publish-subscribe patterns | | Request/Reply | nats://docs/reqreply | NATS request-reply messaging pattern | | JetStream | nats://docs/jetstream | JetStream overview and persistence | | Streams | nats://docs/streams | JetStream stream configuration and retention | | Consumers | nats://docs/consumers | JetStream consumer types and policies | | Headers | nats://docs/headers | NATS message headers and metadata | | Key-Value | nats://docs/kv | NATS Key-Value store guide | | Object Store | nats://docs/objectstore | NATS Object store guide |

SSE Transport

The SSE transport allows network clients to connect to the MCP server over HTTP. This enables:

  • Web browser clients
  • Remote connections
  • Multiple concurrent clients
  • Integration with web-based AI tools
# Start with SSE transport
bun run start:sse

# Or with custom port
bun run src/index.ts --transport=sse --port=8080

Endpoints:

  • GET /health - Health check
  • POST /mcp - JSON-RPC endpoint (requires Accept: application/json, text/event-stream)
  • GET /mcp - SSE stream (requires Accept: text/event-stream)

Development

# Run in development mode (with watch)
bun run dev

# Run with SSE in dev mode
bun run dev:sse

# Run tests
bun run test:up      # Start NATS container
bun test             # Run test suite
bun run test:down    # Stop NATS container

# Or all-in-one
bun run test:ci

# Build for Node.js distribution
bun run build

Testing

The project uses Bun's built-in test runner with Docker Compose for the NATS server:

# Start test infrastructure
docker compose up -d

# Run tests (55 tests covering all tools, resources, and transports)
bun test

# Stop test infrastructure
docker compose down

Example Usage

Once connected to Claude Desktop, you can ask Claude to:

  • "Publish a message to the 'orders.new' subject with the order details"
  • "Subscribe to 'events.>' and listen for messages for 10 seconds"
  • "Check what messages are in the ORDERS stream"
  • "Create a consumer on the ORDERS stream that only gets 'orders.important' messages"
  • "List all consumers on the EVENTS stream"
  • "Check the health of the ORDERS stream"
  • "Store this configuration in the 'config' KV bucket under key 'app.settings'"
  • "Store this large file in the 'files' object store bucket"
  • "List all the streams in my NATS server"
  • "Send a request to 'api.users.get' and wait for a response"
  • "Read the NATS documentation on JetStream consumers"

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT

Author

Shawn Marincas (@Gooseus)