cheshmhayash

module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: Apache-2.0

README ΒΆ

cheshmhayash πŸ‘€

cheshmhayash

ci Go

Introduction

cheshmhayash is a NATS administration dashboard and HTTP gateway. It talks to your clusters over the NATS protocol itself β€” the same system-account channels ($SYS.REQ.*) and JetStream API ($JS.API.*) that natscli uses β€” and exposes them as plain HTTP + JSON for browsers, scripts, and internal tooling.

Because every endpoint is served through a single authenticated NATS connection, you do not need the server's HTTP monitoring port (:8222) open; only the client port (:4222, or wherever) is required.

It is a Swiss Army knife for NATS in one binary: the dashboard (serve), an MCP server for LLM agents (mcp), and protobuf-aware sub / pub commands that decode payloads with schemas loaded at run time.

Screenshots

Servers view

Servers β€” per-server stats card grid with JS leader badge.

JetStream view

JetStream β€” cluster-wide overview, accounts table, drill-in streams. Live SSE indicator top-right.

Topology view

Topology β€” raft-group polygons connecting the servers (meta in amber, streams in green, consumers in blue).

Features

Read endpoints

Responses are forwarded verbatim from the NATS server β€” the JSON payload is the same one you would get from the HTTP monitoring interface.

  • Cluster-wide server discovery ($SYS.REQ.SERVER.PING)
  • Targeted per-server endpoints: VARZ, CONNZ, ROUTEZ, GATEWAYZ, LEAFZ, SUBSZ, JSZ, ACCOUNTZ, HEALTHZ, STATSZ
  • Account-scoped endpoints: CONNZ, LEAFZ, SUBSZ, JSZ, INFO
  • Cluster-wide JetStream overview built from $SYS.REQ.SERVER.PING.JSZ β€” every account, every stream, every consumer, in a single round-trip
  • JetStream: list streams, stream info, list consumers, consumer info
Actions
  • Server: config reload, lame-duck mode, kick a connection by CID
  • JetStream: edit stream config (CodeMirror JSON editor with syntax highlighting), step down meta/stream/consumer raft leader, purge, delete, delete consumer

Destructive JetStream actions require ?confirm=true; without it the server responds with 428 Precondition Required.

Real-time + LLM integration
  • Per-cluster JSZ overview is refreshed in the background and pushed to the SPA over SSE β€” the panel updates in real time, with a small live / polling / disconnected indicator next to each view.
  • MCP server as its own subcommand (cheshmhayash mcp). Speaks the Model Context Protocol over both stdio (default) and HTTP Streamable (--http, POST /mcp) so LLM agents (Claude Desktop, Cursor, etc.) can inspect and operate the cluster as tools. Read-only by default; destructive verbs gate on CHESHMHAYASH_MCP_WRITE=1.
  • Webhook notifications to Slack / Mattermost / Matrix (via hookshot bridge): subscribes to $JS.EVENT.ADVISORY.> and surfaces stream / consumer create / delete / update / leader-elected / quorum-lost as chat messages. Config under [[notify]].

Protobuf-aware pub/sub

cheshmhayash sub and cheshmhayash pub work like nats sub / nats pub, but they decode and encode protobuf with schemas that are loaded at run time, so private .proto files never have to be compiled into the binary.

# Decode with the subject rules; wildcards work
cheshmhayash sub --schemas schemas.toml 'ride.>'

# Force a type, show headers, emit JSON lines for jq
cheshmhayash sub -t backend:ride.Accept -H -o json ride.accepted | jq .payload

# JSON in, protobuf on the wire; --request prints the decoded reply
cheshmhayash pub --schemas schemas.toml ride.accepted '{"ride_id":"42"}'

# Inspect: sources, message names, fields, and what a subject decodes as
cheshmhayash schema list
cheshmhayash schema messages accept
cheshmhayash schema show backend:ride.Accept
cheshmhayash schema resolve ride.accepted
cheshmhayash schema check          # non-zero exit on a broken rule (for CI)

A payload's type comes from --type, then the Proto-Type message header, then the first matching subject rule. A payload without a type is shown as JSON, text, a schemaless protobuf dump keyed by field number, or base64. A schema that does not fit still shows the payload, with a note; unknown fields are reported as schema drift. sub uses core NATS only and never creates a JetStream consumer, so it is safe on production streams.

Schemas live in [schemas] of settings.toml or in standalone files passed with --schemas (repeatable, also CHESHMHAYASH_SCHEMAS) β€” a private repository can ship one next to its descriptor sets:

