Gatekeep Developer Documentation • v1.0

Human-in-the-Loop Control Plane for Autonomous Agents

Gatekeep (bsuit.app) is a cryptographic approval layer that sits between autonomous AI agents (Claude Code, OpenAI Codex / GPT, Cursor, Hermes Agent, OpenClaw, and custom pipelines) and your production infrastructure.

Whenever an agent attempts an irreversible or sensitive action—such as deploying to Kubernetes, running database migrations, issuing Stripe refunds, or modifying cloud resources—Gatekeep pauses execution, posts an interactive Block Kit review card in your designated Slack channel, and issues a single-use execution token bound to the exact RFC 8785 JSON Canonicalization Scheme (JCS) SHA-256 hash of the approved parameters.

End-to-End Execution Flow

┌──────────────────────┐    1. POST /mcp or /v1/requests    ┌──────────────────────────┐
│  AI Agent Runtime    │ ─────────────────────────────────► │   Gatekeep Control Plane │
│ (Claude, Codex,      │    (action, target, params, risk)  │  • RFC 8785 JCS SHA-256  │
│  Cursor, Hermes,     │                                    │  • Policy Engine Check   │
│  OpenClaw, Python)   │ ◄───────────────────────────────── │  • AES-256-GCM Encrypt   │
└──────────┬───────────┘    2. Long-Poll (wait=25s)         └────────────┬─────────────┘
           │                                                             │
           │ 5. start_execution (Verify Hash & Consume Token)            │ 3. Transactional Outbox
           ▼                                                             ▼
┌──────────────────────┐    6. report_execution (Receipt)   ┌──────────────────────────┐
│ Production Target    │ ─────────────────────────────────► │   Slack Approval Channel │
│ (K8s, DB, Stripe)    │                                    │  [✓ Approve] [✎ Edit]    │
└──────────────────────┘                                    │  [? Ask Info] [✕ Reject] │
                                                            └──────────────────────────┘

Slack Installation & Zero-DB Slash Commands

Gatekeep requires zero external database administration to manage agent credentials. Once installed via Add to Slack, manage your entire workspace directly from any Slack channel using the /gatekeep command.

Slash Command Description Example
/gatekeep new-key <name> Generates a new scoped Agent API Key (gk_live_<id>_<secret>) and returns a private ephemeral message with ready-to-paste MCP configuration. /gatekeep new-key claude-prod
/gatekeep keys Lists all active Agent API Keys in your Slack workspace, including key prefix, creator, creation date, and last used timestamp. /gatekeep keys
/gatekeep revoke-key <id> Immediately revokes an Agent API Key by its ID prefix. Any subsequent MCP or REST calls using that key fail with 401 Unauthorized. /gatekeep revoke-key 48437c334bac
/gatekeep billing Displays live monthly governed request quota, active Agent API keys, Fair-Play status, and 1-click Lemon Squeezy upgrade links for Pro ($9/mo) and Scale Unlimited ($19/mo). /gatekeep billing
/gatekeep status Displays workspace connection status, default approval channel, and active policy version. /gatekeep status
/gatekeep policy Displays the active JSON governance policy rules, default verdict, and default TTL. /gatekeep policy
Security Note: The raw secret portion of gk_live_<key_id>_<secret> is shown only once inside an ephemeral Slack message visible solely to you. Gatekeep stores only the SHA-256 digest of the secret in PostgreSQL.

Request Lifecycle & CAS State Machine

Every approval request transitions deterministically using atomic PostgreSQL Compare-And-Swap (CAS) updates. Concurrent clicks in Slack or duplicate network retries cannot cause double execution.

