CortexDB

CortexDB gives AI agents long-term memory so they can store and retrieve context across conversations and workflows.

Documentation

SDKs & Clients

The local CortexDB MCP package for Claude, Cursor, Windsurf, VS Code Copilot and any MCP client that starts a local server; the CortexDB server itself also serves remote MCP over HTTP.

cortexdb-mcp is a small bridge process that exposes CortexDB to any Model Context Protocol client that starts a local server: Claude Desktop, Claude Code, Cursor, Windsurf, VS Code Copilot. It speaks MCP over stdio on the person's computer and calls your CortexDB server's REST API.

Remote MCP: the server serves /mcp itself

Installation

# pip (any Python 3.10+ venv)
pip install 'cortexdb-mcp>=0.11.0'

# pipx: recommended on macOS/Linux; auto-isolates the install
pipx install --python python3.11 'cortexdb-mcp>=0.11.0'

# uv: fastest; pulls its own Python if needed
uvx --python 3.11 cortexdb-mcp --help

The PyPI package is cortexdb-mcp. The current release is listed in Versioning and SDK compatibility; if you run an older one, see Upgrading.

Verify it's on your PATH:

cortexdb-mcp --version     # cortexdb-mcp 0.11.0
cortexdb-mcp --help

The binary takes two options. --transport accepts only stdio: this package runs next to the assistant (for an HTTP endpoint, use the server's own /mcp). --tool-profile all|read|write|code (or CORTEXDB_TOOL_PROFILE) selects the tool surface; see Tool profiles. Against a server that lacks a tool's route, that tool answers 404.

Windows: use the full.exe path

Setup

Every MCP client uses a JSON config file. The structure is the same everywhere, only the file path differs. There are three ways to set it up.

Option A: CortexDB Cloud

Create an API token on your dashboard, which also shows your actor and default scope, and give the server all four:

{
  "mcpServers": {
    "cortexdb": {
      "command": "cortexdb-mcp",
      "env": {
        "CORTEXDB_URL":     "https://api-v1.cortexdb.ai",
        "CORTEXDB_API_KEY": "<your API token>",
        "CORTEXDB_ACTOR":   "user:acct_42",
        "CORTEXDB_SCOPE":   "org:acct_42/user:acct_42"
      }
    }
  }
}

The token lasts 90 days; replace it with a new one from the dashboard. Every tool call counts against your plan. With no CORTEXDB_API_KEY the server tries an anonymous POST /v1/auth/signup against CORTEXDB_URL instead; CortexDB Cloud has signup off (its accounts come from cortexdb.ai), and a self-hosted server only allows it with its dev minter on, so set the key.

Option B: Bring your own token (your own IdP)

Set these env vars so the server skips signup and uses the credentials you supply:

  • CORTEXDB_API_KEY: The bearer credential: a person's or an agent's token minted via POST /v1/auth/tokens, or a token from your identity provider through the server's issuers file.
  • CORTEXDB_ACTOR: Sent as X-Cortex-Actor. Optional: left unset, it is the token's sub when that names an actor (user:, agent:, service:, system:). Set CORTEXDB_ACTOR=- for an identity provider's token whose issuer maps the subject itself; the server takes it alone.
  • CORTEXDB_SCOPE: The default scope path tools use when one isn't passed explicitly. Optional when signup supplied one; otherwise required (a tool call without a scope fails with no scope configured; it does not fall back to the actor).

Option C: Self-hosted server

Point CORTEXDB_URL at your server and supply the server's key as the bearer. CORTEXDB_SCOPE is required here (a self-hosted server normally has no signup to derive one from); a tool call without a scope fails with no scope configured.

{
  "mcpServers": {
    "cortexdb": {
      "command": "cortexdb-mcp",
      "env": {
        "CORTEXDB_URL":     "http://localhost:3141",
        "CORTEXDB_API_KEY": "<the server's CORTEX_API_KEY value>",
        "CORTEXDB_ACTOR":   "user:alice",
        "CORTEXDB_SCOPE":   "user:alice"
      }
    }
  }
}

On a server started with CORTEX_INSECURE_NO_AUTH=1, omit CORTEXDB_API_KEY (no Authorization header is sent; the server serves each request as the X-Cortex-Actor the MCP server sends from CORTEXDB_ACTOR, or user:local without one) but keep CORTEXDB_SCOPE. See Self-hosting defaults and the authorization note on presets.

The operator key under the deny mode

Local state

The server stores its credentials (and only its credentials) under:

  • macOS / Linux: $XDG_CONFIG_HOME/cortexdb-mcp/state.json (default ~/.config/cortexdb-mcp/state.json)
  • Windows: %APPDATA%\cortexdb-mcp\state.json

The file is mode 0600 on POSIX. Contents: { "token", "actor", "scope", "expires_at" }; the values POST /v1/auth/signup returned (user_id is stored as actor; expires_at when the mint reported one, used to sign up again on expiry). No memories are stored locally. It is only read when CORTEXDB_API_KEY is unset; an explicit env key always wins. Delete the file to force a re-signup on the next call.

This path and key set differ from the CLI's state file

Per-client configuration

The JSON blocks below show a token in the env block (Options A and B). For a self-hosted server use the Option C env block instead.

Claude Desktop

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "cortexdb": {
      "command": "cortexdb-mcp",
      "env": {
        "CORTEXDB_API_KEY": "v4.public.eyJpc3MiOi...",
        "CORTEXDB_ACTOR":   "user:acct_<id>",
        "CORTEXDB_SCOPE":   "org:acct_<id>/user:acct_<id>"
      }
    }
  }
}