type_header = "Proto-Type"     # optional; "-" turns the header lookup off

[[sources]]
name = "backend"               # messages are referred to as backend:pkg.Message
type = "descriptor_set"        # protoc --include_imports --descriptor_set_out / buf build -o
path = "backend.binpb"         # relative to this file

[[sources]]
name = "map"
type = "proto_dir"             # compile every .proto under path at start
path = "../map-proto/pb"
import_paths = ["third_party"] # more import roots, e.g. googleapis

[[subjects]]
match = "ride.>"               # NATS wildcards; the first match wins
message = "backend:ride.Event"

Each source keeps its own registry, so two repositories that both declare package ride; can be loaded side by side. In a proto_dir source, a file that does not compile is skipped (and reported by schema list -v) instead of failing the whole source.

--cluster picks a cluster from settings.toml; --server, --user, --password and --creds (or NATS_URL, …) connect without one. The Helm chart can mount a schemas folder from a ConfigMap or an image (schemas.* values), so kubectl exec deploy/<release> -- /app/cheshmhayash sub … decodes in the cluster.

HTTP API

Method Path Notes
GET /api/admin/clusters configured cluster names
GET /api/admin/clusters/{c}/servers PING discovery
GET /api/admin/clusters/{c}/servers/{endpoint} PING + endpoint (e.g. VARZ)
GET /api/admin/clusters/{c}/servers/{id}/{endpoint} targeted server query
GET /api/admin/clusters/{c}/accounts/{account}/{endpoint} account-scoped
POST /api/admin/clusters/{c}/servers/{id}/actions/reload reload config
POST /api/admin/clusters/{c}/servers/{id}/actions/lame-duck graceful drain
POST /api/admin/clusters/{c}/servers/{id}/actions/kick body: {"cid": N}
GET /api/jsm/clusters/{c}/overview cluster-wide JetStream (sys-account) Β· pass ?live=true to bypass cache
GET /api/jsm/clusters/{c}/overview/stream SSE β€” pushes a fresh overview on every cache refresh
GET /api/jsm/clusters/{c}/streams?offset=N paginated
GET /api/jsm/clusters/{c}/streams/{s} stream info
PUT /api/jsm/clusters/{c}/streams/{s} full StreamConfig update
POST /api/jsm/clusters/{c}/streams/{s}/purge?confirm=true purge all messages
DELETE /api/jsm/clusters/{c}/streams/{s}?confirm=true delete stream
POST /api/jsm/clusters/{c}/actions/meta-stepdown?confirm=true force meta raft re-election
POST /api/jsm/clusters/{c}/streams/{s}/actions/stepdown?confirm=true force stream raft re-election
GET /api/jsm/clusters/{c}/streams/{s}/consumers?offset=N list consumers
GET /api/jsm/clusters/{c}/streams/{s}/consumers/{con} consumer info
DELETE /api/jsm/clusters/{c}/streams/{s}/consumers/{con}?confirm=true delete consumer
POST /api/jsm/clusters/{c}/streams/{s}/consumers/{con}/actions/stepdown?confirm=true force consumer raft re-election
POST /mcp MCP Streamable HTTP β€” JSON-RPC 2.0 in body
GET /mcp MCP SSE channel (server→client notifications)
GET /healthz liveness / readiness probe

Configuration

Settings are loaded from config/default.toml, overlaid with an optional settings.toml, and finally with environment variables prefixed CHESHMHAYASH__ (double-underscore separates nested keys; list elements are indexed, e.g. CHESHMHAYASH__NATS__0__USER).

[server]
host = "0.0.0.0"
port = 1378

# Each [[nats]] block describes a cluster to administer. The `url` points
# at the client port. Administrative endpoints ($SYS.REQ.*) require the
# connection to be authenticated against the system account.
[[nats]]
name = "local"
url = "nats://127.0.0.1:4222"
# creds_file = "./sys.creds"
# user = "admin"
# password = "changeme"
# request_timeout_ms = 2000     # single-reply request timeout
# discovery_timeout_ms = 500    # window for multi-reply collection

# Webhook notifications β€” one entry per chat destination. `provider` is
# one of slack | mattermost | matrix (Matrix expects a Slack-compatible
# bridge such as matrix-hookshot or maubot/webhook).
# [[notify]]
# provider = "slack"
# url = "https://hooks.slack.com/services/T000/B000/XXX"
# channel = "#nats-events"        # optional
# username = "cheshmhayash"        # optional

