opsgate

module
v0.2.0-rc.2 Latest Latest
Warning

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

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

README

opsgate

한국어

Let AI assistants help operate your clusters, without handing them a shell.

opsgate is an open-source MCP server written in Go. It gives clients such as Claude, ChatGPT, Claude Code and Cursor a fixed set of operations tools for Kubernetes, with explicit policy, human-approved changes and an audit log.

Status: features for the first public release are implemented. Changes require user authorization, allowed targets and human approval. Read restrictions and output redaction reduce sensitive data exposure. Third-party security review is pending; the security policy explains the protections and remaining limitations.

Why opsgate

No arbitrary commands

Only purpose-built tools exist. There is no shell tool and no Kubernetes Secrets tool.

Everything starts off

Providers, write actions and allowlists are disabled until you enable them in configuration.

Changes need a person

Write tools first plan the exact change, then wait for human approval in the browser by default when web approval is available. Optional approval windows are explained below.

Remote access is authenticated

A builtin OAuth 2.1 server works with claude.ai and ChatGPT connectors. Sign in with passkeys, GitHub or OIDC (Google included), or verify external JWTs.

Results are data for analysis

AI clients are instructed not to follow instructions embedded in logs or other results. Returned results are redacted and size-limited. The audit log records who called each tool and its outcome, with one JSON object per line.

It remembers what happened

The optional note provider keeps runbooks and past incidents in plain Markdown. Assistants are instructed to consult past records and offer to record the outcome. See notes.

What it can do

Providers are groups of tools; enable only the groups you need.

Provider Read tools Write tools (approval required)
Kubernetes overview, list, get, events, pod logs rollout restart, scale, delete pod
Notes: runbooks and memory, Markdown folder or Obsidian vault (experimental) search, read, list, recent, links, tags create, append, replace, move to .trash
Dev (experimental) projects, task status, log, diff, list start a coding agent (Codex or Claude) in a Git worktree

Scopes define the kinds of work a user can perform through opsgate: ops:read for inspection, ops:write for operations and note changes, and dev:run for coding-agent tasks. Allowlists restrict tools and targets such as Kubernetes workloads. A scope alone does not enable an operation prohibited by configuration.

Notes can be created only inside the configured notes folder. There is no tool for creating general files at arbitrary server paths or changing Kubernetes CPU and memory requests or limits. Those resource settings can be inspected with Kubernetes detail tools. See the tool reference for arguments and limits.

How it works

The AI client analyzes results and chooses the next operation. opsgate itself does not run or call an AI model; it checks and executes requested tools.

Kubernetes tools connect to the Kubernetes API using kubeconfig or in-cluster credentials. A local instance can therefore inspect a remote cluster when network access and permissions allow it.

Clients connect over local stdio (the client starts opsgate and communicates through standard input/output) or HTTPS through a TLS reverse proxy. opsgate checks identity and policy, plans and approves writes, then handles output and auditing. OS accounts and Kubernetes RBAC constrain access to the providers.

Details: architecture · approval · authentication.

How approval works

Write tools first prepare a plan showing the target and change. By default, a person reviews and approves it on a web approval page when web approval is available. Explicit approval.require_web: false opts in to in-client elicitation; a compromised client can then approve its own writes. External/static auth and stdio keep elicitation because they have no web channel. An omitted require_web also allows elicitation with -transport stdio for mode-based files; explicit true denies stdio writes. One-call approval binds the exact arguments and plan.

Optional approval windows let a person approve a particular tool for a limited time. During that window, subsequent calls by the same user can skip a new approval prompt, including calls with different targets or arguments. Permission and target checks still run on every call. Windows are disabled by default.

Notes: runbooks and memory

With the note provider enabled, assistants are instructed to search past incidents before acting and offer to record the outcome afterward. The AI client decides whether to follow this guidance; it is not an enforced workflow. Note changes require approval, and saved records can inform later investigations. See notes.

Quick start: local (stdio)

Build with Go 1.26 or later:

go install github.com/gkdis6/opsgate/cmd/opsgate@latest   # or: make build

Save a configuration using the current kubeconfig, for example /path/opsgate.yaml:

stdio:
  scopes: [ops:read]
providers:
  kubernetes:
    enabled: true
    namespaces: [default]

Register it with Claude Code (use absolute paths):

claude mcp add opsgate -- /path/to/opsgate -config /path/opsgate.yaml

Stdio runs with the permissions of the account that launches it. Run it unprivileged. Other clients: client setup.

Quick start: remote (HTTP with passkeys)

Passkeys need no identity provider: people sign in with Face ID, Touch ID, Windows Hello, a phone or a security key.

opsgate init asks for the public URL, who signs in and the namespaces, then writes a short configuration:

opsgate init            # writes opsgate.yaml; flags answer ahead, see -h
mode: kubernetes
http:
  public_url: "https://mcp.example.com"
