Skip to content

MCP server

Memoturn ships an MCP server (TypeScript, in mcp/) so that any MCP-capable agent framework connects directly — agents ingest and recall memory as tools, with no SDK integration. The prototype server uses the stdio transport for local development; the v1 design also specifies a streamable-HTTP transport for production and a schema_inspect tool.

ToolPurposeScope
memory_ingest {namespace, profile, memories}Store typed memories — idempotent batch; fact/instruction supersede older entries sharing topic_key; each memory’s source defaults from MEMOTURN_SOURCEns:write or the profile’s db token
memory_recall {namespace, profile, query?, embedding?, topic_key?, types?, source?, k?, include_superseded?, include_turns?}Hybrid recall: keyword + topic + vector channels, rank-fused; empty result means nothing relevant; source filters to one agent’s memoriesns:read or the profile’s db token
memory_extract {namespace, profile, turns, session_id?, source?, dry_run?}Distill raw turns into typed memories with the node’s server-side extractor, then ingest; errors with 503 when the node has no extractor (see Server-side extraction)ns:write
memory_forget {namespace, profile, id}Permanently delete one memory (hard delete; supersession preserves history without it)ns:write
memory_erase {namespace, profile, memory_id? | topic_key?+type? | session_id?+turns?}Verifiable erasure: hard delete now, history rewrite + signed receipt after the grace windowns:write
memory_erasure_status {namespace, profile, id?}List erasure coupons or fetch one (completed coupons carry the signed receipt)ns:read
memory_get {namespace, profile, id}Fetch one memory by id with its supersession state; reports not-found rather than erroringns:read or the profile’s db token
memory_profiles_list {namespace}List the profiles under a namespace — each is one isolated storenamespace token
ToolPurposeScope
memory_sessions_list {namespace, profile, limit?}List recent sessions, most recent firstns:read
memory_session_end {namespace, profile, session_id, drop_turns?}End a session: its task memories expire immediately, durable memories survive; drop_turns also deletes the verbatim transcriptns:write
ToolPurposeScope
memory_append {db, session, role, content, embedding?}Append a verbatim conversation turn to a sessiondb:write
memory_window {db, session, last?}Fetch the last N turns in orderdb:read
memory_search {db, session, vector, k?}Semantic search over a session’s embedded turnsdb:read
ToolPurposeScope
query {db, stmts}SQL statements as an atomic batch — the escape hatchdb:read / db:write
docs_insert / docs_find / docs_update {db, collection, ...}JSON documents with document-style filters and update operatorsdb:read / db:write
kv_put / kv_get {db, ns, key, value?, ttl?}Scratchpads, flags, caches; optional TTLdb:read / db:write
vector_upsert / vector_search {db, collection, ...}ANN-indexed embeddings outside the memory layerdb:read / db:write
ToolPurposeScope
provision_database {name}Create a database — instant, metadata-onlyplatform
list_databasesList databases on the nodeplatform
branch_create {db, name, from?, ttl?}Copy-on-write fork; ttl makes it a burner branchdb:admin
branch_checkpoint {db, branch, name}Tag the current state with a namedb:admin
branch_rewind {db, branch, to}Rewind to a checkpoint — destructive for state after itdb:admin
ToolPurposeScope
policy_get {namespace, profile?}The namespace governance policy, or a profile’s override + effective valuesplatform / ns:read
policy_set {namespace, profile?, policy}Set the namespace policy, or a tighten-only profile override (policy: null clears it)platform / ns:admin
audit_query {namespace, from?, to?, action?, profile?, outcome?, limit?, cursor?}Page through the namespace’s audit stream (metadata only — never memory content)platform / ns:admin

db accepts a spec of name or name@branch (@main implicit). Every tool result carries the txid of the operation. Destructive tools — branch_rewind, memory_forget, memory_erase, memory_session_end, provision_database, policy_set — are the ones an MCP host should gate behind confirmation.

The server forwards one of three credentials to the node, depending on who the agent is:

  • Per-database JWT — the agent posture, and the default. The agent is locked to exactly one profile or database; it cannot name any other.
  • Namespace token — the orchestrator posture. One token covers every profile under a namespace (for example, all of acme), including the control routes of those profiles’ databases — mint per-profile tokens, checkpoint memories. Tokens widen authorization only; no data-plane operation touches two profiles.
  • Platform token with scopes — control-plane operations such as provision_database and list_databases.

Scopes follow the API: recall and reads need read, ingest and forget need write, branch operations need admin. See Security for token minting.

Per turn: call memory_recall at turn start to load what the profile already knows, act, then call memory_ingest at turn end with anything worth keeping (and memory_append for the verbatim turn, so nothing is lost between extractions). When a session wraps, memory_session_end expires its task memories.

Per session, the orchestrator pattern from the architecture: provision a database per session, hand the agent its scoped JWT, let the agent store turns, memories, and scratch state via the tools above, fork a burner branch before risky operations, and let the database hibernate when the session ends. It resumes on the next session without explicit restore.

The server speaks stdio and targets a running node:

Terminal window
cd mcp && npm i && npm run build
node dist/index.js

Configuration is by environment variable:

VariablePurpose
MEMOTURN_URLNode or gateway base URL (default http://127.0.0.1:8080)
MEMOTURN_TOKENPer-database or namespace JWT for data-plane tools
MEMOTURN_PLATFORM_KEYPlatform credential for provision_database / list_databases
MEMOTURN_SOURCEDefault provenance for ingested memories (e.g. claude-code) — applied when a tool call doesn’t set source itself

A typical MCP client registration:

{
"mcpServers": {
"memoturn": {
"command": "node",
"args": ["/path/to/db/mcp/dist/index.js"],
"env": {
"MEMOTURN_URL": "http://127.0.0.1:8080",
"MEMOTURN_TOKEN": "<jwt>",
"MEMOTURN_SOURCE": "claude-code"
}
}
}
}

Register the same server in each coding tool with a different MEMOTURN_SOURCE — every agent then reads and writes the same profile while each memory carries the agent that wrote it, and memory_recall can filter by it.

The design also includes a built-in assistant — natural language to query, schema and index advice, query optimization, ops copilot — as a control-plane service surfaced in the CLI (memoturn ask) and as an MCP tool. It receives schema, statistics, and query plans, never row data by default. It ships post-prototype; memoturn ask is currently a stub. See the roadmap.

  • Memories — the typed record behind memory_ingest.
  • Recall — channel fusion behind memory_recall.
  • Branching — semantics of branch_create, checkpoint, and rewind.
  • API reference — the HTTP routes each tool wraps.