CHESHMHAYASH_OVERVIEW_PERIOD (Go duration, default 10s) controls how often the background JSZ cache refreshes. CHESHMHAYASH_MCP_WRITE=1 exposes the destructive MCP tools.

System-account requirement

$SYS.REQ.* subjects are only routed when the connecting client is bound to the server's system account. Without system-account credentials, admin endpoints time out and the cluster-wide JetStream overview comes back empty. The per-account $JS.API.* endpoints (list streams, stream info, update/purge/delete, consumers) run against whichever account the credentials grant; they will return JetStream not enabled (err_code 10039) on a connection bound to $SYS.

Tech stack

  • Backend β€” Go 1.27, stdlib net/http (1.22+ pattern syntax), log/slog, nats.go v1.52, BurntSushi/toml for config.
  • Frontend β€” React 19 + TypeScript 6 on Vite 8. JSON editor uses CodeMirror 6 (@uiw/react-codemirror, @codemirror/lang-json, @codemirror/theme-one-dark).
  • Runtime image β€” gcr.io/distroless/static-debian12:nonroot (~10 MB).

Running

Local
# Backend (dashboard)
go run ./cmd/cheshmhayash serve       # serves API + built SPA on :1378

# Frontend (dev β€” separate terminal)
cd frontend && npm install
npm run dev                           # HMR on :5173, /api proxied to :1378

One binary holds every component; the subcommand picks which one runs. For a production build:

cd frontend && npm install && npm run build
go build -o ./bin/cheshmhayash ./cmd/cheshmhayash
./bin/cheshmhayash serve              # http://127.0.0.1:1378

serve --components selects the parts of the dashboard (api, ui, notify; all by default, also via CHESHMHAYASH_COMPONENTS):

./bin/cheshmhayash serve --components api,ui   # no webhook notifier
./bin/cheshmhayash serve --components notify   # notifier only (+ /healthz)

The MCP server is the mcp subcommand β€” stdio by default, --http for the Streamable HTTP transport:

./bin/cheshmhayash mcp                # stdio (Claude Desktop, Cursor, …)
./bin/cheshmhayash mcp --http         # POST /mcp on server.host:port
./bin/cheshmhayash mcp --write        # also register destructive tools
Docker
docker build -t cheshmhayash .
docker run --rm -p 1378:1378 \
    -v "$PWD/settings.toml:/app/settings.toml:ro" \
    cheshmhayash
# the MCP server from the same image
docker run --rm -p 8080:8080 \
    -v "$PWD/settings.toml:/app/settings.toml:ro" \
    cheshmhayash mcp --http --addr :8080
Kubernetes (Helm)

The chart lives in chart/cheshmhayash-chart/ and is published as an OCI artifact to GHCR on every tagged release.

# install from GHCR
helm install panel \
  oci://ghcr.io/1995parham/cheshmhayash-chart \
  --version 2.0.0 \
  -f my-values.yaml

# or from a local checkout
helm install panel chart/cheshmhayash-chart -f my-values.yaml

Clusters and authentication mode are declared in values.yaml. Each entry becomes a [[nats]] block. auth accepts exactly one of three modes β€” userPassword (chart-managed Secret), existingSecret (env vars from an external Secret), or credsFileSecret (a .creds file mounted read-only):

clusters:
  - name: prod
    url: nats://nats.nats.svc.cluster.local:4222
    auth:
      existingSecret:
        name: nats-prod-creds
        userKey: user
        passwordKey: password

The chart deploys the dashboard, and components selects its parts (api, ui, notify). The MCP HTTP server ships as an opt-in workload β€” set mcp.enabled: true to add a cheshmhayash mcp --http Deployment + Service. It reuses the same image, settings.toml and NATS auth; /mcp auth is configured under auth.mcpKeys / auth.mcpOauth / auth.mcpJwt, and write tools gate on mcp.write:

mcp:
  enabled: true
  port: 8080
  write: false

Development

# backend β€” golangci-lint is the single source of truth for Go: it runs
# gofmt/goimports and go vet too, so there are no separate fmt/vet steps.
golangci-lint run
go test -race ./...

# frontend β€” Biome is the single lint + format tool (replaces ESLint/Prettier)
cd frontend
npm run ci          # biome lint + format check
npm run typecheck
npm run build

A docker-compose.yml is included for spinning up a local NATS server with monitoring enabled, so the dashboard has something to talk to.

