Skip to Content

MCP Tools Reference

RelataDB exposes its full surface as Model Context Protocol  tools at the /mcp endpoint. The same surface is mirrored by the Python SDK’s McpClient and any MCP-compatible agent runtime (Claude Desktop, LangChain, OpenAI Agents SDK, …).

Endpoint: POST /mcp/tools/call · Discovery: GET /mcp/tools

The authoritative live list and JSON schemas are always available at GET /mcp/tools — this page mirrors what’s documented in docs/src/mcp-tools.md.

Access control (applies to every tool)

  • Auth: every call authenticated (Bearer token).
  • Parameter validation: ADR-057 enforced.
  • Purpose check: every call requires a registered purpose.
  • Egress filtering: classified types (SourceTrueIdentity, SigintIntercept, AccessScopedIntercept, LawfulInterceptRecord) are blocked at egress regardless of query success.
  • Audit: every invocation recorded in the append-only audit log with principal, timestamp, purpose, cost units, and a tamper-evident hash chain.
  • Quota: tools charge cost units (most query tools 1, multi-table tools 3–5). Default 10,000 units/principal; configurable via RELATA_QUERY_QUOTA. Quota exhaustion returns HTTP 429.

Query

ToolDescriptionCost
queryExecute SQL with a mandatory purpose. Returns rows + column metadata. Result rows capped at 10,000; "truncated": true indicates more exist.1
query_knowledgeSame as query with automatic purpose injection — the purpose token is supplied out-of-band, not in the SQL.1
explain_policyReturn the ACL decision tree and cell-mask plan for the requesting principal.1
suggest_extensionsSuggest the next related queries given a prefix — helps an agent’s reasoning loop.1

Entity & Identity

ToolDescription
lookup_identityUniversal IdentityIndex lookup by value (phone, email, IMEI, IP, BTC address…).
list_entity_typesList every governed object type in the ontology.
get_entitiesPaginated list of entities of a given type.
search_entitiesHybrid (BM25 + vector) entity search.
get_domain_summaryPer-domain roll-up counts.

Document Ingest & RAG

ToolDescription
ingest_documentIngest a document with auto-embedding + provenance.
rag_store_answerStore a RAG-grounded answer (question, answer, citations).
rag_store_elementsStore structured RAG elements (chunks, tables, figures).
ToolDescription
search_knowledgeHybrid BM25 + vector knowledge search across the store.
get_relationshipsList the relationships (edges) attached to an entity.
paths_betweenGoverned PATHS_BETWEEN('<a>', '<b>', max_hops => N) walk with full ACL.
list_link_typesList every governed edge (link) type defined in the ontology.

Entity Intelligence

ToolDescriptionCost
get_entity_profile360° profile of an entity: identity, related entities, cases, alerts.5
get_timelineTemporal activity timeline for an entity (events, transactions, comms).3
find_connectionsFind indirect connections between two entities through the graph.5

Notes & Audit

ToolDescription
add_case_noteAppend an analyst note to a case.
get_audit_trailPaginated, filtered audit trail (principal, time range, purpose).
get_case_summarySummary of a case: entities, alerts, notes, timeline.

Agent Memory (the cognitive verbs)

The 10 cognitive verbs ship as MCP tools and HTTP endpoints. Each requires a purpose token (recorded for audit).

VerbDescription
rememberStore a governed memory item (bi-temporal + provenance).
recallHybrid BM25 + vector retrieval (optionally AS OF).
recognizeIs this identity already known? Returns a MemoryItem projection.
justifyProvenance chain + audit trail for a memory item.
consolidateSupersede an old belief — closes the superseded row’s valid_to and inserts the new belief.
forgetSchedule retention / legal-hold retract (not a hard delete).
associateAssociate two memory items.
resolveResolve a memory item by policy (latest_wins, …).
summariseSummarise a session / topic.
episodes_inReturn full Episode detail for a session.

Example lifecycle (MCP):