Status Terminal? Meaning & Agent Action
pending No Waiting for a human decision in Slack. Agent should continue calling get_approval_status with wait_seconds: 25.
needs_info No A human reviewer clicked ? Ask Info in Slack and asked a question. Agent should call provide_context with the answer, which transitions the request back to pending.
approved No (Ready) Human clicked ✓ Approve on Revision #1. A single-use gkt_... token is issued. Agent must call start_execution, execute the action, and call report_execution.
edited No (Ready) Human clicked ✎ Edit, modified the JSON parameters in Slack, and approved Revision #2+. Agent must adopt the returned params and pass them to start_execution.
executing No The single-use approval token has been consumed via start_execution / POST /v1/requests/:id/consume.
executed Yes Agent reported status: "succeeded" via report_execution. Slack card is updated with execution duration and summary.
failed Yes Agent reported status: "failed". Gatekeep updates the Slack card with the failure alert.
rejected Yes Human clicked ✕ Reject (or policy matched DENY). Agent must abort the action immediately.
expired Yes No human decided before expires_at (default: 30 minutes). Strict default-deny applies.
cancelled Yes Agent cancelled the pending request via cancel_request.

🟠 Integrating with Claude Code & Claude Desktop

Gatekeep natively supports Anthropic's Remote Streamable HTTP MCP transport. No local Node/Python wrapper or Docker container is required.

Option A: Claude Code CLI (One-Liner)

Run the following command in your terminal to register Gatekeep globally (-s user) or for your current repository (-s project):

Terminal — Claude Code CLI
claude mcp add --transport http gatekeep https://gatekeep.bsuit.app/mcp \
  --header "Authorization: Bearer gk_live_YOUR_KEY_ID_SECRET"

Option B: Project-Scoped .mcp.json (Recommended for Teams)

Check a .mcp.json file into the root of your repository and reference an environment variable so every developer's Claude Code session is governed:

.mcp.json
{
  "mcpServers": {
    "gatekeep": {
      "type": "http",
      "url": "https://gatekeep.bsuit.app/mcp",
      "headers": {
        "Authorization": "Bearer ${GATEKEEP_API_KEY}"
      }
    }
  }
}

Option C: Recommended CLAUDE.md Governance Rule

Add this snippet to your project's CLAUDE.md so Claude automatically invokes Gatekeep before high-impact operations:

CLAUDE.md
# Gatekeep Human-in-the-Loop Governance
Before running any production deployment, Terraform/Helm apply, database migration, destructive SQL query, or external customer action:
1. Call the `gatekeep` MCP tool `request_approval` with `action`, `target`, exact `params`, and `justification`.
2. Poll `get_approval_status` with `wait_seconds: 25` until the status is terminal.
3. If status is `needs_info`, answer the reviewer's question using `provide_context`.
4. Only if status is `approved` or `edited`, call `start_execution` (using the revised params if `edited`), run the command, and call `report_execution`.

🟢 Integrating with OpenAI Codex CLI, Responses API & ChatGPT

Gatekeep integrates directly with OpenAI Codex CLI, the OpenAI Responses API (native Remote MCP tool in gpt-4.1, o3, o4-mini, and gpt-5), and ChatGPT Custom GPT Actions.

1. OpenAI Codex CLI (~/.codex/config.toml)

OpenAI's open-source terminal agent (codex) supports remote Streamable HTTP MCP servers in ~/.codex/config.toml:

~/.codex/config.toml
[mcp_servers.gatekeep]
url = "https://gatekeep.bsuit.app/mcp"
http_headers = { Authorization = "Bearer gk_live_YOUR_KEY_ID_SECRET" }

Tip: You can also use env_http_headers = { Authorization = "GATEKEEP_BEARER_TOKEN" } in ~/.codex/config.toml if you prefer storing the token in your shell environment.

2. OpenAI Responses API (Native Remote MCP Connector)

When building agents with the official OpenAI SDK, pass Gatekeep directly as a native Remote MCP tool. OpenAI's cloud runtime connects directly to https://gatekeep.bsuit.app/mcp:

TypeScript / Node.js — OpenAI Responses API
import OpenAI from "openai";

const client = new OpenAI();

const response = await client.responses.create({
  model: "gpt-4.1",
  tools: [
    {
      type: "mcp",
      server_label: "gatekeep",
      server_url: "https://gatekeep.bsuit.app/mcp",
      headers: {
        Authorization: `Bearer ${process.env.GATEKEEP_API_KEY}`,
      },
      require_approval: "never", // Gatekeep enforces human approval in Slack
    },
  ],
  input: "Request Slack approval via Gatekeep before scaling prod-api to 6 replicas.",
});

3. ChatGPT Custom GPTs (OpenAPI 3.1 Action Schema)

To allow a Custom GPT inside ChatGPT Team/Enterprise to request human approvals in Slack, configure an Action with Authentication set to API Key (Bearer) and paste this OpenAPI 3.1 schema:

OpenAPI 3.1 Schema for ChatGPT Actions
openapi: 3.1.0
info:
  title: Gatekeep Human Approval API
  version: 1.0.0
servers:
  - url: https://gatekeep.bsuit.app
paths:
  /v1/requests:
    post:
      operationId: requestApproval
      summary: Request human approval in Slack before executing a sensitive action
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [action, params, justification]
              properties:
                action: { type: string, example: "stripe.refund.create" }
                target: { type: string, example: "stripe:prod" }
                params: { type: object }
                justification: { type: string }
      responses:
        "201":
          description: Created pending approval request
  /v1/requests/{id}:
    get:
      operationId: getApprovalStatus
      summary: Poll approval status (pass wait=25 for long polling)
      parameters:
        - name: id
          in: path
          required: true
          schema: { type: string }
        - name: wait
          in: query
          schema: { type: integer, default: 25 }
      responses:
        "200":
          description: Current request status

🔵 Integrating with Cursor & Windsurf IDE

Connect Cursor or Windsurf to Gatekeep in under 30 seconds using the Remote MCP configuration file.

Cursor (.cursor/mcp.json or ~/.cursor/mcp.json)

.cursor/mcp.json
{
  "mcpServers": {
    "gatekeep": {
      "url": "https://gatekeep.bsuit.app/mcp",
      "headers": {
        "Authorization": "Bearer gk_live_YOUR_KEY_ID_SECRET"
      }
    }
  }
}

Windsurf (~/.codeium/windsurf/mcp_config.json)

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "gatekeep": {
      "serverUrl": "https://gatekeep.bsuit.app/mcp",
      "headers": {
        "Authorization": "Bearer gk_live_YOUR_KEY_ID_SECRET"
      }
    }
  }
}

🟣 Integrating with Hermes Agent (Nous Research)

Hermes Agent is an autonomous multi-step agent capable of shell execution, subagent delegation, and persistent memory. Because Hermes runs unattended background loops, pairing it with Gatekeep ensures it cannot execute destructive commands without human sign-off in Slack.

1. Add Gatekeep to ~/.hermes/config.yaml

Configure Gatekeep under the mcp_servers section in your Hermes configuration file:

~/.hermes/config.yaml
mcp_servers:
  gatekeep:
    transport: http
    url: "https://gatekeep.bsuit.app/mcp"
    headers:
      Authorization: "Bearer gk_live_YOUR_KEY_ID_SECRET"
    timeout: 60

2. Add a Hermes Governance Skill / Memory Rule

Instruct Hermes Agent in your workspace instructions or persistent memory so autonomous subagents always gate high-risk actions:

Hermes Agent Governance Instruction
When running autonomous tasks that mutate production state, modify cloud infrastructure, delete files/tables, or send external messages:
- Always call the `gatekeep` MCP tool `request_approval` first.
- Wait for approval via `get_approval_status(request_id, wait_seconds=25)`.
- If the human reviewer edits the parameters (`status == "edited"`), strictly use the updated parameters returned by Gatekeep.
- Call `start_execution` right before running the command and `report_execution` immediately after.

🦞 Integrating with OpenClaw

