Cortex Memory Engine
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Cortex Memory Engine
Cortex is a self-hosted memory and pre-flight safety server for coding agents. It exposes a FastAPI REST API alongside Model Context Protocol (MCP) endpoints so agents can search past fixes, store new notes, and check risky shell commands before running them.
Why I built it this way
Coding agents start every session from scratch. They forget environment quirks, repeat container flag bugs, and can run destructive commands if nothing sits between the model and the shell. I built Cortex to fix those specific problems without turning my homelab into a fragile stack of vector databases.
Plain Markdown on disk, disposable SQLite in front
Every memory, architecture note, and troubleshooting entry lives as a plain Markdown file with YAML frontmatter (cortex/vault.py). The SQLite database (notes_meta and notes_fts) is strictly a rebuildable cache. If the index breaks or needs a schema change, wipe_index() drops it and rebuilds from the .md files on disk. A watchfiles loop (cortex/watcher.py) watches the vault directory so edits made by hand in a text editor or Obsidian show up in search automatically. Nothing is locked inside a proprietary store.
FTS5 first, Ollama embeddings optional
Exact error strings, CLI flags, and port numbers are where pure vector search tends to miss. Cortex indexes every note in SQLite FTS5 using the porter unicode61 tokenizer in WAL mode (cortex/search.py), so keyword lookups stay fast and need zero GPU memory. When an Ollama server is available, Cortex computes dense embeddings (cortex/embeddings.py) and merges them with BM25 scores through Reciprocal Rank Fusion (RRF). If Ollama is offline or turned off (CORTEX_ENABLE_VECTORS=false), search falls back to FTS5 instead of failing.
Static regex guardrails instead of an LLM judge
Asking another language model whether a shell command is dangerous adds latency and still leaves room for prompt drift. HazardInterceptor (cortex/interceptor.py) runs static regex checks timed with perf_counter_ns, finishing in under a millisecond. It blocks destructive patterns like rm -rf /, rm -rf ~, git push --force main, piped curl | bash, and pct/qm destroy, and returns warnings for subtle traps such as git reset --hard or docker run --gpus all missing --runtime=nvidia on cgroup v2.
Superseding old notes instead of deleting them
Configs change, and stale troubleshooting notes make agents repeat outdated workarounds. Calling /api/supersede marks the older note with status: superseded and a superseded_by reference, then down-ranks it during retrieval. Newer decisions surface first while the old history stays readable on disk.
Related MCP server: hexis
Quickstart (Docker)
cp .env.example .env
docker compose up -d --buildCheck that the server is up:
curl http://localhost:8766/healthMarkdown notes persist under ./data/vault and the SQLite index under ./data/cache.
Local development
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
export CORTEX_VAULT_PATH=./data/vault
export CORTEX_CACHE_PATH=./data/cache/index.db
export CORTEX_ENABLE_VECTORS=false
uvicorn cortex.server:app --host 0.0.0.0 --port 8766Running tests
pip install pytest
python -m pytest -vAPI and MCP endpoints
Endpoint | Method | Purpose |
|
| Service status, indexed note count, and Ollama availability |
|
| Hybrid BM25 and vector search with optional type filtering |
|
| Read a Markdown note by relative path |
|
| Write a new memory or troubleshooting note to the vault |
|
| Mark an older note as superseded by a newer one |
|
| Run a pre-flight hazard check on a shell command |
|
| Model Context Protocol endpoints for coding agents |
Configuration
See .env.example for all environment variables (CORTEX_OLLAMA_URL, CORTEX_ENABLE_VECTORS, CORTEX_EMBEDDING_MODEL, CORTEX_VAULT_PATH, CORTEX_CACHE_PATH, CORTEX_PORT).
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Hosted MCP memory for coding agents: persistent across sessions, editable markdown, team sharing.
Persistent memory, knowledge graph, task management and more for AI agents via MCP.
Shared memory for your AI tools: tasks, notes and context every tool can read and write over MCP.
Team memory for AI coding agents and code reviews, reviewed by humans and served over MCP.
Related MCP Servers
- AlicenseAqualityBmaintenanceEnables coding agents to store, search, and retrieve long-term memory as plain Markdown files with a disposable SQLite index, including note management, decision/bug tracking, and codebase symbol lookup via MCP.8MIT
- AlicenseNot gradedqualityBmaintenanceEnables coding agents to retrieve and verify semantic memory from markdown notes via MCP, with automatic indexing and self-checking for reliability.1Apache 2.0
- AlicenseNot gradedqualityBmaintenanceGives coding agents a persistent memory by searching a local, read-only index of existing markdown and letting them write findings back as notes that the next session can retrieve. It serves ranked, context-sized results over MCP, injects standing conventions at session start, and keeps data on your machine with secret redaction and archive-only deletion.MIT
- AlicenseAqualityBmaintenanceEnables coding agents to save, search, and recall Markdown notes as persistent memory over MCP using a local index. Exposes remember, search, and recall tools so agents can reuse prior decisions and context across sessions.8428 npm58Apache 2.0