License

Free and open source forever, just like NATS. Released under the Apache License 2.0 β€” see the file for details.


Built with ❀️ by @1995parham · 1995parham/cheshmhayash

Directories ΒΆ

Path Synopsis
cmd
cheshmhayash command
Command cheshmhayash is a toolbox for NATS administration.
Command cheshmhayash is a toolbox for NATS administration.
internal
auth
Package auth wires OIDC login + HMAC-signed cookie sessions for the HTTP API and bearer-token auth for MCP HTTP.
Package auth wires OIDC login + HMAC-signed cookie sessions for the HTTP API and bearer-token auth for MCP HTTP.
cliutil
Package cliutil holds the flags and helpers that several subcommands share: the settings file, the cluster choice, and the schema files.
Package cliutil holds the flags and helpers that several subcommands share: the settings file, the cluster choice, and the schema files.
cmd
Package cmd builds the cheshmhayash command tree with urfave/cli v3.
Package cmd builds the cheshmhayash command tree with urfave/cli v3.
cmd/mcp
Package mcp implements `cheshmhayash mcp`: the MCP server.
Package mcp implements `cheshmhayash mcp`: the MCP server.
cmd/pub
Package pub implements `cheshmhayash pub`: publish a message, encoding JSON into protobuf when the subject has a schema, and optionally wait for a reply (request-reply) and print it decoded.
Package pub implements `cheshmhayash pub`: publish a message, encoding JSON into protobuf when the subject has a schema, and optionally wait for a reply (request-reply) and print it decoded.
cmd/schemacmd
Package schemacmd implements `cheshmhayash schema`: inspect the loaded protobuf schemas and the subject rules, without a NATS connection.
Package schemacmd implements `cheshmhayash schema`: inspect the loaded protobuf schemas and the subject rules, without a NATS connection.
cmd/serve
Package serve implements `cheshmhayash serve`: the HTTP dashboard.
Package serve implements `cheshmhayash serve`: the HTTP dashboard.
cmd/sub
Package sub implements `cheshmhayash sub`: subscribe to subjects on core NATS and print each message decoded.
Package sub implements `cheshmhayash sub`: subscribe to subjects on core NATS and print each message decoded.
codec
Package codec turns NATS payloads into JSON a person can read, and JSON back into payloads.
Package codec turns NATS payloads into JSON a person can read, and JSON back into payloads.
config
Package config loads runtime settings via koanf in the layered pattern: struct defaults β†’ settings.toml β†’ CHESHMHAYASH__* environment variables.
Package config loads runtime settings via koanf in the layered pattern: struct defaults β†’ settings.toml β†’ CHESHMHAYASH__* environment variables.
handler
Package handler exposes cheshmhayash's HTTP API.
Package handler exposes cheshmhayash's HTTP API.
httpserver
Package httpserver runs an http.Server until its context ends and then shuts it down gracefully.
Package httpserver runs an http.Server until its context ends and then shuts it down gracefully.
mcp
Package mcp exposes cheshmhayash's NATS admin surface as a Model Context Protocol server.
Package mcp exposes cheshmhayash's NATS admin surface as a Model Context Protocol server.
natsx
Package natsx wraps the NATS client with cheshmhayash's request patterns: a single-reply request_json for targeted endpoints and a multi-reply discover for PING-style fan-out.
Package natsx wraps the NATS client with cheshmhayash's request patterns: a single-reply request_json for targeted endpoints and a multi-reply discover for PING-style fan-out.
notify
Package notify fans out NATS advisory events (stream/consumer create/update/delete/leader-elected, plus system-account events) to chat webhooks (Slack, Mattermost, Matrix-via-bridge).
Package notify fans out NATS advisory events (stream/consumer create/update/delete/leader-elected, plus system-account events) to chat webhooks (Slack, Mattermost, Matrix-via-bridge).
render
Package render prints decoded NATS messages for a person (pretty) or for a program (one JSON object per line).
Package render prints decoded NATS messages for a person (pretty) or for a program (one JSON object per line).
schema
Package schema holds the protobuf schemas that cheshmhayash decodes NATS payloads with.
Package schema holds the protobuf schemas that cheshmhayash decodes NATS payloads with.
version
Package version exposes the cheshmhayash binary version to other subsystems (HTTP /api/version, MCP initialize handshake, etc.).
Package version exposes the cheshmhayash binary version to other subsystems (HTTP /api/version, MCP initialize handshake, etc.).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL