Use emisar tools from the shell
The emisar-mcp program lets agents and scripts find actions, request work,
and read results from a terminal. They do not need an MCP client. CLI and MCP calls
go through the same server and runner checks. The key you use determines which
hosts and actions you can access.
Authenticate once, with emisar-mcp auth
or during the
bridge install
step. After that, commands work without setting environment variables.
The CLI saves the key in local files that only your user can read.
Run emisar-mcp
by itself to see one command reference grouped into Fleet, Actions, Runbooks,
Continuations, Accounts, and MCP client commands. list_tools
shows the live server catalog in the same operational groups. MCP clients start this
program automatically and send MCP requests through stdin.
$ emisar-mcp auth $ emisar-mcp list_tools $ emisar-mcp help find_actions $ emisar-mcp get_action --help
auth
opens the approval page in your browser. Choose an account there. The CLI stores a
dedicated key for that account and makes it current.
Use auth status
to inspect the current account and endpoint without contacting the control plane or
printing the key.
list_tools
fetches and groups the live catalog. help <tool>
shows the server-owned description and top-level arguments.
<tool> --help
is a shorthand for non-conflicting tool names. Add --json
to list_tools
or help
for exact descriptors and complete input schemas.
Authenticate each account once. accounts list
shows the accounts stored on this machine. It marks the current one with a star.
accounts use <slug-or-id>
changes the current account. A leading --account <slug-or-id>
uses another account for one command without changing the current one.
$ emisar-mcp auth $ emisar-mcp accounts list $ emisar-mcp accounts use immersive $ emisar-mcp --account blitz list_runners
--json
calls a tool once and prints its exact structuredContent
object with no styling. It does not make follow-up calls. After a network failure,
the CLI may send the same request once more with the same operation ID. Put
--json
last, pass -
to read one JSON object from stdin, and parse stdout as JSON. For conditional or
mutually exclusive arguments, use help <tool> --json
to see the full rules for valid inputs.
Fleet#
These commands list your runners and packs. By default, they print runner details
and short pack summaries for a person reading the terminal. Add --json
to receive the exact MCP structuredContent
object instead.
-
list_runnersshows connectivity, hostname, group, labels, packs, issues, and exactrunner_refvalues. JSON arguments can filter by status, runner name/group/host text, runner, pack, action, or issues. -
list_packsshows trusted versions, availability, action counts, issues, and exactpack_refvalues. The default includes executable packs; useinclude: "all"to diagnose trusted unavailable packs.
$ emisar-mcp list_runners $ emisar-mcp list_runners '{"statuses":["connected"]}' $ emisar-mcp list_packs $ emisar-mcp list_packs '{"include":"all"}'
Actions#
find_actions
accepts a plain-text task and shows ranked matches. get_action
shows what the action does, the inputs it accepts, and which runners can use it.
Pass it the immutable pack_ref
returned by find_actions. recent_runs
and get_operation
let you review runs and recover a request after losing its response.
In readable output mode, run_action
prints the operation ID, then follows only exact wait_for_run
follow-up calls for those runs. It can wait on several runners at once and
shows approvals, final status, exit codes, and output. Ctrl-C stops waiting and exits
130; it does not cancel the action. The diagnostic prints a get_operation
command you can use later to check what happened.
$ emisar-mcp find_actions "postgres replication" $ emisar-mcp get_action '{"action_id":"postgres.replication_lag","pack_ref":"<pack_ref from find_actions>"}' $ emisar-mcp recent_runs '{"scope":"own","limit":10}' $ emisar-mcp get_operation '{"operation_id":"op_..."}'
Runbooks#
list_runbooks
shows live releases, unpublished changes, and workflow size. get_runbook
shows inputs, stages, and action steps. Draft commands show the content digest, current
live release, and review link.
In readable output mode, execute_runbook
follows only calls for that runbook execution. It waits for approval or expiry
and gets the available output for each action. It prints up to 16,384
characters per action and links to the run page when more remains. Ctrl-C stops
waiting only. Add --json
when a script or LLM should receive the original execution response and decide whether
to call wait_for_run
itself.
Call an exact tool name with one JSON object. Omit the object when the tool accepts {}, or pass
-
to read it from stdin. Stdin keeps operational details out of the process list and works
cleanly with JSON-producing tools such as jq. Put --json
last when a script needs the exact structuredContent
object.
$ query='diagnose postgres replication' $ jq -cn --arg query "$query" '{query:$query}' \ | emisar-mcp find_actions - --json >actions.json $ jq -e '.candidates' actions.json
A successful tool call exits 0 and prints readable text, or JSON with --json. In JSON mode, check the returned runs to see whether the host
work succeeded. Follow any returned calls needed to get the final result.
Tool, MCP, sign-in, and network failures after sending a request exit 1.
Invalid commands or JSON exit 2. If the CLI cannot tell whether the server received
a request that changes something, its JSON response includes data.operation_id.
Check that ID with get_operation before sending new work.
In readable output mode, run_action
exits 1 if the final status is anything
except success. In that mode, execute_runbook
exits 1 for halted
or cancelled.
Policy, approvals, signed dispatch, and audit apply in both modes.
Tool and MCP error objects stay on stdout in the selected format, so a script can read
recovery data such as data.operation_id. A safe local diagnostic may also
appear on stderr. Configuration and usage failures write their diagnostic to stderr.
Color appears only in a terminal; pipes and redirected output stay plain. Set
NO_COLOR
to turn terminal color off. --json
output on stdout never contains styling.
When both authentication environment variables are absent, direct commands use the
current account. A leading --account <slug-or-id>
selects another stored account for that command. Use accounts list --json
to see immutable account IDs. Setting EMISAR_URL
and EMISAR_API_KEY
together overrides it for that command. Setting only one is an error.
Do not combine the pair with --account.
Stdio MCP clients never use direct-CLI account storage. Run emisar-mcp auth
and choose the account again if its credential expires or is revoked. Revoke connected keys from AI agents.
The local auth, accounts, connect, disconnect, help, and
list_tools
commands do not hide server tools with the same names. Prefix an exact tool call with --, for example emisar-mcp -- help '{}'.
MCP clients#
connect
detects the AI clients installed on this machine and writes the emisar server into
each one you choose; an already-connected client is left alone. disconnect
removes that entry and does not change anything else in those files.
-
--client <id>names one client; repeatable.--alltakes every detected client without asking. -
--auto-permit(connect only) also turns off the client's own "allow this tool?" prompt for the emisar server alone. emisar still decides every call server-side. Claude Code, Gemini CLI, Codex CLI, and Grok CLI support this per-server setting. -
--forget(disconnect only) also deletes the stored direct-CLI accounts. A key removed from a config keeps working until you revoke it under AI agents.
$ emisar-mcp connect --all --auto-permit $ emisar-mcp disconnect --client cursor
Calling the endpoint
A custom client uses an agent key with the emk-
prefix. Create one from Manage agents & keys. Send JSON-RPC
requests to the HTTPS endpoint below. Use the method sequence for your protocol version.
# This legacy-compatible request returns the tool list. $ curl -X POST https://emisar.dev/api/mcp/rpc \ -H "Authorization: Bearer $EMISAR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
Protocol methods
emisar serves three protocol revisions on one stateless endpoint. It does not issue an
Mcp-Session-Id
or require sticky routing.
| Revision | Start | Other methods | Cancellation |
|---|---|---|---|
2026-07-28 |
server/discover |
tools/list, tools/call
|
No protocol cancellation method. |
2025-11-252025-06-18
|
initialize |
ping, tools/list, tools/call
|
notifications/cancelled
stops observation and does not send a response.
|
A 2026-07-28
request declares its version in _meta. It also sends
MCP-Protocol-Version
and Mcp-Method
headers. A tools/call
request also sends Mcp-Name. Modern results include resultType
and cache hints.
Request IDs are strings or integers and are returned with the same JSON type. A frame without an ID is a notification, and a mutation sent as one never runs. A mutation needs a request ID for safe recovery.
Fourteen fixed tools
Each tool below keeps the same inputs as you add packs. Clients discover new actions through search and fetch the arguments for the action they choose. See the token counts for a full action catalog.
| Tool | Purpose |
|---|---|
| list_packs | List currently trusted packs with bounded action summaries and deployment issues. |
| list_runners | Inspect runner connectivity, compatibility, and exact runner refs. |
| find_actions | Find a bounded set of actions by task or exact identifiers. |
| get_action | Read one immutable action contract and its compatible runners. |
| run_action | Dispatch one exact action to one or more selected runners. |
| get_operation | Recover one exact mutation after an ambiguous response. |
| wait_for_run | Wait for one run to change or reach a terminal state. |
| cancel_run | Cancel one of your own runs while it is still queued or waiting for approval. |
| recent_runs | Inspect workspace run history with exact identity filters. |
| list_runbooks | List every runbook with its live release and any unpublished change. |
| get_runbook | Read one runbook's live release, or its unpublished change. |
| execute_runbook | Execute the live release, or an explicitly allowed unpublished change. |
| create_runbook_draft | Start a new runbook as an unpublished change. |
| update_runbook_draft | Replace a runbook's unpublished change without changing its slug. |
Discovery
Use find_actions
to find an action, then get_action
to read its arguments and see which runners can execute it. If you already know
the target, pass its runner reference. Without one, discovery may return a trusted
action that none of your available runners can execute. Use list_runners
to choose a host, or list_packs
to browse the catalog.
Pack and runner lists return 15 items per page by default. To get the next page,
pass the previous response's next_cursor. find_actions
also returns a ready-to-send next
call. Keep the query unchanged
between pages; a cursor from a different query is rejected.
include: "executable"
is the normal path and omits capabilities that
cannot run anywhere in scope. include: "all"
is diagnostic: it keeps
trusted packs and actions that are outside your action access or currently unavailable, with issues such as no
connected runner, a missing executable, or a descriptor mismatch. Pending, rejected,
revoked, and retirement-blocked pack refs are operator-only facts that discovery
omits. When an expected ref is absent, review it in Packs.
A pack_ref
has the immutable form pack@version/sha256:hash. A runner_ref
has the identity-bound form name~sha256-prefix. Copy both exactly from
discovery: a reconnect or reinstall that reuses the same external ID keeps the ref,
while a new external ID or a pack change can make a selection stale.
Running an action
run_action accepts one explicit execution intent:
| Field | Requirement | Meaning |
|---|---|---|
| action_id | Required | Exact action returned by get_action. |
| pack_ref | Required | Immutable pack generation returned by discovery. |
| runner_refs | Required | One to sixteen distinct, explicit targets. |
| args | Required | One JSON object validated against the trusted action schema. |
| reason | Required | Operator-facing audit reason for this execution. |
| evidence | Optional | What you already observed that makes the action necessary: prior findings or run ids. |
| expected | Optional | The outcome you expect if it works. It is stored with the run and shown to approvers. |
| wait | Optional | Duration string: "0", "1s"–"60s", or "1ms"–"60000ms". The default is 45s and the maximum 60s. |
Dispatch preflight re-resolves the complete target set, pack trust, descriptor, schema,
policy, certificate window, and signature requirement, and creates the complete
fan-out or nothing. It never silently drops a stale target. Policy can still
produce a mix of allowed, pending-approval, and denied runs inside the accepted
operation. A parked run is not an error: it comes back in a successful response with
run status pending_approval, an approval URL, and a
wait_for_run
continuation. Wait on the run.
Operations and recovery
Every run_action, execute_runbook, create_runbook_draft, and
update_runbook_draft
receives a private operation_id. The stdio bridge derives it from its private
process nonce and request sequence. For native HTTP clients, the portal derives it from
the exact request and credential lineage. Automatic rotation successors share that
lineage. The portal reserves the operation ID in the same transaction as the mutation.
Repeating the same request and facts returns the original resource; changed facts
conflict. Models never create operation identifiers.
A successful mutation returns its operation ID. If the bridge loses an HTTP response, its
correlated JSON-RPC error includes that same ID. After a mutation, pass it to
get_operation
before deciding whether to issue new work. Read calls retry normally. Run history
is for investigation and does not replace exact operation recovery.
Waits and cancellation
run_action
waits 45 seconds by default, up to 60. wait_for_run
waits the same and returns the current state when its deadline expires. The 45-second
default keeps each call inside the 60-second tool limit some clients, such as Slack,
enforce.
An API key and the keys created by rotating it share a limit of eight simultaneous
waits per portal server. This group of keys is called a credential lineage.
The stdio bridge handles up to eight requests at once, each with a 90-second
HTTP deadline, so waiting for one result does not block other calls. Clients can also use ping.
Cancelling an MCP wait stops waiting for the result. It does not undo infrastructure changes that have already been committed.
To cancel a run that has not reached a runner, call cancel_run
with its run_id. The run is cancelled, its approval request closes, and
the result is the same summary wait_for_run
returns. A run already delivered to a runner is refused with run_not_cancellable; an operator stops it from the console.
Runbooks and signing
A runbook is one slug carrying a live release, slug@N, and at most one
unpublished change. Discovery returns the live release by default. To edit an existing
runbook, read it, then call update_runbook_draft
with the definition_sha256
you read. The slug never changes, the edit lands as the runbook's one unpublished
change, and a concurrent write answers draft_changed
instead of being overwritten.
Before authoring a step, use get_action
to inspect its argument and output schemas. See
runbook output sources and extractors
for stdout, stderr, and schema-validated JSON bindings.
Execution runs the live release. An older slug@N
answers not_live
rather than silently running current content. An unpublished change never runs by
default; list_runbooks
only shows that one is waiting. Read it with status: "draft", then pass the
slug to execute_runbook
with allow_draft: true
and the exact definition_sha256
you consent to run. A draft test uses the same target, trust, policy, approval,
scheduler, runner, and audit path as a live execution. It can cause the actions'
real effects, and it publishes nothing: publication remains a human action in Runbooks.
A definition can contain 32 inputs, 16 stages, and 16 target refs per step within 64 KiB.
A resolved execution can contain 256 items. Execution returns after the durable execution
and its initial stage state commit. The response groups exact items under stages and shows
extracted output and condition evidence, wait state, stable blocking reason, and only the
latest physical attempt. Follow its wait_for_run
continuation while it remains active. Use recent_runs
for paginated attempt history.
Customer-CA signing currently protects only run_action. A runbook that targets
a signature-enforcing runner fails closed with signed_runbook_unsupported.
Errors
| Code | Meaning | Next step |
|---|---|---|
| target_contract_changed | The selected action, pack, or runner generation is stale. | Call get_action again and make a fresh selection. |
| action_unavailable | The trusted action is unavailable, or the requested runners cannot execute it. | Follow the returned list_runners continuation to review the targets. |
| operation_conflict | One operation ID was reused with different facts. | Treat it as a security error. Do not retry. |
| signed_runbook_unsupported | A runbook includes signature-enforcing targets. | Use individually signed run_action calls. |
These are the common codes. The full list is the error code
enum in the MCP API schema.
When you have a symptom instead of a code (a client
that cannot connect, an outdated bridge, a refused tool call), start from troubleshooting, which routes back here once it identifies the problem.
Approval gates, denials, decisions, and terminal results are recorded. See the audit trail and policies & approvals.
MCP methods and tool inputs are v1 compatibility surfaces. Read Compatibility and deprecation.