OpenClaw agents operate continuously across messaging platforms, local shells, and browser sessions. Adding Gatekeep gives you a cryptographic kill-switch and parameter editor in Slack before OpenClaw runs privileged skills.

1. Register Gatekeep in ~/.openclaw/openclaw.json

~/.openclaw/openclaw.json
{
  "mcpServers": {
    "gatekeep": {
      "type": "streamable-http",
      "url": "https://gatekeep.bsuit.app/mcp",
      "headers": {
        "Authorization": "Bearer gk_live_YOUR_KEY_ID_SECRET"
      }
    }
  }
}

2. Add Guardrail Policy to OpenClaw SOUL.md or AGENTS.md

~/.openclaw/workspace/SOUL.md
## Mandatory Slack Approval via Gatekeep (bsuit.app)
Never execute shell commands that alter production servers, transfer funds, delete repositories, or send bulk external communications without first obtaining a verified Gatekeep token:
1. Call `gatekeep.request_approval` with the exact command/parameters.
2. Poll `gatekeep.get_approval_status` until `approved` or `edited`.
3. Call `gatekeep.start_execution` to consume the single-use token, execute the skill, and log the result with `gatekeep.report_execution`.

🐍 Python, LangGraph & CrewAI Integration

Any Python agent or workflow can call Gatekeep's REST API directly with standard httpx or requests—zero custom SDK dependencies required:

Python — Governed Tool Wrapper
import os, time, httpx

GATEKEEP_URL = "https://gatekeep.bsuit.app"
HEADERS = {"Authorization": f"Bearer {os.environ['GATEKEEP_API_KEY']}"}

def require_slack_approval(action: str, target: str, params: dict, justification: str) -> dict:
    with httpx.Client(timeout=35.0) as client:
        # 1. Create approval request
        req = client.post(f"{GATEKEEP_URL}/v1/requests", headers=HEADERS, json={
            "action": action,
            "target": target,
            "params": params,
            "justification": justification,
        }).raise_for_status().json()
        req_id = req["id"]

        # 2. Long-poll until human decides in Slack
        while True:
            status_res = client.get(f"{GATEKEEP_URL}/v1/requests/{req_id}?wait=25", headers=HEADERS).json()
            st = status_res["status"]
            if st in ("approved", "edited"):
                return status_res
            if st in ("rejected", "expired", "cancelled"):
                raise PermissionError(f"Action {action} denied by Gatekeep ({st})")
            time.sleep(1)

🔌 Remote Model Context Protocol (MCP) Reference

Gatekeep exposes a stateless JSON-RPC 2.0 MCP server at POST https://gatekeep.bsuit.app/mcp (alias: POST https://gatekeep.bsuit.app/gatekeep).

  • Protocol Version: 2024-11-05 / 2025-03-26 (Streamable HTTP)
  • Authentication: Authorization: Bearer gk_live_<key_id>_<secret>
  • Supported JSON-RPC Methods: initialize, ping, tools/list, tools/call, prompts/list, prompts/get

Available MCP Tools (6 Tools)

Tool Name Required Arguments Description
request_approval action, params, justification Creates a new governed request, computes the RFC 8785 JCS SHA-256 hash, evaluates workspace policy, and dispatches an interactive Slack card. Optional: target, risk (low|medium|high|critical), preview, editable, expires_in_seconds.
get_approval_status request_id Polls the current status of the request. Pass wait_seconds: 25 (default) to hold the HTTP connection until a human clicks a button in Slack.
provide_context request_id, answer When an approver clicks ? Ask Info in Slack (status: "needs_info"), call this tool to post the agent's answer back to the Slack card and return status to pending.
start_execution request_id, params Verifies that params match the approved revision's JCS canonical hash and atomically consumes the single-use gkt_... approval token.
report_execution request_id, status Reports final execution outcome (succeeded | failed | skipped), optional summary, and output_url. Updates the Slack card in place.
cancel_request request_id Cancels a pending request and updates the Slack card to Cancelled.