auth:
  builtin:
    users:
      - subject: "passkey:alice"
        scopes: [ops:read]
    admins: ["passkey:alice"]
    allowed_redirect_hosts: [claude.ai, chatgpt.com, localhost]
    unknown_redirect_hosts: approve
providers:
  kubernetes:
    namespaces: ["*"]
    deny_namespaces: ["kube-system", "kube-public", "kube-node-lease", "opsgate"]
    allow_logs: true

The mode fills in the rest: HTTP on 0.0.0.0:8787, builtin passkey sign-in, state in /var/lib/opsgate, browser approval links and the pod’s ServiceAccount. opsgate config show -config opsgate.yaml prints every effective value.

Put this file in the opsgate ConfigMap of deploy/kubernetes/opsgate-deployment.yaml and apply it. The manifest’s sample uses Google sign-in; replacing its config with passkeys still leaves the required opsgate-upstream Secret mount. Follow deployment for Secret provisioning, image verification, RBAC and probe configuration.

kubectl apply -f deploy/kubernetes/opsgate-deployment.yaml

Run opsgate -h to list commands and flags, or opsgate help <command> for command help. opsgate version (also -version) prints the build version. Help and successful commands exit 0; invalid commands, flags or extra arguments exit 2 before loading configuration; operational errors exit 1. Help goes to stdout and errors to stderr.

  1. On first start, opsgate logs a one-time setup link (valid 24 hours) for each user without a passkey. Open it and press Create passkey. Later links: kubectl -n opsgate exec deploy/opsgate -- /opsgate passkey invite -config /etc/opsgate/opsgate.yaml -subject passkey:alice.
  2. Put a TLS ingress or reverse proxy in front that preserves the Host header. The public host must match public_url; other hosts get 421.
  3. Connect a client to https://mcp.example.com/mcp, for example claude mcp add --transport http opsgate https://mcp.example.com/mcp, or add it as a connector in claude.ai or ChatGPT.

The generated file already limits client redirect hosts (allowed_redirect_hosts); review them before exposing the server. GitHub, Google and other sign-in options are covered in authentication. Proxy routes and release verification are in deployment.

Watch alerts

Run opsgate watch alongside the MCP server to receive Kubernetes problem and change notifications. It watches the Kubernetes API and sends alerts directly to Discord, custom JSON webhooks or SMTP email. n8n is optional. Paste an alert into an MCP client to investigate the resource with opsgate's read tools.

From an alert to a diagnosis

Paste the alert into your MCP client with a request such as:

Investigate this alert using opsgate MCP. Check operational records, resource status and events, and current and previous container logs. Separate confirmed causes, hypotheses and checks that still need to be made.

An example investigation follows these steps:

  1. If the Notes provider is enabled, search runbooks and past incidents by service, symptom or error text.
  2. Use the alert's cluster, namespace, resource and occurrence time to inspect Pod/workload state and Kubernetes events.
  3. If log access is allowed, compare current logs with the previous container instance's logs using previous: true to trace the failure.
  4. Explain confirmed causes, hypotheses and outstanding checks, with supporting logs and events.

The MCP client's AI performs the investigation by calling read tools; watch supplies the notification. Available evidence depends on enabled providers and access policy. Host resource and systemd log inspection are outside the current Kubernetes mode's tool scope. Deleted Pods or expired logs and events can prevent a conclusive root-cause diagnosis. Changes such as restarts follow the separate approval process.

Automatic investigation (optional)

The separate opsgate-analyzer process can receive signed watch alerts, ask a function-calling model to query read-only MCP tools, and send a report to Discord. It groups repeated alerts, enforces investigation limits and never calls write tools. Configure your own model and credential files; no model is required for normal watch or interactive MCP use. This experimental feature supports OpenAI-compatible Chat Completions or installed Claude Code (claude -p) and Codex (codex exec) CLIs, selected by model.backend. CLI mode reuses the execution account's CLI auth and does not require a separate model API-key file. See automatic investigation.

Immediate Discord cause explanations support language: ko or en per output. Reports independently select report.language and request actionable proposals with report.suggest_actions: true; proposals are never executed automatically. Error codes and raw evidence remain unchanged. See report language and actions.

Delivery configuration

Add the following to a configuration with the Kubernetes provider enabled:

watch:
  outputs:
    - name: discord
      type: discord
      language: ko # ko or en
      url_file: /etc/opsgate/discord-webhook-url
    - name: custom
      type: webhook
      url: https://alerts.example.com/ingest
      header_files:
        Authorization: /etc/opsgate/alerts-authorization
      body_template: |
        {"message": {{json .Text}}, "sent_at": {{json .SentAt}}, "alerts": {{json .Alerts}}}

