spatial-memory-mcp
Allows using OpenAI embedding models for memory vectorization, enabling semantic search and spatial navigation.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@spatial-memory-mcp recall what we discussed about authentication"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Spatial Memory MCP Server
A persistent semantic memory system for LLMs via the Model Context Protocol that treats knowledge as a navigable landscape, not a filing cabinet.
Version 1.11.4 — Production-ready with 2,500+ tests across Windows, macOS, and Linux.
Your AI assistant forgets everything between sessions. Spatial Memory fixes that. It gives Claude Code, Cursor, and any MCP client a persistent brain — memories that fade when stale, sharpen with use, and organize themselves into a navigable knowledge graph. Install in one command, capture knowledge automatically, and let your AI build on what it learned yesterday.
Why Spatial Memory?
Most memory servers store and retrieve. Spatial Memory thinks about your knowledge.
Memories That Fade Like Yours Do
Other memory tools treat every piece of information as equally important forever. Spatial Memory applies time-based decay — old, unused memories gradually lose importance while frequently accessed knowledge stays sharp. The result: your AI assistant surfaces what's relevant now, not what was relevant six months ago. Decay is automatic and configurable — adjust half-life, decay curves (exponential, linear, step), and minimum importance floors. Memories accessed frequently decay slower, just like human recall.
Why this approach? The cognitive memory model is inspired by established research:
Ebbinghaus, H. (1885) — Memory: A Contribution to Experimental Psychology. The foundational research on the forgetting curve showing how memory retention decays exponentially over time. Our exponential decay function directly models this curve.
Settles, B. & Meeder, B. (2016) — A Trainable Spaced Repetition Model for Language Learning. Duolingo's half-life regression (HLR) algorithm for optimizing memory retention. Our configurable half-life and access-count weighting draw from this work.
FSRS Algorithm — Free Spaced Repetition Scheduler. A modern open-source algorithm for optimizing review intervals based on memory research. Informed our adaptive decay that slows for frequently accessed memories.
Zero-Effort Memory Capture
You shouldn't have to stop coding to tell your AI "remember this." With cognitive offloading, hook scripts run silently in the background and capture decisions, bug fixes, error root causes, and architecture choices as they happen — no manual remember calls needed.
PostToolUse — captures insights after each tool call
PreCompact — saves knowledge before context window compaction would erase it
Stop — grabs remaining valuable context at session end
Content is classified into tiers (auto-save, ask-first, skip) and secrets are automatically redacted before storage.
Navigate and Search Like No Other Memory Server
Traditional memory is a search box. Spatial Memory is a map with a search engine. You get hybrid search — combined vector similarity and keyword matching with a tunable alpha — plus spatial tools that let you explore the space between and around your memories:
Tool | What It Does |
| Combined vector + keyword search with tunable balance (alpha 0.0-1.0) — find memories that match both meaning and specific terms |
| Walk the conceptual path between two memories using SLERP interpolation — discover what lies in between "authentication" and "performance" |
| Take a temperature-controlled random walk — stumble into unexpected connections you'd never think to search for |
| See how your knowledge self-organizes into clusters via HDBSCAN — find the natural shape of what you know |
| Project your memory space into 2D/3D via UMAP — render as JSON, Mermaid diagrams, or SVG |
Fast and Lightweight Embeddings
No GPU. No heavy model downloads. Spatial Memory defaults to all-MiniLM-L6-v2 — an ~80MB model trained on over 1 billion sentence pairs that maps text to 384-dimensional vectors, accelerated by ONNX Runtime for 2-3x faster inference over the default PyTorch backend — all on CPU alone.
ONNX Runtime auto-detected at startup — no configuration needed
CPU-only — no CUDA, no GPU drivers, works everywhere Python runs
Related MCP server: AI Long-Term Memory MCP Server
How Is This Different?
Most MCP memory servers are vector stores with semantic recall — store text, search by similarity, retrieve results. Spatial Memory starts there but adds what they don't: time-based decay that fades stale knowledge automatically, cognitive offloading hooks that capture decisions and errors without manual calls, spatial navigation (SLERP interpolation, random walks, HDBSCAN clustering) for exploring the space between memories, and hybrid search that combines vector similarity with keyword matching. If you need a simple key-value memory, any of those will work. If you want memory that behaves more like human recall — fading, reinforcing, and organizing itself — this is the one.
Quick Start
Windows users: This plugin requires
uvx(uv). Install it first:powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
Claude Code (Recommended)
Option A — Plugin (zero-config):
claude plugin marketplace add arman-tech/spatial-memory-mcp
claude plugin install spatial-memory@spatial-memory-marketplaceThis installs the plugin globally (user scope) — available across all your projects. To install for the current project only:
cd /path/to/your/project
claude plugin install spatial-memory@spatial-memory-marketplace --scope projectThat's it. The plugin registers 3 hooks (PostToolUse, PreCompact, Stop), starts the MCP server, and begins capturing knowledge automatically as you work.
Option B — Manual MCP config:
Add to your Claude Code settings (~/.claude/settings.json or project .claude/settings.json):
{
"mcpServers": {
"spatial-memory": {
"command": "uvx",
"args": ["--from", "spatial-memory-mcp", "spatial-memory", "serve"],
"env": {
"SPATIAL_MEMORY_COGNITIVE_OFFLOADING_ENABLED": "true"
}
}
}
}No pip install needed — uvx fetches the package from PyPI automatically.
Cursor
From your project root, one command writes .cursor/mcp.json, .cursor/hooks.json, and .cursor/rules/spatial-memory.mdc:
pip install spatial-memory-mcp
cd /path/to/your/project
spatial-memory init --client cursorClaude Desktop / Other MCP Clients
Add to your MCP client config (e.g., claude_desktop_config.json):
{
"mcpServers": {
"spatial-memory": {
"command": "uvx",
"args": ["--from", "spatial-memory-mcp", "spatial-memory", "serve"],
"env": {
"SPATIAL_MEMORY_COGNITIVE_OFFLOADING_ENABLED": "true"
}
}
}
}No pip install needed — uvx fetches the package from PyPI automatically.
Client | Install | Hooks | Notes |
Claude Code | Plugin or pip | Native (auto) | Full auto-capture via plugin or manual settings |
Cursor | pip + | Native (auto) | One-command setup via |
Claude Desktop | pip | Manual | Add MCP config, hooks require manual setup |
Other MCP clients | pip | Manual | Any client that speaks MCP works |
How It Works
Cognitive Offloading (Auto-Capture)
Three hooks (PostToolUse, PreCompact, Stop) run silently in the background to capture knowledge as you work — see Why Spatial Memory? for the full description. Captured content is classified into tiers:
Tier | Behavior | What's Captured |
1 | Auto-save | Decisions, bug fixes, error root causes, architecture choices |
2 | Ask first | Patterns, preferences, configuration discoveries, workarounds |
3 | Skip | Trivial observations, duplicates, speculative information |
Secrets (API keys, tokens, passwords) are automatically redacted before storage.
25 MCP Tools
Category | Tools |
Core |
|
Spatial |
|
Lifecycle |
|
Utility |
|
Cross-corpus |
|
Setup |
|
See docs/API.md for complete parameter and return type documentation.
Configuration
Settings via environment variables or .env file. Key options:
Variable | Default | Description |
|
| LanceDB storage directory |
|
| Embedding model (or |
|
|
|
| — | Required only for OpenAI embeddings |
|
| Enable queue-based auto-capture pipeline |
|
| Automatic importance decay over time |
|
| Logging verbosity |
See docs/CONFIGURATION.md for the full reference including auto-decay tuning, rate limiting, and connection pool settings.
CLI Commands
# Server
spatial-memory serve # Start the MCP server (default)
# Setup
spatial-memory init --client cursor # Auto-configure Cursor (writes 3 files)
spatial-memory setup-hooks --client X # Generate hook config for Claude Code or Cursor
# Database maintenance
spatial-memory namespaces # List all namespaces with memory counts
spatial-memory consolidate <namespace> # Merge duplicate memories (dry run by default)
spatial-memory consolidate <ns> --no-dry-run # Actually apply merges
spatial-memory migrate --status # Check database migration status
# Utilities
spatial-memory hook <event> --client X # Run a hook event (used by hook configs)
spatial-memory instructions # View auto-injected MCP instructions
spatial-memory --version # Show versionSecurity
Path traversal prevention on all file operations
SQL injection detection (13 patterns)
Secret redaction in cognitive offloading (AWS, GitHub, Stripe, OpenAI, SSH keys, JWTs, etc.)
Input validation via Pydantic models on all tool inputs
Error sanitization — internal errors return reference IDs, not stack traces
Secure credentials — API keys stored as
SecretStr
Development
# Install from source
git clone https://github.com/arman-tech/spatial-memory-mcp.git
cd spatial-memory-mcp
pip install -e ".[dev]"
# Run tests
pytest tests/ -v # Unit tests only
pytest tests/ -v -m "" # All tests (unit + integration)
# Quality checks
ruff check spatial_memory/ tests/
ruff format --check spatial_memory/ tests/
mypy spatial_memory/Architecture
Clean Architecture with ports/adapters pattern:
graph TD
Client["MCP Clients<br>Claude Code · Cursor"] --> Server["MCP Server<br>server.py · 25 tools"]
Hooks["Hook Dispatcher<br>PostToolUse · PreCompact · Stop"] -.->|file queue| Server
Server --> Services["Services<br>Memory · Spatial · Lifecycle · Utility"]
Services --> DB["Database Facade<br>database.py · 8 managers"]
Services --> Emb["Embeddings<br>embeddings.py"]
DB --> Lance["LanceDB"]
Emb --> ST["sentence-transformers<br>ONNX Runtime"]spatial_memory/
├── server.py # MCP server + tool handlers
├── factory.py # Dependency injection container
├── config.py # Pydantic settings
├── core/ # Database, embeddings, models, validation, security
├── services/ # Business logic (memory, spatial, lifecycle, utility)
├── adapters/ # LanceDB repository, project detection, git utils
├── ports/ # Protocol interfaces
├── hooks/ # Cognitive offloading dispatcher + pipeline
├── tools/ # MCP tool definitions + setup_hooks generator
└── migrations/ # Database schema migrationsSee SPATIAL-MEMORY-ARCHITECTURE-DIAGRAMS.md for visual documentation.
Documentation
Document | Description |
Complete API reference for all 25 tools | |
Full configuration reference | |
Step-by-step tutorial | |
Algorithm deep-dives (SLERP, HDBSCAN, UMAP) | |
Performance benchmarks | |
Common issues and solutions |
Supported Platforms
Windows 11, macOS (latest), Linux (Fedora, Ubuntu, Linux Mint)
Python 3.10+
CI tested across 3 OS x 4 Python versions
Contributing
Fork the repository
Create a feature branch
Add tests for new functionality
Ensure all tests pass (
pytest tests/ -v -m "")Submit a pull request
For contributors using AI assistants, see CLAUDE.md for project-specific guidance.
License
MIT — See LICENSE
Available Tools
25 toolsconsolidateA
Merge similar or duplicate memories to reduce redundancy. Finds memories above similarity threshold and merges them.
Inputs: namespace (required), dry_run, project, strategy, +3 more.
corpus_bridgesA
Find cross-namespace bridges in the memory corpus. Discovers memories in different namespaces that are semantically similar -- potential knowledge links or duplicates.
Inputs: _agent_id, max_bridges, min_similarity, namespace_filter.
decayA
Apply time and access-based decay to memory importance scores. Memories not accessed recently will have reduced importance.
Inputs: dry_run, project, _agent_id, namespace, +4 more.
delete_namespaceA
Delete all memories in a namespace. DESTRUCTIVE - use dry_run first.
Inputs: namespace (required), confirm, dry_run, _agent_id.
discover_connectionsA
Find cross-corpus connections for a memory. Discovers semantically similar memories across all namespaces and projects using ANN-based search with pluggable scoring.
Inputs: memory_id (required), limit, _agent_id, min_similarity, +2 more.
export_memoriesB
Export memories to file (Parquet, JSON, or CSV format).
Inputs: output_path (required), format, project, _agent_id, +2 more.
extractC
Automatically extract memories from conversation text. Uses pattern matching to identify facts, decisions, and key information.
Inputs: text (required), project, _agent_id, namespace, +3 more.
forgetA
Delete a memory by its ID.
Inputs: memory_id (required), _agent_id.
forget_batchA
Delete multiple memories by their IDs.
Inputs: memory_ids (required), _agent_id.
healthC
Check system health status.
Inputs: verbose, _agent_id.
hybrid_recallA
Search memories using combined vector and keyword (full-text) search.
Inputs: query (required), alpha, limit, project, +3 more.
import_memoriesB
Import memories from file with validation. Use dry_run=true first.
Inputs: source_path (required), format, dry_run, validate, +5 more.
journeyB
Navigate semantic space between two memories using spherical interpolation (SLERP). Discovers memories along the conceptual path.
Inputs: end_id (required), start_id (required), steps, _agent_id, +1 more.
namespacesA
List all namespaces with memory counts and date ranges.
Inputs: _agent_id, include_stats.
nearbyC
Find memories similar to a specific memory.
Inputs: memory_id (required), limit, project, _agent_id, +1 more.
recallB
Search for similar memories using semantic similarity.
Inputs: query (required), limit, project, _agent_id, +2 more.
regionsA
Discover semantic clusters in memory space using HDBSCAN. Returns cluster info with representative memories and keywords.
Inputs: project, _agent_id, namespace, max_clusters, +1 more.
reinforceA
Boost memory importance based on usage or explicit feedback. Reinforcement increases importance and can reset decay timer.
Inputs: memory_ids (required), _agent_id, boost_type, boost_amount, +1 more.
rememberC
Store a new memory in the spatial memory system.
Inputs: content (required), tags, project, metadata, +4 more.
remember_batchB
Store multiple memories efficiently in a single operation.
Inputs: memories (required), project, _agent_id.
rename_namespaceA
Rename a namespace, moving all its memories to the new name.
Inputs: new_namespace (required), old_namespace (required), _agent_id.
setup_hooksB
Generate hook configuration for cognitive offloading. Returns ready-to-use hooks JSON for Claude Code or Cursor.
Inputs: client, _agent_id, python_path, include_mcp_config, +1 more.
statsB
Get database statistics and health metrics.
Inputs: project, _agent_id, namespace, include_index_details.
visualizeB
Project memories to 2D/3D for visualization using UMAP. Returns coordinates and optional similarity edges.
Inputs: format, project, _agent_id, namespace, +3 more.
wanderA
Explore memory space through random walk. Uses temperature-based selection to balance exploration and exploitation.
Inputs: steps, start_id, _agent_id, namespace, +1 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 25 tools
Most tools target distinct operations, but there is notable overlap among retrieval/exploration tools: recall, hybrid_recall, nearby, discover_connections, corpus_bridges, journey, and wander all return semantically related memories with only subtle differences in scope. The descriptions help distinguish them, but an agent could easily select the wrong one, especially for recall vs. hybrid_recall and discover_connections vs. corpus_bridges.
Names are consistently lowercase snake_caseaine and readable, but they do not follow a single verb_noun convention; many are bare verbs (forget, recall, reinforce), while others are nouns or noun phrases (regions, stats, namespaces, corpus_bridges). This mix of imperative actions and declarative nouns is predictable enough to navigate but lacks the tight pattern of the highest-calibration servers.
At 25 tools, the server sits at the heavy end of the borderline range; the spatial memory domain can justify many operations, but the count feels inflated by a cluster of overlapping search and exploration tools. A tighter set closer to 18-20 tools would likely be just as capable and easier for an agent to navigate.
The surface covers the core memory lifecycle well: create (remember, remember_batch, extract), read/retrieve (recall, hybrid_recall, nearby), delete (forget, forget_batch, delete_namespace), plus namespace management, import/export, analytics, and maintenance. The main gap is the lack of a direct get_memory-by-ID tool and an update tool for editing memory content; users must work around this with forget-and-remember or importance-only mutation tools.
Maintenance
Related MCP Connectors
Persistent working memory for AI agents: a knowledge graph with semantic search and decay.
Persistent long-term memory for AI agents: semantic search, knowledge graph, and task canvas.
Shared long-term memory for AI agents: save and recall context as a searchable knowledge graph.
Persistent memory and knowledge graphs for AI agents. Hybrid search, context checkpoints, and more.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA knowledge-graph-based memory system for AI agents that enables persistent information storage between conversations.6-
- AlicenseNot gradedqualityDmaintenanceProvides persistent long-term memory for AI agents with semantic search and activation-based decay. Enables AI systems to remember across sessions through layered memory architecture and automatic context-aware retrieval.14 npmMIT
- AlicenseNot gradedqualityBmaintenancePersistent memory for AI agents with semantic memory, belief tracking, and dream consolidation, enabling cross-session knowledge retention.96 npm51MIT
- FlicenseNot gradedqualityDmaintenanceAn agentic memory system that enables AI assistants to store, search, and manage persistent memories with semantic understanding using natural language instructions.-