⚡ REST API Reference (/v1)

All REST endpoints are served over HTTPS from https://gatekeep.bsuit.app and require a Bearer API key in the Authorization header.

POST https://gatekeep.bsuit.app/v1/requests

Submits a new action for policy evaluation and human approval in Slack. Supports optional Idempotency-Key header (returns 200 OK if identical payload hash, or 409 Conflict if payload differs).

Request & 201 Created Response
// POST /v1/requests
{
  "action": "deploy.k8s.rollout",
  "target": "civo:prod-k3s/slack-suite",
  "risk": "high",
  "params": {
    "service": "gatekeep-app",
    "image_tag": "6829205c9e44",
    "replicas": 3
  },
  "justification": "Roll out new landing page and /docs portal",
  "callback_url": "https://ci.example.com/webhooks/gatekeep"
}

// Response (201 Created)
{
  "id": "gk_req_04550bcd55d74ba48d294be1",
  "status": "pending",
  "params_hash": "kzgOWh_-FfHbf6EG8s1vN4xL9qP2mW7rT0yU3iO5pA8",
  "risk": "high",
  "gate": "slack_channel",
  "expires_at": "2026-10-17T05:00:00.000Z",
  "poll_url": "https://gatekeep.bsuit.app/v1/requests/gk_req_04550bcd55d74ba48d294be1"
}
GET https://gatekeep.bsuit.app/v1/requests/:id?wait=25

Retrieves the current state of an approval request. Pass ?wait=1..30 to enable server-side long-polling: the server holds the request open until the status changes from pending or the timeout elapses.

// Response (200 OK)
{
  "id": "gk_req_04550bcd55d74ba48d294be1",
  "status": "approved",
  "action": "deploy.k8s.rollout",
  "target": "civo:prod-k3s/slack-suite",
  "risk": "high",
  "gate": "slack_channel",
  "current_revision": 1,
  "params_hash": "kzgOWh_-FfHbf6EG8s1vN4xL9qP2mW7rT0yU3iO5pA8",
  "expires_at": "2026-10-17T05:00:00.000Z",
  "decided_at": "2026-10-17T04:31:12.000Z",
  "executed_at": null
}
POST https://gatekeep.bsuit.app/v1/requests/:id/consume

Atomically verifies the single-use approval_token (gkt_...) and checks that params_hash matches the approved revision. Transitions status to executing.

// Request Body
{
  "approval_token": "gkt_9f8a21c4e7b01928374655647382910abcdef1234567890",
  "params_hash": "kzgOWh_-FfHbf6EG8s1vN4xL9qP2mW7rT0yU3iO5pA8"
}

// Response (200 OK)
{
  "ok": true,
  "status": "executing",
  "jti": "c9a8b7d6-e5f4-4321-8765-1029384756ab"
}
POST https://gatekeep.bsuit.app/v1/requests/:id/receipt

Records the final execution outcome (succeeded, failed, or skipped) and updates the Slack card with the execution badge, summary, and duration.

// Request Body
{
  "status": "succeeded",
  "summary": "2/2 replicas rolled out healthy in namespace slack-suite",
  "output_url": "https://signoz.bsuit.app",
  "duration_ms": 1420
}

// Response (200 OK)
{
  "ok": true,
  "status": "executed"
}
POST /v1/requests/:id/context & /v1/requests/:id/cancel

POST /v1/requests/:id/context submits {"answer": "..."} when a reviewer asks a question (needs_info → pending).
POST /v1/requests/:id/cancel submits {"reason": "..."} to abort a pending request (pending → cancelled).

📦 TypeScript / Deno / Node.js SDK (@suite/gatekeep-sdk)

The official TypeScript SDK provides a high-level gk.guard() method that orchestrates request creation, long-polling, JCS hash validation, token consumption, and execution receipt reporting in a single call.