// 1. remember — store a governed memory item { "method": "tools/call", "params": { "name": "remember", "arguments": { "content": "Customer Alice plans to renew in Q3.", "session_id": "agent-session-42", "confidence": 0.9, "purpose": "account_management" } } } // 2. recall — hybrid BM25+vector retrieval { "method": "tools/call", "params": { "name": "recall", "arguments": { "query": "What do we know about Alice's renewal?", "session_id": "agent-session-42", "top_k": 5, "as_of": "2026-06-01T00:00:00Z", "purpose": "account_management" } } } // 3. forget — schedule retention { "method": "tools/call", "params": { "name": "forget", "arguments": { "id": "<MemoryItem-uuid>", "retain_days": 90, "purpose": "data_retention" } } }

The same verbs over HTTP:

curl -X POST http://localhost:9090/memory/remember \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $RELATA_BEARER_TOKEN" \ -d '{"content":"Alice plans to renew in Q3.","purpose":"account_management"}' curl -X POST http://localhost:9090/memory/recall \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $RELATA_BEARER_TOKEN" \ -d '{"query":"Alice renewal","top_k":5,"purpose":"account_management"}'

Governance, Media & Ops (#949)

ToolDescription
erase_subjectGDPR Art. 17 erasure — crypto-shred every row, vector, and blob linked to a subject; return a signed certified receipt (ADR-188).
ingest_mediaIngest image / audio / video (base64) or text payload for embedding + perceptual-hash near-duplicate dedup (#816). Returns a task id — embedding runs on the async media worker.
similar_multimodalGoverned cross-modal similarity search (ADR-106). Routes through the SIMILAR TO … LIMIT k planner path — ACL and cell masking apply.
server_healthReadiness snapshot: ready flag + reason, profile, queue depth, WAL failures, audit drops. Mirrors /health/ready.
job_statusContinuous detection jobs with status, interval, last-run, run count, and total alerts. Mirrors GET /jobs.
metricsOperational counters (ingested rows, query count, uptime, audit-chain validity, queue depth/capacity, WAL failures, background-task panics). Mirrors GET /metrics.json.
list_rulesList detection rules (mirrors GET /rules).
create_ruleCreate a rule from name + condition_sql (mirrors POST /rules).
import_sigmaImport a Sigma rule (yaml) — logsource + detection converted to a governed Relata rule (mirrors POST /rules/sigma).

Purpose enforcement

Strict mode (default) — only registered purposes are allowed:

RELATA_PURPOSE_MODE=strict RELATA_PURPOSES=analytics,audit,compliance,product_research

Open mode (dev/test only) — any non-empty purpose string is accepted:

RELATA_PURPOSE_MODE=open

Hierarchical scoping with : separator is supported (analytics:external).

Egress filtering

These classified types never appear in tool results even if queries touch them internally (ADR-057):

TypeWhat it represents
SourceTrueIdentityHUMINT protected true identity (SPECS §5.19)
SigintInterceptSignal intelligence intercept records
AccessScopedInterceptRestricted access-scoped data (SPECS §5.20)
LawfulInterceptRecordLawful intercept records

Error handling

MCP error envelope:

{ "content": [{ "type": "text", "text": "error message" }], "isError": true }
HTTPCause
200Tool succeeded
400Missing / invalid parameters
401Bearer token missing or invalid
403ACL denied, purpose denied, egress blocked, protected types ingest
404Unknown tool
429Quota exhausted or ingest queue full
500Store unavailable or execution error

Deferred

watch / subscribe are not exposed over MCP — the SubscriptionManager + /watch/stream SSE surface is a long-lived event stream; the MCP tools/call request→response envelope cannot carry an open stream. Watch needs a streaming transport (MCP resources / notifications) rather than a synchronous dispatch arm.

SDK access (Python)

from relata import RelataClient, McpClient with RelataClient(url, bearer_token=token, purpose="analytics") as client: mcp = McpClient.from_client(client) # inherits auth + purpose profile = mcp.get_entity_profile("person-42", purpose="analytics") tools = mcp.list_tools() # discovery custom = mcp.call_tool("my_tool", {"arg": 1}) # generic dispatch

Vector search via MCP

{ "name": "query", "arguments": { "sql": "PURPOSE 'product_research' SELECT id, title FROM Document WHERE SIMILAR(embedding, ARRAY[0.12, -0.34, 0.91, ...], threshold=0.75) LIMIT 10", "purpose": "product_research" } }

Pass the embedding as a SQL ARRAY[...] literal, or bind via the Postgres wire protocol as a parameter (:query_embedding).

Last updated on