MCP server

MCP tools reference

Complete reference for all seven Spectron MCP tools.

Spectron exposes seven tools over the Model Context Protocol at /mcp. 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.

Tool responses correlate with graph-resident traces via traceId or trace.traceId (depending on the underlying endpoint). Use GET .../traces/{traceId} for the full record.

Store a conversational exchange. Spectron auto-classifies the content, reconciles new facts against existing memory, and persists structured records to the experiential graph.

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

FieldTypeRequiredDescription
role"user" \| "assistant"YesWho produced the content
contentstringYesThe message text to extract memory from
session_idstringNoExisting session to append to. A new session is created if omitted.
scopestring[]NoSlash paths (for example ["org/acme/user/alice"]).
FieldTypeDescription
turn_idstringID of the turn record created
session_idstringSession the turn was appended to
entitiesarrayEntities extracted from the content
attributesarrayAttributes extracted and persisted
relationsarrayRelations between entities
instructionsarrayImperative instructions extracted (e.g. "always respond in bullet points")
uncertaintiesarrayUncertain or unverifiable claims flagged during extraction
correctionsarrayValues that supersede previously stored attributes
traceIdstringTrace record ID

An LLM invokes this tool at the end of a conversation turn:

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

Output: {
"turn_id": "turn:01jt4kx...",
"session_id": "session:01jt4ky...",
"entities": [
{ "id": "Person/alice", "label": "Alice" }
],
"attributes": [
{ "entity": "Person/alice", "key": "role", "value": "VP of Engineering", "category": "identity" },
{ "entity": "Person/alice", "key": "city", "value": "Singapore", "category": "identity", "valid_from": "2026-06-01" }
],
"relations": [],
"instructions": [],
"corrections": [],
"traceId": "trace:01jt4m..."
}

Retrieve relevant context for a query from experiential memory and authoritative knowledge in one call. Returns a pre-formatted context string designed for direct injection into an LLM system prompt.

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

FieldTypeRequiredDescription
querystringYesNatural-language query describing what context to retrieve
kintegerNoMaximum number of memory hits to include (default: 10)
scopestring[]NoSlash paths to filter the query.
FieldTypeDescription
contextstringFormatted context block for system prompt injection
tierstringResolution tier used: "direct", "cache", "hybrid", or "full_context"
queryMsintegerTime taken to resolve the query in milliseconds
traceIdstringTrace record ID
Tool: memory_recall
Input: {
"query": "What do I know about Alice's current situation?",
"scope": ["org/acme/user/alice"]
}

Output: {
"context": "### Alice\n- Role: VP of Engineering (updated 2026-05-12)\n- City: Singapore (from 2026-06-01)\n- Organisation: Acme Corp\n- Preference: Concise answers, no filler phrases",
"tier": "direct",
"queryMs": 3,
"traceId": "trace:01jt4n..."
}

The context string can be placed directly in a system prompt:

You are a helpful assistant.

## Memory
### Alice
- Role: VP of Engineering (updated 2026-05-12)
...

Synthesise patterns and insights from existing memories. Useful for periodic summarisation, generating user briefs, or deriving higher-order facts from accumulated context.

Pass persist: true to write the derived attributes back to experiential memory as durable facts.

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

FieldTypeRequiredDescription
promptstringYesA directive describing what patterns or insights to look for (e.g. "What are the recurring themes in this user's goals?")
scopestring[]NoSlash paths to reflect over
persistbooleanNoIf true, saves derived attributes to experiential memory (default: false)
kintegerNoNumber of memory records to consider during reflection (default: 20)
FieldTypeDescription
reflectionstringSynthesised insights in natural language
evidencearrayMemory records used as evidence for the reflection
persisted_attributesarrayAttributes written to experiential memory if persist was true
traceIdstringTrace record ID
Tool: memory_reflect
Input: {
"prompt": "What career themes emerge from this user's history?",
"scope": ["org/acme/user/alice"],
"persist": true
}

Output: {
"reflection": "Alice consistently moves toward technical leadership roles and has a pattern of relocating for career advancement. Recent trajectory: engineer → CTO → VP of Engineering with international moves.",
"evidence": [...],
"persisted_attributes": [
{ "entity": "Person/alice", "key": "career_theme", "value": "technical leadership progression" }
],
"traceId": "trace:01jt4p..."
}

Return the aggregated profile for the current principal. The profile groups identity facts, dynamic context, preferences, and active instructions into a single object suitable for direct system prompt injection.

REST equivalent: GET /api/v1/{context_id}/profile

FieldTypeRequiredDescription
scopestring[]NoSlash paths identifying the principal.
FieldTypeDescription
identityobjectStatic identity facts (name, role, organisation, etc.)
dynamicobjectRecently updated contextual facts (current project, mood, focus area)
preferencesobjectStated preferences (language, response style, format)
instructionsarrayActive imperative instructions to apply during the session
traceIdstringTrace record ID
Tool: memory_profile
Input: {
"scope": ["org/acme/user/alice"]
}

Output: {
"identity": {
"name": "Alice",
"role": "VP of Engineering",
"organisation": "Acme Corp",
"city": "Singapore"
},
"dynamic": {
"current_project": "Platform v3",
"focus": "Hiring for the Singapore office"
},
"preferences": {
"response_style": "concise",
"language": "British English"
},
"instructions": [
"Always respond in bullet points when listing more than three items",
"Do not include filler phrases such as 'Great question!'"
],
"traceId": "trace:01jt4q..."
}