Claude Code (CLI)

claude mcp add cortexdb \
  -e CORTEXDB_URL=https://api-v1.cortexdb.ai \
  -e CORTEXDB_API_KEY=v4.public... \
  -e CORTEXDB_ACTOR=user:acct_<id> \
  -e CORTEXDB_SCOPE=org:acct_<id>/user:acct_<id> \
  -- cortexdb-mcp

The server's name comes first: -e takes several values, so a name written after the -e flags is read as one more variable (and the command fails with missing required argument 'commandOrUrl'). Everything after -- is the server's own command line, so -- cortexdb-mcp --tool-profile write adds the write tools. Add --scope user to make the server available in every project, or --scope project to write it to a shareable .mcp.json in the repository root. Without --scope, Claude Code stores the entry in ~/.claude.json (local scope, this project only). To edit by hand, put the same mcpServers block into .mcp.json (project) or ~/.claude.json (user/local).

For the server's own remote MCP endpoint, Claude Code takes the URL and a header instead: claude mcp add --transport http cortexdb https://memory.acme.example/mcp --header "Authorization: Bearer <token>" (Connecting AI Assistants).

Cursor

Edit ~/.cursor/mcp.json:

{
  "mcpServers": {
    "cortexdb": {
      "command": "cortexdb-mcp",
      "env": {
        "CORTEXDB_URL":     "https://api-v1.cortexdb.ai",
        "CORTEXDB_API_KEY": "v4.public...",
        "CORTEXDB_ACTOR":   "user:acct_<id>",
        "CORTEXDB_SCOPE":   "org:acct_<id>/user:acct_<id>"
      }
    }
  }
}

Windsurf

Edit ~/.codeium/windsurf/mcp_config.json (same mcpServers block as Cursor).

VS Code (GitHub Copilot)

Add to .vscode/mcp.json (project) or ~/.vscode/mcp.json (global). Note the key is servers, not mcpServers:

{
  "servers": {
    "cortexdb": {
      "command": "cortexdb-mcp",
      "env": {
        "CORTEXDB_URL":     "https://api-v1.cortexdb.ai",
        "CORTEXDB_API_KEY": "v4.public...",
        "CORTEXDB_ACTOR":   "user:acct_<id>",
        "CORTEXDB_SCOPE":   "org:acct_<id>/user:acct_<id>"
      }
    }
  }
}

Tools exposed

