mem-brain-mcp · Model Context Protocol

MCP Server

The Mem-Brain MCP server exposes your memory as callable tools over the Model Context Protocol — run it locally, or connect to the hosted endpoint without installing anything.
Any MCP-capable client — Cursor, Claude Code, Claude Desktop, ChatGPT, Agno — can call search_memories, add_memory, and the rest automatically.
  • Local or remote

    Run the MCP server on your machine, or connect to the hosted endpoint with OAuth.

  • Any MCP client

    Cursor, Claude Code, Claude Desktop, ChatGPT, Agno — configure once and go.

  • Full tool surface

    search_memories, add_memory, traverse_graph, stats, deletes, and agent instructions.

  • Stateless bridge

    Each tool call hits the API with your auth; the client polls ingest so agents get a predictable contract.

Install

Two options — pick whichever you prefer:

bash
uvx mem-brain-mcp

The server starts on http://localhost:8100 by default. You can verify it's running:

bash
curl http://localhost:8100/health

Connect your client

Add this to ~/.cursor/mcp.json. Replace mb_live_xxx with your real API key.

~/.cursor/mcp.json
json
{  "mcpServers": {    "mem-brain": {      "url": "http://localhost:8100/mcp",      "headers": {        "X-API-Key": "mb_live_xxx"      }    }  }}
The MCP server is stateless — it proxies every tool call to the Mem-Brain API with your API key. You can run one server and share it across clients by passing different keys per client.
Mem-Brain memory writes are async at the REST layer, but the MCP client polls the ingest job for you. From the MCP tool perspective, add_memory(...) still behaves like a normal blocking tool call.

Available tools

ToolWhat it does
add_memory(content, tags?, category?, ingestion_scope?)Store a new memory; optional ingest-time tag scope for merge/link candidates
search_memories(query, k?, response_format?, scope?, rerank?, full_scope?, keyword_filter?, scope_regex?)Semantic search; optional scope (API list), rerank (nodes only), full_scope (list all in scope); legacy keyword_filter / scope_regex are single-source aliases—do not combine
traverse_graph(start_memory_id, query, ...)Semantic graph traversal along edge descriptions
get_memories(memory_ids)Fetch specific memories by ID
delete_memories(memory_id? | tags? | category?)Delete by ID, tag, or category
get_stats()Count and metadata about your memory store
get_agent_instructions()Returns a prompt snippet the agent can use as context

Search response formats

The response_format parameter on search_memories controls what comes back:

ValueReturns
rawMemory nodes and graph edges
interpretedLLM plain-language summary — best for injecting directly into context
bothSummary plus raw evidence
Example — search with interpreted response
bash
search_memories(query="What does the user prefer for their editor?", response_format="interpreted")

Environment variables

VariableDefaultDescription
API_BASE_URLhosted Railway URLURL of your Mem-Brain API
MEMBRAIN_API_KEYFallback key for single-user local runs. Overridden by the per-request header.
MCP_SERVER_PORT8100Port the MCP server listens on
LOG_LEVELINFOSet to DEBUG to log every tool call

Troubleshooting

Tools not appearing in Cursor: restart Cursor after editing mcp.json and check that the server is running.
401 errors: make sure your X-API-Key header is present and the key starts with mb_live_.
Server not responding: run curl http://localhost:8100/health — if that fails the server isn't up yet.
Silent failures: set LOG_LEVEL=DEBUG and restart to see full request/response logs.

See also