Search the authoritative knowledge base only (documents, structured records, connector-synced content). Does not include conversational memory. Returns ranked results with chunk text, score, and source metadata.

REST equivalent: POST /api/v1/{context_id}/query (or POST .../documents/query for authoritative passages only)

FieldTypeRequiredDescription
querystringYesNatural-language search query
modestringNoRetrieval mode: "vector", "bm25", "hybrid" (default), or "hybrid_graph"
kintegerNoNumber of results to return (default: 10)
thresholdnumberNoMinimum relevance score (0–1); results below this are excluded
scopestring[]NoSlash paths to filter results
ModeDescription
vectorDense semantic search using HNSW index. Best for conceptual similarity.
bm25Sparse keyword search. Best for exact terminology, product names, and codes.
hybridCombines vector and BM25 with Reciprocal Rank Fusion. Recommended default.
hybrid_graphHybrid retrieval extended with graph density re-ranking. Best for multi-hop relational queries.
FieldTypeDescription
resultsarrayRanked result objects
results[].chunk_textstringThe text of the matched chunk
results[].scorenumberRelevance score (0–1)
results[].document_titlestringTitle of the source document
results[].document_idstringID of the source document
results[].chunk_idstringID of the specific chunk
results[].metadataobjectAdditional metadata attached during ingestion
traceIdstringTrace record ID
Tool: knowledge_search
Input: {
"query": "what is the refund policy for subscription plans?",
"mode": "hybrid",
"k": 5,
"scope": ["org/acme"]
}

Output: {
"results": [
{
"chunk_text": "Subscription plans may be cancelled at any time. Refunds are issued on a pro-rata basis for the unused portion of the current billing period, provided the cancellation request is submitted within 14 days of the renewal date.",
"score": 0.94,
"document_title": "Acme Billing Policies v3",
"document_id": "document:01jt4r...",
"chunk_id": "chunk:01jt4s...",
"metadata": { "version": "3.0", "last_reviewed": "2026-03-01" }
}
],
"traceId": "trace:01jt4t..."
}

Fetch a specific document, chunk, or knowledge node by its ID. Returns the full record without re-ranking or scoring. Use this when you already know which resource you need.

REST equivalent: GET /api/v1/{context_id}/documents/{id}

FieldTypeRequiredDescription
idstringYesThe ID of the document, chunk, or knowledge node to retrieve

The returned object shape depends on the record type:

Document:

FieldTypeDescription
idstringDocument ID
titlestringDocument title
content_typestringMIME type
metadataobjectMetadata attached during ingestion
created_atstringISO 8601 datetime

Chunk:

FieldTypeDescription
idstringChunk ID
document_idstringParent document ID
textstringChunk text
positionintegerPosition within the document
Tool: knowledge_get
Input: { "id": "chunk:01jt4s..." }

Output: {
"id": "chunk:01jt4s...",
"document_id": "document:01jt4r...",
"text": "Subscription plans may be cancelled at any time...",
"position": 4
}

Upload a document to the knowledge layer. Accepts base64-encoded bytes (MCP-friendly); the backend chunks, embeds, and indexes asynchronously.

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

FieldTypeRequiredDescription
context_idstringYesSpectron context id
bytes_base64stringYesDocument bytes, RFC 4648 base64
titlestringNoDisplay title
sourcestringNoProvenance tag
mime_typestringNoDeclared MIME type
filenamestringNoOriginal filename
scopestring[]NoDNF scope selector — slash paths narrower than the caller's memory:write region. Use nested arrays for AND clauses; a flat multi-element array is OR. Prefer scopes on new integrations.
labelsstring[]Nokey=value tags stamped on document-owned rows
observedAtstringNoOptional RFC 3339 known time for facts derived from this upload
FieldTypeDescription
idstringDocument id
statusstringPipeline status (queued, extracting, …)
content_hashstringBLAKE3 content hash
deduplicatedbooleantrue when bytes matched an existing document
versionintegerDocument version (incremented on reprocess)
Tool: upload
Input: {
"context_id": "acme-prod",
"bytes_base64": "aGVsbG8=",
"title": "Team handbook",
"scope": ["org/acme/team/eng"],
"labels": ["team=eng"]
}

Output: {
"id": "doc:01jt4u…",
"status": "queued",
"content_hash": "blake3:…",
"deduplicated": false,
"version": 1
}

Semantically soft-delete memories matching a natural-language description. Spectron identifies relevant entities and attributes, marks them as deleted, and returns the count of records removed.

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

FieldTypeRequiredDescription
descriptionstringYesNatural-language description of what to forget (e.g. "anything about Alice's previous employer")
scopestring[]NoSlash paths to restrict the deletion to
FieldTypeDescription
deleted_countintegerNumber of records soft-deleted
traceIdstringTrace record ID
Tool: memory_forget
Input: {
"description": "Alice's previous job title and employer",
"scope": ["org/acme/user/alice"]
}

Output: {
"deleted_count": 3,
"traceId": "trace:01jt4u..."
}

Soft-deleted records are excluded from all future retrieval but retained in the database for audit purposes. They can be permanently purged via the management API.

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?