Skip to main content
Version: v5.8.1

MCP server

Included from Basic tier

OpsChain as a Model Context Protocol tool server, shipped as a base capability: opschain mcp serve lets any MCP client — a desktop assistant, an IDE, an agent framework — query the estate, raise and follow changes and workflows, read events, chains, audit and evidence, raise and read change records, and answer approvals, through a deliberately curated tool vocabulary — as the person whose credential it holds, or (--as-agent) as a registered OpsChain agent that person owns.

The command is an API client, not a platform surface. It speaks MCP (JSON-RPC 2.0) to the assistant and the OpsChain API to the targeted server, holding no enforcement logic of its own: it cannot bypass an approval gate, cannot read what its principal may not read, and cannot suppress audit, because enforcement and audit happen server-side on every call exactly as for any other API caller.

Transports​

  • stdio — the local-assistant shape: the client launches opschain mcp serve as a child process; one JSON-RPC message per line on stdin/stdout, logs on stderr only.
  • streamable HTTP — opschain mcp serve --http <addr> for hosted clients: messages POST to /mcp, each answered with a single JSON response. SSE streaming is not offered in this first cut; a client opening the stream (HTTP GET) is refused politely. TLS termination is the operator's reverse-proxy concern.

The handshake negotiates the protocol revision — 2025-06-18 preferred, older revisions accepted per the protocol's negotiation rule — and names the server and its version. Sampling and elicitation requests (a tool server asking the client's model or user for input) are always refused by name.

The tool vocabulary​

A curated set of governed verbs, never a generated one-to-one dump of the API: each tool is a typed wrapper over one or two API calls, and its description carries the governance contract (creation may hold for approval; the tool returns the gate state, it never waits).