TypeScript — GatekeepClient.guard()
import { GatekeepClient } from "@suite/gatekeep-sdk";

const gk = new GatekeepClient({
  apiKey: process.env.GATEKEEP_API_KEY!,
  baseUrl: "https://gatekeep.bsuit.app",
});

const result = await gk.guard(
  {
    action: "db.migration.apply",
    target: "postgres:prod-origin",
    risk: "critical",
    params: {
      migration: "004_add_billing_index.sql",
      lock_timeout_ms: 5000,
    },
    justification: "Add composite index for monthly quota queries",
  },
  async (approvedParams) => {
    // Runs ONLY after Slack approval (and uses revised params if human edited them)
    return await applyMigration(approvedParams);
  },
);

🔒 Cryptographic Integrity: RFC 8785 (JCS) & Single-Use Tokens

Standard JSON serialization is non-deterministic because object key ordering varies across languages and runtimes. Gatekeep implements RFC 8785 (JSON Canonicalization Scheme — JCS) to guarantee byte-identical canonical representations across Deno, Node.js, Python, Go, and Rust.

How Canonical Hash Binding Works

  1. Gatekeep constructs the canonical envelope: {"action": action, "params": params, "revision": revision, "target": target}.
  2. All object keys are recursively sorted lexicographically by UTF-16 code units, whitespace is stripped, and numbers are formatted per IEEE 754 / ECMAScript rules.
  3. The UTF-8 byte stream is hashed with SHA-256 and encoded as base64url (no padding).
  4. When a human clicks ✓ Approve in Slack, the button payload includes the exact params_hash displayed on the card. If the card revision changed in the meantime, PostgreSQL rejects the stale decision.
Tamper Protection: If an AI agent gets approval for {"amount_cents": 500} and attempts to call start_execution with {"amount_cents": 50000}, the recomputed JCS SHA-256 hash will not match the token's bound params_hash, and Gatekeep immediately blocks execution.

⚖️ Policy Engine & Governance Rules

Each Slack workspace has a versioned GatekeepPolicyDocument evaluated on every incoming request. Rules are matched in order using glob patterns on action and target.

Example Workspace Policy JSON
{
  "version": 2,
  "default_verdict": "REVIEW",
  "default_risk": "medium",
  "default_ttl_seconds": 1800,
  "default_channel_id": "C0C74RUH52R",
  "rules": [
    {
      "id": "allow-staging-deploys",
      "action_glob": "deploy.*",
      "target_glob": "env:staging*",
      "verdict": "AUTO_APPROVE",
      "risk": "low"
    },
    {
      "id": "prod-critical-review",
      "action_glob": "deploy.k8s.*",
      "target_glob": "civo:prod*",
      "verdict": "REVIEW",
      "risk": "critical",
      "ttl_seconds": 900,
      "slack_channel_id": "C0C74RUH52R"
    },
    {
      "id": "block-drop-database",
      "action_glob": "db.drop.*",
      "verdict": "DENY",
      "risk": "critical"
    }
  ]
}

💬 Slack Interactive Workflows

Every Gatekeep approval card in Slack gives human reviewers four interactive actions:

  • ✓ Approve: Atomically transitions the request to approved, generates a single-use gkt_... token (5-minute TTL), cancels the expiration timer, and updates the card with the approver's Slack handle.
  • ✎ Edit: Opens a Slack modal pre-populated with the decrypted JSON parameters. When submitted, Gatekeep increments current_revision (e.g., Rev #2), computes the new RFC 8785 JCS hash, encrypts the new parameters with AES-256-GCM, and transitions the request to edited.
  • ? Ask Info: Opens a modal for the reviewer to ask a clarifying question (e.g., "Did the dry-run migration succeed on staging?"). Transitions the request to needs_info so the agent can reply via provide_context.
  • ✕ Reject: Opens a modal for an optional rejection reason, transitions the request to rejected, and immediately notifies the waiting agent to abort.