Keep the destinations you need. Store the Discord channel's incoming webhook URL in url_file; the authorization file contains the full header value, such as Bearer TOKEN. Files are read at startup, so restart watch after changing them. In Kubernetes, mount these files from Secrets.

opsgate watch -config opsgate.yaml

Each destination has its own queue, cooldown and retries. Discord embeds include UTC occurrence times, cluster, namespace/resource, reason and summary; long batches are visibly truncated to fit Discord's limit. Custom templates use the json helper to escape values and must produce valid JSON. Existing watch.webhook_url and watch.email settings remain supported alongside outputs. See watch alerts for delivery limits, HMAC signatures and all configuration options.

Security model in brief

  • One instance is one trust group: ops:read covers every enabled provider. Use separate instances and OS accounts for things with different trust levels, such as production operations, personal notes and coding agents.
  • Permission checks stack: scopes, server tool policy, per-user tool lists, provider allowlists, then OS permissions and Kubernetes RBAC.
  • HTTP requires browser approval by default when approval.web is enabled. Explicit approval.require_web: false opts in to elicitation, allowing a compromised client to approve its own writes; HTTP startup logs a warning.

Full details: SECURITY.md.

Documentation

Document Contents
Architecture Request flow, packages, design principles
Authentication Passkey, GitHub, OIDC, external JWT, static tokens, stdio
Approval Plan/apply, approval channels, approval windows
Client setup Claude Code, Claude Desktop, claude.ai, ChatGPT, Cursor
Configuration Every configuration key, defaults and audit log format
Tools Tool arguments, limits, redaction
Notes Runbooks and incident memory in a Markdown folder
Deployment Release verification, Kubernetes, reverse proxy
Dev provider Running coding agents through the separate runner
Watch alerts Kubernetes alerts to Discord, custom JSON webhooks and email through a separate opsgate watch process
Automatic investigation Optional model worker, read-only MCP authentication and investigation limits
Roadmap What is done and what may come

Contributing and license

See CONTRIBUTING.md, the Code of Conduct and changelog. Licensed under Apache-2.0, copyright 2026 The opsgate Authors.

Incident alerts are sent first; the optional analyzer sends causes, evidence, and suggested actions in a separate message. Analysis does not delay the initial alert.

Directories

Path Synopsis
cmd
opsgate command
Command opsgate is an MCP server for safe, audited server operations.
Command opsgate is an MCP server for safe, audited server operations.
opsgate-analyzer command
opsgate-analyzer is a separate, read-only investigation worker.
opsgate-analyzer is a separate, read-only investigation worker.
internal
alert
Package alert batches and delivers watch alerts.
Package alert batches and delivers watch alerts.
analyzer
Package analyzer receives signed watch alerts and investigates them through a read-only MCP connection and a function-calling model.
Package analyzer receives signed watch alerts and investigates them through a read-only MCP connection and a function-calling model.
approval
Package approval obtains human confirmation for write tools, either via MCP elicitation inside the client or via a browser approval page.
Package approval obtains human confirmation for write tools, either via MCP elicitation inside the client or via a browser approval page.
audit
Package audit records every tool call as one JSON line.
Package audit records every tool call as one JSON line.
authn
Package authn verifies bearer tokens for static and external auth modes.
Package authn verifies bearer tokens for static and external auth modes.
buildinfo
Package buildinfo reports the executable version.
Package buildinfo reports the executable version.
config
Package config loads the opsgate YAML configuration.
Package config loads the opsgate YAML configuration.
devrunner
Package devrunner runs configured coding agents in git worktrees over a peer-authenticated Unix socket.
Package devrunner runs configured coding agents in git worktrees over a peer-authenticated Unix socket.
httpserver
Package httpserver serves authenticated MCP over Streamable HTTP.
Package httpserver serves authenticated MCP over Streamable HTTP.
oauth
Package oauth implements opsgate's built-in OAuth authorization server.
Package oauth implements opsgate's built-in OAuth authorization server.
provider/dev
Package dev exposes coding-agent tasks run by a separate dev-runner account.
Package dev exposes coding-agent tasks run by a separate dev-runner account.
provider/kube
Package kube provides Kubernetes inspection and approved writes.
Package kube provides Kubernetes inspection and approved writes.
provider/note
Package note provides tools for a folder of Markdown notes, such as an Obsidian vault, without any note app running.
Package note provides tools for a folder of Markdown notes, such as an Obsidian vault, without any note app running.
redact
Package redact masks secrets in text before it leaves the server.
Package redact masks secrets in text before it leaves the server.
server
Package server assembles the MCP server from the configured providers.
Package server assembles the MCP server from the configured providers.
tool
Package tool is the only way providers expose MCP tools.
Package tool is the only way providers expose MCP tools.
ui
Package ui renders the shared browser pages.
Package ui renders the shared browser pages.

Jump to

Keyboard shortcuts

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