SuperAPI AI Directory

opsgate

opsgate is an infrastructure operations security gateway for AI agents, running as an MCP server. It lets AI clients such as Claude and Cursor diagnose and operate real servers, but does not hand a root shell directly to the agent. The agent can only call 25 structured tools (such as service_restart, docker_logs, journal_tail); commands are constructed by opsgate itself as argv arrays, and agent input never becomes shell syntax. Each call must pass through four gates: policy check, approval, and audit; the default observe mode is read-only, in operate mode change operations require human approval, and all calls (including rejections) are written to an audit log with a hash chain.

Open website

About this tool

Purpose

opsgate is a security gate between AI agents and servers. The core problem it solves is: when letting an AI agent operate real infrastructure, you can usually only give it arbitrary command execution over SSH, and command blacklists cannot exhaustively enumerate dangerous formulations, nor can they judge systemctl restart nginx the risk during business peak hours. opsgate instead provides a limited structured tool set, with commands constructed by the server itself, thereby reducing the blast radius.

Main capabilities

  • Structured tool set: the agent gets 25 typed tools, for example service_restart(name)、docker_logs(container)、journal_tail(unit, since, priority). Commands are built as argv arrays and do not concatenate shell strings, so there is no shell injection surface.
  • Read-only tools (always available in observe mode): system_info, disk_usage, process_top, listening_ports, service_list, service_status, docker_ps, docker_logs, docker_inspect, docker_stats, compose_ps, journal_tail, journal_errors, file_read, dir_list, file_grep, nginx_test.
  • Change tools (rejected in observe mode, require approval in operate mode): service_restart, service_start, service_stop, service_reload, docker_restart, docker_start, docker_stop, nginx_reload.nginx_reload first executes nginx -t, and rejects the reload if the configuration does not pass.
  • shell_exec: free-form shell, disabled by default; once enabled it always requires approval, used to cover long-tail needs.
  • Policy control: can restrict the targets a tool can reach (allow_targets); once set, the target becomes required; Docker tools only accept exact container names, not IDs or prefixes;files.allow_paths controls the scope of file access; setting it to an empty array completely disables file access.
  • Audit log: each call appends one line of JSON, embedding the hash of the previous record to form a hash chain; rejection records are also written. Change calls write two records: the intent before execution and the outcome after execution; if the intent cannot be written, execution is rejected. Values whose parameter names contain password or token are redacted; command output stores only the SHA-256, not the original text.
  • Security guarantees: agent input never becomes shell syntax; observe mode has no code path to change commands; file tool paths are sanitized first and then prefix-checked, so they cannot escape the allowed directory; SSH host keys are verified against known_hosts, and unknown keys are rejected rather than trusted on first use; approval is for one specific call only (host, tool, command) and is used only once; configuration is read only from --config or ~/.opsgate/config.yaml , not from the startup directory.

Usage

It can run read-only on the local machine without a configuration file, in observe mode by default. Once a real host is ready,opsgate init will write the initial configuration to ~/.opsgate/config.yaml. It can be used as a plugin (including an MCP server, a server operations skill, and a read-only /opsgate:health-check [host] command), or you can add only MCP servers. Supports stdio and HTTP transports: if the client runs in a sandbox and cannot reach the server, use HTTP instead; when HTTP binds to a non-loopback address, you must set http.auth_token. The simplest deployment is to run opsgate on the managed server itself (default_host: local), with no SSH keys needed, behind a TLS-terminating reverse proxy. The Docker image is registered in the MCP Registry as io.github.polymatx/opsgate.

Use cases

  • Let AI agents diagnose server problems, such as troubleshooting nginx 502s, disk usage, nighttime crashes, container health and restart counts, and comparing runtime differences between staging and prod.
  • Perform controlled change operations under human approval, such as restarting services and reloading nginx.
  • Infrastructure operations that require a traceable audit trail.

Limitations

  • The toolset is limited; needs not covered require shell_exec or contributing your own tools.
  • Tools run with the permissions of the SSH user; if that user is root, an approved call is a root call, so use a dedicated least-privilege user.
  • Once shell_exec is enabled and approved, it is arbitrary code execution.
  • full mode removes human approval; use it only when that risk is acceptable.
  • A prompt-injected agent may still call allowed tools with seemingly reasonable arguments; limit the damage by tightening policies such as allow_targets.
  • Path checks are lexical; symlinks inside allowed directories that point outside will be followed.
  • The trustworthiness of approvals depends on the MCP client that displays the prompt; a client that auto-responds renders approvals ineffective.
  • The hash chain cannot detect truncation at the end of the file or rewriting of the entire log; in important scenarios, ship logs externally or write them to append-only storage.
  • opsgate reduces the blast radius, but it is not a sandbox and cannot make it safe to point an untrusted agent at production.

Other

The project uses the MIT license. Contributing new tools is fairly easy; most are about 20 lines, and the core rule is that commands must be argv and must not concatenate strings.