action.log

Live

Log an action event to the Cortex action ledger.

CategoryAction
JSON-RPCtools/call
EndpointPOST /mcp
Sourcepackages/mcp-tools/src/tools/action-log.ts

Description

Persists a consequential action to the action_ledger with co-committed audit row. Use after trust.check for coding.* and other governed action classes.

Input schema

FieldTypeRequiredDescription
action_classstringyesAction class, e.g. "coding.git_push", "coding.git_commit", "coding.shell_exec".
counterpartystringnoCounterparty slug, e.g. "repo:cortex-ai/main". Resolved to UUID via extension_counterparties.
outcome"completed" | "skipped" | "failed"yesAction outcome at time of logging.
descriptionstringnoHuman-readable description of the action taken.
metadataRecord<string, unknown>noOptional structured metadata (commit SHA, file paths, exit_code, etc.).
idempotency_keystringnoOptional caller-supplied idempotency key. Generated automatically if omitted.
autonomy_level1 | 2 | 3noAutonomy level at time of action. Defaults to 1 if not supplied.

Output shape

typescript
{
  ok: boolean;
  ledger_entry_id?: string;
  error?: string;
  message?: string;
}

Example call

JSON-RPC tools/call request body (omit the JSON-RPC envelope when using an SDK; the SDK adds it for you):

jsontools/call params
{
  "name": "action.log",
  "arguments": {
    "action_class": "coding.git_commit",
    "counterparty": "repo:cortex-ai/main",
    "outcome": "completed",
    "description": "chore: verify dogfood",
    "metadata": { "commit_sha": "abc123" }
  }
}

Example response

Tool results are always wrapped as content[0].text with a stringified JSON body. The shape below is what you get back from JSON.parse(result.content[0].text):

jsonparsed result body
{
  "ok": true,
  "ledger_entry_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}

Errors this tool can return

CodeMeaning
invalid_argumentsTool input failed Zod validation.
unauthorizedMissing or invalid bearer token.
write_failedThe tool could not persist the requested write (ledger, episode correction, etc.).

See the full error catalog for resolution steps on each code, plus the standard transport-layer responses (401, 429).