privacyagent guideagent apiledger specanchoringopentelemetry exportagents supported

Agent API

A read-only, versioned JSON API for AI agents (or an MCP server acting for one) to learn what agent-blackbox is and to read back what it recorded, without scraping the CLI or the UI. It is served by the recorder on 127.0.0.1 (default port 7071, BLACKBOX_PORT overrides it) under /v1/agent/.

Start with GET /v1/agent/capabilities: it lists every endpoint, the rule names, the record kinds and what the API never returns. GET /v1/agent/openapi.json describes the same API as OpenAPI 3.1, generated from the same table, so the two cannot drift apart.

Authentication and scopes

Send the token in the x-blackbox-token header, like every other recorder endpoint. Two tiers, using the two tokens that already exist:

TierTokenEndpoints
publicingest token (the one hooks hold) or admin tokencapabilities, openapi.json, status, rules
adminadmin tokensessions, records

The public tier is what the agent itself may read, so it says nothing about enforcement: no mode, no findings, no reasons for a denial (see "Denials stay quiet" in the README). Records and sessions are for the human, or for an agent the human delegates the admin token to.

With the recorder as a dedicated user (blackbox harden) the admin token is not readable by the agent's OS user; with the default same-user install every token is readable by any process running as you, as described in PRIVACY.md.

Endpoints

All responses are JSON with a schema field (blackbox.agent/v1). New optional fields may appear; existing fields keep their meaning within v1.

EndpointScopeReturns
GET /v1/agent/capabilitiespublicname, version, endpoints, rule ids, record kinds, guarantees
GET /v1/agent/openapi.jsonpublicOpenAPI 3.1 document
GET /v1/agent/statuspublicrecording, ledger_seq, chain_ok, encrypted
GET /v1/agent/rulespublicrule catalogue: id, usual decision, one-line summary
GET /v1/agent/sessionsadminsessions, newest first: id, first/last time, cwd, event/tool/decision counts, taint flag names
GET /v1/agent/recordsadmincompact records; query session, kind (default decision,taint), after (cursor), limit (1 to 500, default 100); next_after is the cursor for the next page or null

What is never returned

Record fields follow spec/ledger-v1.md; records returns the subset seq, ts, kind, hash, event, session_id, prompt_id, tool_name, tool_use_id, decision, rule, reason, flag, why, hosts, and the settings/anchor fields.

Example

TOKEN=$(cat ~/.blackbox/keys/token)
curl -s -H "x-blackbox-token: $TOKEN" http://127.0.0.1:7071/v1/agent/capabilities
curl -s -H "x-blackbox-token: $(cat ~/.blackbox/keys/admin-token)" \
  "http://127.0.0.1:7071/v1/agent/records?kind=decision&limit=20"

MCP server

blackbox serve-mcp is a local MCP server (stdio, newline-delimited JSON-RPC, protocol 2025-06-18, no dependencies) that exposes the same API as read-only tools, so a coding agent can use it like any other tool:

{ "mcpServers": { "blackbox": { "command": "blackbox", "args": ["serve-mcp"] } } }
ToolEndpointOffered
blackbox_capabilities/v1/agent/capabilitiesalways
blackbox_status/v1/agent/statusalways
blackbox_rules/v1/agent/rulesalways
blackbox_sessions/v1/agent/sessionsonly with --admin
blackbox_records/v1/agent/recordsonly with --admin

Without --admin the server uses the ingest token and can only reach the public tier. --admin is for a person who wants to give an agent the decision trail; with the default same-user install the agent could read that token anyway (see PRIVACY.md). Every tool is annotated readOnlyHint, returns the JSON as structuredContent and declares its outputSchema. Note that serve-mcp is separate from blackbox mcp, which audits the MCP servers you have configured.

CLI --json

For scripts and agents that prefer a command: blackbox status|sessions|timeline|verify|docs --json print one JSON document (schema: blackbox.cli/v1, except verify, which prints the verifier's own result). timeline --json has the same metadata-only records as the API; use blackbox show <n> to open a payload. scan, mcp, skills and eval already had --json.

Edit this page on GitHub