{"id":25368583,"url":"https://github.com/bmorphism/nats-mcp-server","last_synced_at":"2025-07-13T15:34:08.160Z","repository":{"id":271755849,"uuid":"913047274","full_name":"bmorphism/nats-mcp-server","owner":"bmorphism","description":"MCP server for NATS messaging system using NATS CLI - enabling AI agents to interact with NATS messaging","archived":false,"fork":false,"pushed_at":"2025-01-06T23:33:41.000Z","size":2,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-06T13:16:42.198Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bmorphism.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-06T23:31:34.000Z","updated_at":"2025-04-04T04:26:25.000Z","dependencies_parsed_at":"2025-01-10T10:31:57.309Z","dependency_job_id":null,"html_url":"https://github.com/bmorphism/nats-mcp-server","commit_stats":null,"previous_names":["bmorphism/nats-mcp-server"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmorphism%2Fnats-mcp-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmorphism%2Fnats-mcp-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmorphism%2Fnats-mcp-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmorphism%2Fnats-mcp-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bmorphism","download_url":"https://codeload.github.com/bmorphism/nats-mcp-server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247987233,"owners_count":21028895,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-15T00:39:16.925Z","updated_at":"2025-04-09T06:19:10.836Z","avatar_url":"https://github.com/bmorphism.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# NATS MCP Server\n\nAn MCP (Model Context Protocol) server that provides access to [NATS](https://nats.io/), a cloud native messaging system, through the NATS CLI.\n\n## Features\n\n- Publish messages with advanced options (headers, templates, reply subjects)\n- Subscribe to subjects with configurable timeouts and message counts\n- Request-reply pattern support with headers\n- Full NATS CLI integration\n- Error handling and cleanup\n\n## Requirements\n\n- Node.js \u003e= 14.0.0\n- NATS CLI (nats)\n\n### Installing NATS CLI\n\n#### macOS\n\nUsing Homebrew:\n```bash\nbrew tap nats-io/nats-tools\nbrew install nats-io/nats-tools/nats\n```\n\n#### Linux\n\nUsing snap:\n```bash\nsnap install nats\n```\n\nUsing apt (Debian/Ubuntu):\n```bash\n# First, add the NATS repository\necho \"deb https://dl.nats.io/nats-io/repo/deb nats release\" | sudo tee /etc/apt/sources.list.d/nats.list\ncurl -fsSL https://dl.nats.io/nats-io/repo/deb/gpg.key | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/nats.gpg\n\n# Then install\nsudo apt-get update\nsudo apt-get install nats-server\n```\n\nUsing yum (RHEL/CentOS):\n```bash\n# Add the NATS repository\necho \"[nats]\nname=NATS Repository\nbaseurl=https://dl.nats.io/nats-io/repo/rpm/centos/\\$releasever/\\$basearch\ngpgcheck=1\ngpgkey=https://dl.nats.io/nats-io/repo/rpm/gpg.key\nenabled=1\" | sudo tee /etc/yum.repos.d/nats.repo\n\n# Install\nsudo yum install nats-server\n```\n\n#### Windows\n\nUsing Chocolatey:\n```powershell\nchoco install nats-io-client\n```\n\nUsing Scoop:\n```powershell\nscoop bucket add nats https://github.com/nats-io/scoop-bucket.git\nscoop install nats\n```\n\nManual installation:\n1. Download the latest release from [NATS CLI Releases](https://github.com/nats-io/natscli/releases)\n2. Extract the archive\n3. Add the binary to your system PATH\n\n#### Building from Source\n\nIf packages are not available for your system:\n```bash\n# Requires Go 1.16+\ngo install github.com/nats-io/natscli/nats@latest\n```\n\n### Verifying Installation\n\nAfter installation, verify the CLI works:\n```bash\n# Check version\nnats --version\n\n# Test connection to default server\nnats ping\n\n# List available commands\nnats help\n```\n\n## Installation\n\n```bash\n# Install from npm\nnpm install @modelcontextprotocol/nats-mcp-server\n\n# Or clone and build from source\ngit clone https://github.com/bmorphism/nats-mcp-server.git\ncd nats-mcp-server\nnpm install\nnpm run build\n```\n\n## Configuration\n\nThe server can be configured using environment variables:\n\n- `NATS_URL`: NATS server URL (default: 'nats://localhost:4222')\n\n## Usage\n\nThe server provides the following MCP tools:\n\n### publish\n\nPublish a message to a NATS subject with advanced options.\n\nParameters:\n- `subject` (required): NATS subject to publish to\n- `message` (required): Message to publish\n- `reply` (optional): Reply subject for request-reply patterns\n- `headers` (optional): Array of message headers (key-value pairs)\n- `count` (optional): Number of messages to publish\n- `sleep` (optional): Sleep duration between messages (e.g., \"100ms\")\n- `template` (optional): Enable Go template processing in message\n\nExample with templates:\n```typescript\nconst result = await mcp.useTool(\"nats\", \"publish\", {\n  subject: \"greetings\",\n  message: \"Message {{Count}} @ {{Time}}\",\n  count: 5,\n  sleep: \"1s\",\n  template: true\n});\n```\n\nExample with headers:\n```typescript\nconst result = await mcp.useTool(\"nats\", \"publish\", {\n  subject: \"orders\",\n  message: \"New order received\",\n  headers: [\n    { key: \"OrderId\", value: \"12345\" },\n    { key: \"Priority\", value: \"high\" }\n  ]\n});\n```\n\n### subscribe\n\nSubscribe to a NATS subject and receive messages.\n\nParameters:\n- `subject` (required): NATS subject to subscribe to\n- `timeout` (optional): Subscription timeout in milliseconds (default: 5000)\n- `count` (optional): Number of messages to receive before exiting\n- `raw` (optional): Show only message payload\n\nExample:\n```typescript\nconst result = await mcp.useTool(\"nats\", \"subscribe\", {\n  subject: \"greetings\",\n  timeout: 10000,\n  count: 5,\n  raw: true\n});\n```\n\n### request\n\nSend a request message and wait for a reply.\n\nParameters:\n- `subject` (required): NATS subject to send request to\n- `message` (required): Request message\n- `timeout` (optional): Request timeout in milliseconds (default: 5000)\n- `headers` (optional): Array of request headers (key-value pairs)\n\nExample:\n```typescript\nconst result = await mcp.useTool(\"nats\", \"request\", {\n  subject: \"service.time\",\n  message: \"What time is it?\",\n  timeout: 3000,\n  headers: [\n    { key: \"Locale\", value: \"en-US\" }\n  ]\n});\n```\n\n## Template Functions\n\nWhen using templates (template: true), the following functions are available:\n\n- `Count`: Message number\n- `TimeStamp`: RFC3339 format current time\n- `Unix`: Seconds since 1970 in UTC\n- `UnixNano`: Nano seconds since 1970 in UTC\n- `Time`: Current time\n- `ID`: Unique ID\n- `Random(min, max)`: Random string between min and max length\n\nExample with random strings:\n```typescript\nconst result = await mcp.useTool(\"nats\", \"publish\", {\n  subject: \"test\",\n  message: \"Random data: {{ Random 10 100 }}\",\n  template: true\n});\n```\n\n## Adding to MCP Configuration\n\n### For Cline (VSCode Extension)\n\nAdd to `~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json`:\n\n```json\n{\n  \"mcpServers\": {\n    \"nats\": {\n      \"command\": \"node\",\n      \"args\": [\"/path/to/nats-mcp-server/build/index.js\"],\n      \"env\": {\n        \"NATS_URL\": \"nats://localhost:4222\"\n      }\n    }\n  }\n}\n```\n\n### For Claude Desktop\n\nAdd to `~/Library/Application Support/Claude/claude_desktop_config.json`:\n\n```json\n{\n  \"mcpServers\": {\n    \"nats\": {\n      \"command\": \"node\",\n      \"args\": [\"/path/to/nats-mcp-server/build/index.js\"],\n      \"env\": {\n        \"NATS_URL\": \"nats://localhost:4222\"\n      }\n    }\n  }\n}\n```\n\n## Error Handling\n\nThe server includes robust error handling for:\n- Connection failures\n- Invalid parameters\n- Timeouts\n- Network errors\n- NATS-specific errors\n- CLI execution errors\n\n## Development\n\nTo build the project:\n\n```bash\nnpm run build\n```\n\nThe build output will be in the `build` directory.\n\n## Contributing\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add some amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n## License\n\nMIT\n\n## Acknowledgments\n\n- [NATS.io](https://nats.io/) - For the amazing messaging system\n- [NATS CLI](https://github.com/nats-io/natscli) - For the CLI tool\n- [Model Context Protocol](https://github.com/modelcontextprotocol) - For the MCP framework","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmorphism%2Fnats-mcp-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbmorphism%2Fnats-mcp-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmorphism%2Fnats-mcp-server/lists"}