Skip to main content
Glama
README.md
# belaygate

**Let AI agents operate your Proxmox cluster, with a rope attached.**

belaygate is an [MCP](https://modelcontextprotocol.io) server that sits between an agent
(Claude Code, Codex, any MCP client) and your infrastructure. The agent gets typed tools
instead of a root shell. Every call goes through a written policy:

- **Read-only by default.** Anything the policy does not allow is denied.
- **Protected targets.** Guests you list or tag (DNS, VPN, password manager) cannot be
  touched, whatever the rules say.
- **Human approval that the agent cannot fake.** `ask` rules wait for a person on an
  out-of-band channel (CLI, push notification). Each approval is bound to the exact
  arguments, used once, and expires.
- **Snapshot before change.** Rules can require a snapshot before a call runs, and
  `gate_rollback_last` undoes what the gateway did.
- **Tamper-evident audit.** Every decision and result goes to an append-only, hash-chained
  JSONL log.

> **Status: alpha.** The policy engine, approvals, audit log, Proxmox adapter and MCP
> server work and are tested, including against a real Proxmox VE 9 cluster. Expect rough
> edges, and start with a test guest.

## Try it

```sh
git clone https://github.com/juanbeniteza/belaygate.git && cd belaygate
corepack enable && pnpm install && pnpm build
node packages/server/dist/cli.js dev
```

This runs the gateway against a built-in fake Proxmox cluster and prints the command to
connect Claude Code. (Once released on npm: `npx belaygate dev`.)

New to this? Read **[Getting started](docs/getting-started.md)**: what belaygate does, how
to think about it, and a step-by-step setup. Reference: [Running the gateway](docs/server.md).

## How a call flows

```
agent ─► MCP endpoint ─► policy ─┬─ deny ──────────────────────────► refused + audit
          (bearer token)          ├─ ask ─► human approves out of band ─┐
                                  └─ allow ─────────────────────────────┴─► snapshot ─► Proxmox API ─► audit
```

## A policy

```yaml
version: 1
defaults:
  decision: deny
protected:
  targets:
    - { provider: pve, tags: [critical] }
rules:
  - id: reads
    match: { risk: read }
    decision: allow
  - id: power
    match: { tool: [pve_guest_stop, pve_guest_reboot] }
    decision: ask
  - id: config
    match: { tool: pve_guest_config_set }
    decision: ask
    snapshot: before
```

See the [policy reference](docs/policy.md), a fuller [example](examples/policy.yaml), the
[gateway config example](examples/belaygate.yaml) and the [Proxmox token guide](docs/proxmox-token.md).

## Design principles

- **The agent is useful but untrusted.** It may be prompt-injected. It holds only a
  gateway token, never Proxmox credentials or SSH keys.
- **Fail closed.** If the policy cannot load, the snapshot fails or the audit line cannot be
  written, the action does not run.
- **Run it next to, not on, the hypervisor.** A small LXC or VM with a least-privilege
  Proxmox API token.
- **Adapters are small.** Core handles policy, approvals, snapshots and audit generically,
  so supporting another platform means writing one adapter folder.

## Development

Requires Node.js 22.12 or newer and pnpm.

```sh
pnpm install
pnpm check      # format, lint, typecheck, tests
pnpm coverage
```

See [CONTRIBUTING.md](CONTRIBUTING.md).

## License

[Apache-2.0](LICENSE)