Skip to content

MCP server

MCP tools reference

SurrealDB Agent Memory exposes seven tools over the Model Context Protocol at /mcp: remember, recall, context, reflect, forget, upload, and inspect. All tools use the same Authorization: Bearer authentication as the REST API. Point the MCP URL at https://<your-context-host>/mcp on SurrealDB Cloud.

Note

Older docs used names such as memory_store, memory_recall, and knowledge_search. Those prefixes are retired - use the short names above.

Note

MCP tool arguments and outputs use snake_case (session_id, query_ms, trace_id), unlike the REST API, which uses camelCase. The one exception is the optional occurredAt field on a recall hit, which keeps the REST hit shape. Scope arguments are slash paths (for example org/acme/user/alice). Register paths with agent-memory scopes create before use.

Tool responses correlate with graph-resident traces via trace_id. Use GET .../traces/{traceId} for the full record, or MCP inspect with ref: "trace:<id>".

Every tool accepts an optional context_id. When omitted, the server uses the Context bound to the bearer API key. An explicit context_id that does not match that binding returns 401.

Store a conversational exchange or free-text fact. SurrealDB Agent Memory auto-classifies content, reconciles against existing memory, and persists structured records.

REST equivalent: POST /api/v1/{context_id}/facts

FieldTypeRequiredDescription
textstringYes, except with infer: "triples"Content to remember
session_idstringNoExisting session to append to
scopestring[] or nested arraysNoDNF write selector within memory:write
labelsstring[]NoDescriptive key=value labels
infer"full" \| "triples" \| "preview" \| "none"NoDefault full. triples stores the caller-supplied triples without an LLM
triplesobject[]With infer: "triples"Structured entries: each has an entity (type, name) and a key with a value (attribute), a target (relation) or a verb (dated action)
observed_atstringNoRFC 3339 known time for the written facts, for backfill. Only valid with infer set to full or triples
context_idstringNoOmit to use the bearer key's Context

mode, session_id, turn_id, chunk_id, preview, and an extraction object with the structured diff (entities, attributes, relations, actions, instructions, uncertainties, corrections), plus a stand-in trace_id that holds the turn id.

Tool: remember
Input: {
  "text": "I just got promoted to VP of Engineering and I'm moving to Singapore next month.",
  "scope": ["org/acme/user/alice"]
}

Unified search over experiential facts and document passages. Returns ranked hits (not a synthesised answer).

REST equivalent: POST /api/v1/{context_id}/query

FieldTypeRequiredDescription
querystringYesNatural-language question
kintegerNoHit count (default 10, max 50)
modestringNovector \| bm25 \| graph \| hybrid
lensstring[] or nested arraysNoDNF read lens
scope_viewstringNostrict (default) \| merged \| crossTeam. merged and crossTeam are accepted but behave as strict
labelsstring[]NoOptional filters
context_idstringNoOmit to use the bearer key's Context

tier, hits (each with id, text, source, score, and occurredAt or resource when present), query_ms, trace_id, and context_hits when the router gathered extra rows for synthesis.

Tool: recall
Input: {
  "query": "What role does Alice have?",
  "k": 10,
  "lens": ["org/acme"]
}

Assemble a markdown context block for prompt injection (profile + relevant facts).

REST equivalent: POST /api/v1/{context_id}/context

FieldTypeRequiredDescription
querystringYesWhat context to assemble
kintegerNoHit count (default 10)
lensstring[] or nested arraysNoDNF read lens
scope_viewstringNostrict (default) \| merged \| crossTeam. merged and crossTeam are accepted but behave as strict
labelsstring[]NoOptional filters
context_idstringNoOmit to use the bearer key's Context

context (the markdown block), tier, query_ms, and trace_id.

Synthesise insights across memory. Optionally persist with persist: true.

REST equivalent: POST /api/v1/{context_id}/reflect

FieldTypeRequiredDescription
querystringYesSynthesis question
persistbooleanNoDefault false
context_idstringNoOmit to use the bearer key's Context

Soft-delete attributes that match a natural-language query. Use purge: true for permanent erasure including history.

REST equivalent: POST /api/v1/{context_id}/forget

FieldTypeRequiredDescription
querystringYesWhat to stop believing
purgebooleanNoAlso erase supersession history
context_idstringNoOmit to use the bearer key's Context

Upload a document (base64). Processing is asynchronous - poll with inspect or REST.

REST equivalent: POST /api/v1/{context_id}/documents

FieldTypeRequiredDescription
bytes_base64stringYesDocument bytes (RFC 4648)
titlestringNoDisplay title
sourcestringNoProvenance string
mime_typestringNoMIME type
filenamestringNoOriginal filename
scopesnested arraysNoDNF write selector (scope alias accepted)
labelsstring[]NoLabels on the document
context_idstringNoOmit to use the bearer key's Context
Tool: upload
Input: {
  "bytes_base64": "aGVsbG8=",
  "title": "Team handbook",
  "scopes": [["org/acme/team/eng"]],
  "labels": ["team=eng"]
}

Look up an entity, trace, or document by typed reference.

REST equivalents: GET .../entities/..., GET .../traces/{id}, GET .../documents/{id}

FieldTypeRequiredDescription
refstringYesentity:<Type>/<Name>, trace:<id>, or document:<id>
context_idstringNoOmit to use the bearer key's Context
Tool: inspect
Input: {
  "ref": "document:01hx9…"
}

Operation failures return isError: true tool results with structuredContent.error.status mirroring REST (404, 403, 429, 401, 500). JSON-RPC error is reserved for protocol faults (bad params, unknown tool). Auth and missing-Context failures are masked as 401. See MCP tools - error handling.

Was this page helpful?