GroupTools
Estate readslist_projects, list_nodes, get_node, get_properties
Infrastructurelist_infrastructure, get_host
Change lifecycleplan_change, create_change, get_change, get_change_logs
Workflowsrun_workflow, list_workflow_runs, get_workflow_run
Events and chainsquery_events, get_chain
Audit and evidencequery_audit, get_evidence
Approvalslist_my_approvals, answer_approval
Change records and storieslist_change_records, get_change_record (the record's story), create_change_record, link_run_to_change_record, get_run_story (a run with its steps, its approval checklist and its activity chain)
Coverage and workcoverage (the coverage query, default window the last 7 days), policy_coverage (whether a run on a path must name an approved change record), list_my_work

create_change and run_workflow take rationale (shown to the approvers; required when acting as an agent) and change_record (the approved record, by id or code, the run joins). list_my_work answers by who is asking: for a person, the approval checklists waiting on them; for an agent, its own changes held for approval and its open recommendations. create_change_record raises a pending record — a person approves it; no tool approves, closes or attests anything as an agent.

policy_coverage reads GovernanceService.GetPolicyCoverage: the approval policies carrying require_change_record whose path and action patterns and metadata predicates cover the path (a workflow path is tested at the workflow's effective target), decided by the server's compiled policy matcher in memory — never by a path's name — and whether a run there must name an approved record (every covering policy while packs:change-governance holds, the strict ones after it lapses). Read on the node, 404-on-deny; on a server on the SQLite store, which has no approval policies, it answers uncovered with approval_policies_available: false.

The estate reads accept entity paths: get_node and get_properties read an entity like any other node, and list_nodes takes include_entities (with a root_path, which it then requires) to nest the entities under that subtree into the tree it returns.

Read tools carry readOnlyHint: true; mutating tools carry destructiveHint: true, honestly. Tools whose underlying surface the licence does not entitle (the evidence ledger without the packs:security-governance entitlement, the approvals inbox without a governance pack) are omitted from the tool listing for that server; execution re-checks regardless — listing is a courtesy, the API is the enforcement.

As an agent​

opschain mcp serve --as-agent <code> makes the session an instance of a registered agent, owned (for accountability) by the person who enrolled it:

  • Enrolment. The first run redeems a registration token (--token, from opschain admin agent-token create --project <code> --group claude-code --code <code>) and keeps the keypair in the state directory (--dir, default <opschain home>/mcp-agents/<code>). The person's own login on the server identifies them and is declared as the agent's owner — accountability on the server, never a grant. The command refuses by name a later session whose login is not the recorded owner, one naming an agent the directory does not hold, or one not enrolled there without a token; that check is a courtesy made on the developer's machine. Enrolment needs packs:agents and is refused by name without it.
  • The state directory is the credential. Its keypair (directory 0700, files 0600, written by the command) authenticates the agent: protect it like a private key. Anyone holding a copy acts as the agent, and the server attributes it to the agent's principal with the enrolling person as owner; revoke the agent if the directory is exposed.
  • The channel. The session holds the agent's channel open — the agent is on the fleet and posture pages, and halting the agent plane or the agent severs it: every call then answers the halt's text verbatim. Every tool call is sent over the channel's request lane as the agent's service account; the server applies the agent's trust tier, ceilings and the human-verb refusals and writes the agent request event with the applied tier.
  • The tier. Under SUPERVISED, create_change and run_workflow create the run with the injected approval gate and return its state without waiting; a target no grant covers is refused by name. answer_approval and list_my_approvals are not listed, and a call to one is refused by name.
  • The change-record refusal. Before a run is created, the session asks policy_coverage for the target; a covered target is refused by name unless the call names an approved change record in change_record (a pending or closed record is refused with its state). A target no such policy covers behaves as today; a coverage answer that cannot be read refuses the write. The server's own require_change_record condition still decides at creation.
  • Correlation. Every tool's schema accepts correlation_id (a UUID): one id for every call of one unit of work — a client turn — so the reads, the record, the run and the recommendation of one task share one chain; a call without one gets an id of its own. The id rides the agent request event and is stamped on the run the call creates.
  • Masking. Every result and refusal is masked before it leaves the process: secret-shaped JSON members at any depth (including JSON held in a *_json field), bearer values, the registration token and every OPSCHAIN_*TOKEN* value in the environment read ******; page tokens, ids and secret references are left as they are.

Postures. The local lane is refused by name ("mcp serve needs a server"), as on the floor. On a server on the SQLite store the agent enrols with no owner (there are no logins), its trust grants decide its tier as on PostgreSQL — with no grant the agent's run is refused by name — and nothing is covered by require_change_record (there are no approval policies). On PostgreSQL, everything above.

Mandating the assistants lane​

An organisation that wants every assistant on the estate to be a registered agent — owned, tier-governed, halted with the agent plane, its work on one correlation chain — sets the global setting agents.mcp_requires_agent_identity to true (default false; opschain docs settings-reference). From then on a session on a person's login or API token (no --as-agent) is refused by name at start, exit code 2, and the server refuses every call such a session makes with the same text, permission_denied:

this estate reaches its assistants only as registered agents — run `opschain mcp serve --as-agent <code> --token <registration token>`; ask an administrator for an agent code

The server recognises the session by the client identification every opschain mcp serve request without --as-agent carries (opschain-mcp/… in the user agent) and by the principal: an enrolled agent is never refused, and an ordinary API or CLI call on the same token is unaffected — the mandate governs the assistant lane, not the API. Each server replica re-reads the setting at most every 30 seconds, and a value that is not true, false or null refuses the session (fail closed) and is refused when written. Turn it on once every team has an agent code (opschain admin agent-token create … --code <code>), so nobody is locked out on the day it lands. The local lane has no setting (it refuses mcp serve already), and a server on the SQLite store holds no global settings document, so the setting cannot be turned on there.

Authentication and audit​

Without --as-agent the credential is the CLI's ordinary token lane: --auth-token, or the stored login for the targeted server. For unattended assistant use, configure a dedicated service-account token so the assistant acts as a governed, individually attributable identity rather than as a person; a personal login is right when the assistant acts as you.

Every invocation is an ordinary API call through the existing request log and event lanes — nothing new to trust. The MCP tool name rides the client identification (opschain-mcp/<version> tool/<name> in the request's user agent), so the request log answers "which assistant verb did this" beside the principal.

Errors​

Named refusals become MCP tool errors (isError: true) with the server's refusal text verbatim — an approval-policy hold, a validation violation or an entitlement lapse reads to the assistant exactly as it reads to a CLI user. Authorisation denials answer not found, exactly as the API answers them: denied and missing stay indistinguishable.

See also​

  • opschain docs cli/mcp-serve — the command manual: transports, flags, exit codes.
  • opschain learn 12.9 — connecting Claude Desktop, an IDE or a hosted client, step by step.