Skip to content

Reference

MCP tool reference

Every brain_* tool exposed by gbrain serve, with parameters, returns, and JSON-RPC examples.

gbrain serve exposes a stdio MCP server that speaks JSON-RPC 2.0. Seventeen brain_* tools cover the read, write, graph, intelligence, and stats surfaces. This page is the canonical catalog.

The transport is stdio. Any MCP-compatible client (Claude Code, Cursor, custom rmcp clients) can connect by spawning gbrain serve and exchanging JSON-RPC over stdin/stdout. See Connect Claude Code for a worked example.

  • Slugs may be collection-qualified (<collection>::<slug>). Bare slugs resolve to the default collection or fail with Ambiguity if multiple collections expose the same slug.
  • All timestamps are ISO-8601 strings. valid_from / valid_until may be null to indicate open-start or open-end intervals.
  • Error responses use extended JSON-RPC codes documented in Errors.
  • The MCP server enforces collection write-gates: a restoring or needs_full_sync collection rejects mutations with CollectionRestoringError before any other validation runs.
ToolPurposeMutates
brain_getRead a page
brain_putCreate or update a page (OCC)
brain_queryHybrid semantic + FTS5 query
brain_searchFTS5 keyword search
brain_listList pages with filters
brain_linkCreate a temporal link
brain_link_closeClose a temporal link interval
brain_backlinksList inbound links
brain_graphN-hop graph neighbourhood
brain_checkContradiction detection
brain_timelineTimeline entries for a page
brain_tagsList, add, or remove tags
brain_gapLog a knowledge gap (privacy-safe)
brain_gapsList knowledge gaps
brain_statsBrain statistics
brain_collectionsList collection status
brain_rawStore raw structured data

Get a page by slug.

ParamTypeRequiredNotes
slugstringyesBare or collection-qualified

Returns the rendered markdown of the page (compiled truth + timeline).

{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{
"name":"brain_get","arguments":{"slug":"people/alice"}
}}

Errors: NotFound, Ambiguity.

FTS5 full-text search.

ParamTypeRequiredDefault
querystringyes
collectionstringno
wingstringno
limitu32no10

Returns a JSON array of {slug, title, snippet, score}.

Hybrid semantic + FTS5 query.

ParamTypeRequiredDefault
querystringyes
collectionstringno
wingstringno
limitu32no10
depthstringno– (set to "auto" for progressive expansion)

Returns a ranked, fused result list with optional progressive context up to the active token budget.

List pages with optional filters.

ParamTypeRequiredDefault
collectionstringno
wingstringno
page_typestringno
limitu32no50

Write or update a page.

ParamTypeRequiredNotes
slugstringyes
contentstringyesFull page markdown (frontmatter + body)
expected_versioni64no (required for safe updates)OCC: must match current version

Errors: Conflict on OCC violation; CollectionReadOnlyError if the target collection is not writable; CollectionRestoringError while a collection is mid-restore.

{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{
"name":"brain_put",
"arguments":{
"slug":"people/alice",
"content":"---\ntitle: Alice\ntype: person\n---\n# Alice\n\n",
"expected_version": 7
}
}}

Store raw structured data (API responses, JSON) for a page.

ParamTypeRequiredDefault
slugstringyes
sourcestringyesE.g. "crustdata", "exa", "meeting"
dataobjectyesMust be a JSON object (not array/scalar)
overwritebooleannofalse

Per (slug, source) only one row is kept active; older rows roll over per the configured retention.

Create a typed temporal link between two pages.

ParamTypeRequired
from_slugstringyes
to_slugstringyes
relationshipstringyes
valid_fromISO-8601no
valid_untilISO-8601no

Close a temporal link by its database ID.

ParamTypeRequired
link_idu64yes
valid_untilISO-8601yes

List inbound backlinks for a page.

ParamTypeRequiredDefault
slugstringyes
limitu32no
temporalstringno"current" (alt: "all")

N-hop neighbourhood graph from a page.

ParamTypeRequiredDefault
slugstringyes
depthu32no2
temporalstringno"current"

Run contradiction detection on a page or all pages.

ParamTypeRequired
slugstringno (omit to scan globally)

Show timeline entries for a page.

ParamTypeRequiredDefault
slugstringyes
limitu32no20

List, add, or remove tags on a page.

ParamTypeRequired
slugstringyes
addstring[]no
removestring[]no

Log a knowledge gap (privacy-safe: stores query_hash, not raw query).

ParamTypeRequired
querystringyes
slugstringno
contextstringno

The raw query is not persisted unless explicitly approved via the knowledge_gaps approval workflow. See Sensitivity contract.

List knowledge gaps.

ParamTypeRequiredDefault
resolvedbooleannofalse
limitu32no20 (max 1000)

Brain statistics.

No parameters. Returns counts (pages, links, embeddings, gaps), the active embedding model, and schema version.

List collection status for MCP clients.

No parameters. Returns one entry per attached collection with state, ignore-pattern diagnostics, and recovery flags.

Every tool call uses the standard MCP tools/call shape:

{
"jsonrpc": "2.0",
"id": <request_id>,
"method": "tools/call",
"params": {
"name": "<tool_name>",
"arguments": { ... }
}
}

Successful responses contain a result.content array. Errors return an error.code per Errors.