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
| Tool | Description | Cost |
|---|---|---|
query | Execute SQL with a mandatory purpose. Returns rows + column metadata. Result rows capped at 10,000; "truncated": true indicates more exist. | 1 |
query_knowledge | Same as query with automatic purpose injection — the purpose token is supplied out-of-band, not in the SQL. | 1 |
explain_policy | Return the ACL decision tree and cell-mask plan for the requesting principal. | 1 |
suggest_extensions | Suggest the next related queries given a prefix — helps an agent’s reasoning loop. | 1 |
Entity & Identity
| Tool | Description |
|---|---|
lookup_identity | Universal IdentityIndex lookup by value (phone, email, IMEI, IP, BTC address…). |
list_entity_types | List every governed object type in the ontology. |
get_entities | Paginated list of entities of a given type. |
search_entities | Hybrid (BM25 + vector) entity search. |
get_domain_summary | Per-domain roll-up counts. |
Document Ingest & RAG
| Tool | Description |
|---|---|
ingest_document | Ingest a document with auto-embedding + provenance. |
rag_store_answer | Store a RAG-grounded answer (question, answer, citations). |
rag_store_elements | Store structured RAG elements (chunks, tables, figures). |
Knowledge Graph & Search
| Tool | Description |
|---|---|
search_knowledge | Hybrid BM25 + vector knowledge search across the store. |
get_relationships | List the relationships (edges) attached to an entity. |
paths_between | Governed PATHS_BETWEEN('<a>', '<b>', max_hops => N) walk with full ACL. |
list_link_types | List every governed edge (link) type defined in the ontology. |
Entity Intelligence
| Tool | Description | Cost |
|---|---|---|
get_entity_profile | 360° profile of an entity: identity, related entities, cases, alerts. | 5 |
get_timeline | Temporal activity timeline for an entity (events, transactions, comms). | 3 |
find_connections | Find indirect connections between two entities through the graph. | 5 |
Notes & Audit
| Tool | Description |
|---|---|
add_case_note | Append an analyst note to a case. |
get_audit_trail | Paginated, filtered audit trail (principal, time range, purpose). |
get_case_summary | Summary 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).
| Verb | Description |
|---|---|
remember | Store a governed memory item (bi-temporal + provenance). |
recall | Hybrid BM25 + vector retrieval (optionally AS OF). |
recognize | Is this identity already known? Returns a MemoryItem projection. |
justify | Provenance chain + audit trail for a memory item. |
consolidate | Supersede an old belief — closes the superseded row’s valid_to and inserts the new belief. |
forget | Schedule retention / legal-hold retract (not a hard delete). |
associate | Associate two memory items. |
resolve | Resolve a memory item by policy (latest_wins, …). |
summarise | Summarise a session / topic. |
episodes_in | Return 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)
| Tool | Description |
|---|---|
erase_subject | GDPR Art. 17 erasure — crypto-shred every row, vector, and blob linked to a subject; return a signed certified receipt (ADR-188). |
ingest_media | Ingest 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_multimodal | Governed cross-modal similarity search (ADR-106). Routes through the SIMILAR TO … LIMIT k planner path — ACL and cell masking apply. |
server_health | Readiness snapshot: ready flag + reason, profile, queue depth, WAL failures, audit drops. Mirrors /health/ready. |
job_status | Continuous detection jobs with status, interval, last-run, run count, and total alerts. Mirrors GET /jobs. |
metrics | Operational counters (ingested rows, query count, uptime, audit-chain validity, queue depth/capacity, WAL failures, background-task panics). Mirrors GET /metrics.json. |
list_rules | List detection rules (mirrors GET /rules). |
create_rule | Create a rule from name + condition_sql (mirrors POST /rules). |
import_sigma | Import 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_researchOpen mode (dev/test only) — any non-empty purpose string is accepted:
RELATA_PURPOSE_MODE=openHierarchical 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):
| Type | What it represents |
|---|---|
SourceTrueIdentity | HUMINT protected true identity (SPECS §5.19) |
SigintIntercept | Signal intelligence intercept records |
AccessScopedIntercept | Restricted access-scoped data (SPECS §5.20) |
LawfulInterceptRecord | Lawful intercept records |
Error handling
MCP error envelope:
{
"content": [{ "type": "text", "text": "error message" }],
"isError": true
}| HTTP | Cause |
|---|---|
| 200 | Tool succeeded |
| 400 | Missing / invalid parameters |
| 401 | Bearer token missing or invalid |
| 403 | ACL denied, purpose denied, egress blocked, protected types ingest |
| 404 | Unknown tool |
| 429 | Quota exhausted or ingest queue full |
| 500 | Store 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 dispatchVector 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).