The default profile, all, lists 38 tools; write lists 43, read 31 and code 4. The server also registers 3 resources (cortexdb://health, cortexdb://episodes, cortexdb://insights) and 5 prompts. A tool refuses an argument it does not take, and every tool carries MCP annotations (readOnlyHint, destructiveHint, idempotentHint), so a client can ask before a destructive call.

Matched spans and code citations

Every tool that takes a scope accepts it as tenant_id (a legacy name: it is a v1 scope path) and falls back to CORTEXDB_SCOPE.

Memory

MCP toolv1 endpointNotes
memory_storePOST /v1/experienceWraps free-form text in a conversation envelope with a fresh idempotency_key (or the one you pass); source / episode_type become source: / type: labels; namespace appends /ns:<name> to the scope; provenance names the events it was made from; consistency returns a token to read the write back with. ttl_seconds is accepted but ignored (the reply says so). Returns captured immediately, it does not wait for indexing, and names where a redirected write landed (redirected_to).
memory_statusGET /v1/experience/statusDid a store land? Check by event_id or idempotency_key (keys are kept 24 h) after a timeout.
memory_searchPOST /v1/recallSends view only when CORTEXDB_VIEW is set, so the server picks (holistic, or granular at a shared org-tree scope); diagnostics="none" so free-tier tokens succeed. Takes extra_scopes (up to 40), coverage, at_least, purpose and session. On a live voice call, pass profile="voice" and the call's session (see Voice calls). Shows the first max_results memories from the pack's context_block, falling back to derived facts.
get_contextPOST /v1/recallSame call, rendered as memories + facts + beliefs for "what should I know before I respond". include_graph only adds a hint line.
advanced_searchPOST /v1/recalltime_range_start / time_range_end become a temporal window; source / episode_type filter on labels; limit / offset page the results.
memory_listGET /v1/eventsScope-aware list of raw events, newest first; pages by cursor (each page ends with More: cursor=<next>); episode_type filters on the type: label.
memory_getGET /v1/events/{id}Single event by id; tenant_id is sent as ?scope=, the event's exact scope.

Deleting

MCP toolv1 endpointNotes
forget_previewPOST /v1/forget/previewDry run: per-layer estimated counts plus a fpvw_… preview id. Same selector rules as the delete tools.
memory_forgetPOST /v1/forgetquery → selector.about_subject; no query → whole-scope confirm_all=true. Pass from_preview_id from forget_preview for the two-phase flow. Always cascade: derived_only: it deletes derived records (facts, beliefs, episodes, understanding) and keeps the memories; use memory_delete or forget_by_key to delete memories.
memory_bulk_deletePOST /v1/forget (+ /v1/forget/preview when dry_run=true)Subject-targeted delete by query; dry_run previews instead.
memory_deletePOST /v1/forgetSelector preset for one memory_ids=[…].

Knowledge graph and beliefs

MCP toolv1 endpointNotes
entity_listGET /v1/factsDistinct fact subjects in the scope (synthetic subjects filtered out).
entity_getGET /v1/facts?subject=Facts filtered to one subject (predicate -> object lines).
entity_edgesGET /v1/facts?subject=Same query, rendered as subject --[predicate]--> object.
entity_linkPOST /v1/experienceRecords a "X relates to Y" sentence for the LLM extractor to turn into a fact.
belief_declarePOST /v1/beliefsWrites a belief record directly (statement, confidence, optional supports event/fact ids, subject, predicate). A newer belief on the same subject+predicate closes the previous one.
list_conflictsGET /v1/conflictsDetected contradictions for a scope (status=open default, or all).
resolve_conflictPOST /v1/conflicts/{id}/resolvepick (needs winner) / split (boundary, earlier, later) / new_information (record) / dismiss. Wrong or missing fields are rejected client-side with the expected list.
claim_historyGET /v1/claims/historyFull bi-temporal change-log of one subject+predicate claim, with any conflicts on it.

Access, rollups, notices and the directory

MCP toolProfilev1 endpointNotes
access_checkall, read, writePOST /v1/access/checkCan a principal read, write or own a scope or a memory? ALLOWED or DENIED with the link that decided. Your own token by default, or another principal for an Owner of the scope
access_explainall, read, writePOST /v1/access/explainWhy, link by link
rollupsall, read, writeGET /v1/rollupsA team's rollups: typed totals and synthesis items
noticesall, read, writeGET /v1/access/notices?mine=trueYour own unacknowledged notices: who read what of yours, when and why
acknowledge_noticesall, read, writePOST /v1/access/notices/ackAcknowledges them; changes no memory
directory_lookupall, read, writeGET /v1/directoryPeople and named scopes by name or email prefix, with only the fields you may read
publishwritePOST /v1/publishA person copies a memory they are served into a wider scope they write
forget_by_keywritePOST /v1/forgetForgets memories by their idempotency keys or capture labels, reading nothing first, with a preview

Governed memory

Seven tools cover governed memory: why a memory is held, what CortexDB may learn, and fixing what it learned wrongly. The four read tools are in every profile but code. The three write tools are opt-in (--tool-profile write) and annotated destructive, so a client asks before it calls them.

MCP toolProfilev1 endpointNotes
memory_whyall, read, writeGET /v1/facts/{id}?include=derivation, GET /v1/beliefs/why?include=derivation, GET /v1/derivation/decisionsWhy a fact or belief is held and how it was made, or what CortexDB learned from one memory (fact_…, belief_… or evt_…). A rejected candidate is only counted, by the rule that rejected it
derivation_policyall, read, writeGET /v1/derivation/policyWhat CortexDB learns at a scope and what it will not, and who set each rule; include_texts adds the instructions and examples, for an Owner
memory_aboutall, read, writeGET /v1/memory/aboutWhat is known about a subject: each fact and belief with its id and sources; include_corrections adds the scope's corrections
review_listall, read, writeGET /v1/reviewThe candidates a policy held for review: what each states, the rule that held it, when it lapses
memory_correctwritePOST /v1/correctionsaction reject, replace (with value and valid_from), pin or confirm on a fact_id; bind widens a reject. The way to fix a wrong memory: a forget of derived memory can be learned again
correction_undowriteDELETE /v1/corrections/{id}Undoes a correction, for its author, an Owner of its scope or the operator
review_decidewritePOST /v1/review/decisionsapprove or reject up to 100 held_ids; a rejection leaves a correction that keeps the claim from being learned

memory_search, get_context and advanced_search also take session, the conversation session a read is made in: where an opt-in read-time use rule is in force, memory from other sessions is withheld. All three send it to /v1/recall, which on a server without the capability answers 422 INVALID_BODY, so pass session only to a server whose GET /v1/admin/version lists derivation_use_rules_v1. Of these seven, all but memory_why take the scope as scope, not tenant_id, unlike the other tools. An agent that fixes a memory and then undoes the fix sends these two calls (each object is a tools/call request's params):

[
  {"name": "memory_correct", "arguments": {"action": "replace", "fact_id": "fact_0196…", "value": "Denver", "valid_from": "2026-03-01"}},
  {"name": "correction_undo", "arguments": {"correction_id": "cor_0196…"}}
]

Check the capability first

The server's own /mcp endpoint has memory_why and memory_about in its read profile and correct in its write profile (CORTEX_MCP_PROFILE=write), and its recall tool takes session; send session only where GET /v1/admin/version lists derivation_use_rules_v1. It has no undo tool: correct 's answer names the DELETE /v1/corrections/{id} route that undoes it. The routes in full: Derivation Policies, Corrections, Review, Re-derivation, Change Feed and Memory About.

Status, usage and helpers

MCP toolv1 endpointNotes
health_checkGET /v1/auth/whoamiAuth + reachability in one call: caller, tenant, preset, capabilities.
get_usageGET /v1/auth/whoamiSame call plus the X-RateLimit-Limit and X-Cortex-Token-Expires-* response headers.
get_insightsGET /v1/events, /v1/facts, /v1/beliefs (up to 500 each)Heuristic pass over the scope: contradictions, low-confidence beliefs, key entities, activity spikes, new sources. No recall and no LLM involved.
cortexdb_check_callnone (offline)Validates a planned HTTP call or SDK snippet before you make it: catches POST /v1/memories, client.remember(...), a scope missing its type: prefix, a selector combined with confirm_all, and returns the correction.

Voice calls

One tool opens a live voice call on a server in voice mode. It is in every profile but code, and it changes no memory.

MCP toolv1 endpointNotes
call_briefPOST /v1/sessionsCall once when the call starts, with the call's own id as session and, when known, the reason for the call as query; also max_tokens (default 400) and idle_timeout_s. Returns the caller's brief. Then pass the same session to memory_search with profile="voice" on each turn. A server not in voice mode refuses it (409 VOICE_SESSIONS_DISABLED); voice searches work there without a session.

Code memory

Four read-only tools for the code memory plane; the server must run with CORTEX_CODE_PLANE=1 or every call returns 503 CODE_PLANE_DISABLED. Repository registration is an operator action through the API/CLI, not an MCP tool.

MCP toolv1 endpointNotes
code_explorePOST /v1/code/context (one repo) or POST /v1/code/workspace/context (several)Token-budgeted evidence envelope of cited snippets (repo:path@hash#Lx-Ly).
code_impactGET /v1/code/impactReverse dependency closure of a symbol, depth 1 to 6.
code_inventoryPOST /v1/code/symbol/search or POST /v1/code/inventorykind is required: a symbol-prefix search, or a bounded structural inventory (stats, files, …).
code_graphPOST /v1/code/graph/queryBounded graph traversal from roots, with node/edge budgets.

Code tools need the code plane

Entity/Facts tools need enrichment on self-host

Resources and prompts

The server also registers three MCP resources: cortexdb://health (GET /v1/auth/whoami), cortexdb://episodes (the scope's last 50 raw events via GET /v1/events) and cortexdb://insights (the same heuristic pass as get_insights), and five prompts: investigate_incident(topic), summarize_knowledge(topic), deployment_review(service), onboard_to_codebase(repo) and weekly_digest(tenant_id?). The prompts are plain instruction templates; they make no API calls themselves.

Tool profiles

ProfileTools
all (default)Every memory, access, voice and code tool but the opt-in writes (38)
writeall, plus the opt-in writes publish, forget_by_key, memory_correct, correction_undo and review_decide (43)
readOnly the tools that write no memory (31; acknowledge_notices changes only your notices and call_brief only opens a call)
codecode_explore, code_impact, code_inventory, code_graph (4)

Select one with --tool-profile or CORTEXDB_TOOL_PROFILE. A tool outside the profile is removed from the listing and cannot be called. Resources and prompts are registered under every profile.

Configuration Reference

Environment variableDefaultNotes
CORTEXDB_URLhttps://api-v1.cortexdb.aiv1 endpoint. With no CORTEXDB_API_KEY, anonymous signup is attempted against this URL (any host).
CORTEXDB_API_KEY(none)Any bearer: a person's or an agent's token, an identity provider's token, or, self-hosted, the server's CORTEX_API_KEY value. Unset → the cached state file, then anonymous signup.
CORTEXDB_ACTORthe token's subSent as X-Cortex-Actor; must match the token's sub. - sends none (an identity provider's token whose issuer maps the subject).
CORTEXDB_SCOPE(none)Default scope for tools that don't take an explicit one; set automatically by signup. Required otherwise.
CORTEXDB_VIEW(unset: the server's default)Recall reach for memory_search / get_context / advanced_search: holistic, descend, or granular. At a shared org-tree scope only granular and raw are allowed.
CORTEXDB_TOOL_PROFILEallall, read, write or code, as --tool-profile.
CORTEXDB_SUBJECT_TOKEN(none)With the operator key: a person's token, sent as X-Cortex-Subject-Token, so the server counts what that person would be refused (a dry run of moving off the key).
CORTEXDB_BREAK_GLASS_REASON, CORTEXDB_BREAK_GLASS_TICKET, CORTEXDB_BREAK_GLASS_NOTE(none)With the operator key under the deny mode: every request carries X-Cortex-Break-Glass built from them.
CORTEXDB_PURPOSE(none)The purpose reads declare unless a call names its own.
CORTEXDB_TENANT_ID(none)Legacy tenant id (v0 callers only).
CORTEXDB_TIMEOUT30.0HTTP request timeout (seconds).

The wheel also carries a small FastAPI app (uvicorn cortexdb_mcp.api:app) that serves the insights pass as GET /api/insights for a dashboard. It is not part of the MCP surface.

Architecture

Your Machine                           CortexDB
┌──────────┐    stdio     ┌───────────┐    HTTPS    ┌──────────┐
│ Cursor / │ ◄─────────►  │ cortexdb- │ ◄─────────► │  v1 API  │
│ Claude / │  MCP JSON    │    mcp    │  REST       │  server  │
│ VS Code  │              │ (bridge)  │             │          │
└──────────┘              └───────────┘             └──────────┘

The bridge process holds the bearer token in memory, injects Authorization and X-Cortex-Actor headers on every call, and translates MCP tool invocations into v1 HTTP requests. Nothing is stored locally except the credentials.

Next steps

  • Python SDK: programmatic access, V1Client + AsyncV1Client.
  • TypeScript SDK: Node.js and browser apps.
  • Auth: how tokens, actors, and capabilities fit together.
  • API Reference: endpoint-by-endpoint reference.