Skip to content

Reference

Errors

MCP JSON-RPC error codes returned by gbrain serve.

The MCP server uses standard JSON-RPC 2.0 error envelopes plus a small set of extended codes specific to GigaBrain. CLI commands surface the same conditions on stderr (and as JSON when --json is set).

{
"jsonrpc": "2.0",
"id": <request_id>,
"error": {
"code": -32009,
"message": "expected_version 7 does not match current 9",
"data": { "current_version": 9, "expected_version": 7 }
}
}

The data field is best-effort: when populated it carries machine-readable detail (current versions, conflicting slugs, recovery hints).

CodeNameWhen
-32001NotFoundA referenced page, link, collection, or gap doesn’t exist.
-32002AmbiguityA bare slug matches pages in more than one attached collection. Re-issue with <collection>::<slug>.
-32003InternalUnexpected server-side or database failure. Treat as transient and retry; if persistent, file an issue.
-32009ConflictOCC mismatch on brain_put, unique-constraint violation, or concurrent rename.
-32010CollectionRestoringErrorThe target collection is mid-restore or carries needs_full_sync = 1. Mutations are gated until reconciliation completes.
-32011CollectionReadOnlyErrorThe target collection is not writable. Either it’s flagged read-only at attach time or another serve session holds the write lease.
-32602InvalidParamsStandard JSON-RPC code for parameter validation failures (e.g. invalid slug characters, unknown tool name, malformed dates).
CodeNameWhen
-32700ParseErrorBody wasn’t valid JSON.
-32600InvalidRequestRequest envelope didn’t match JSON-RPC 2.0.
-32601MethodNotFoundUnknown method (e.g. wrong tool name on tools/call).
-32603InternalErrorGeneric JSON-RPC internal error (rare; we prefer -32003).

brain_put accepts an optional expected_version for safe updates. Two failure modes:

ConditionResponse
Page exists, you supplied no expected_versionTreated as create-only; returns Conflict because the page already exists.
Page exists, your expected_version doesn’t matchReturns Conflict with data.current_version set. Re-fetch the page, rebase your edit, retry.
Page doesn’t exist, you supplied an expected_versionReturns Conflict (you expected an update; there’s nothing to update).
Page doesn’t exist, no expected_versionCreates the page at version 1.

A typical agent loop:

fetch → version v
construct → new content from v
brain_put → expected_version = v
on Conflict:
fetch again → version v'
rebase edit on v'
retry with expected_version = v'

When more than one collection is attached, the same slug may exist in two of them. A bare slug returns Ambiguity with a data.candidates list. Resolve by qualifying:

Terminal window
# bare slug
gbrain get people/alice
# → Ambiguity: candidates: ["work::people/alice", "personal::people/alice"]
# qualified
gbrain get work::people/alice
CodeRetry?
Internal (-32003)Yes, with backoff.
Conflict (-32009)Yes, after re-fetching state and rebasing. Bare retries are pointless.
CollectionRestoringErrorYes, after the collection finishes restoring (poll brain_collections or watch state).
Everything elseNo — fix the request and resubmit.