Cortex Memory MCP Server
cortex-mem-mcp is a server implementation based on Model Context Protocol (MCP) that enables AI assistants to interact with the Cortex Memory system for persistent memory storage and retrieval.
🧠 Overview
Cortex Memory MCP Server provides six core tools for AI assistants:
- 📝 store_memory: Store new memories from conversations
- 🔍 query_memory: Semantic vector search with L0/L1/L2 layered results
- 📋 list_memories: Browse stored memory entries
- 📄 get_memory: Retrieve complete memory content
- 🗑️ delete_memory: Delete specific memory entries
- 📊 get_abstract: Get L0 abstract summary (~100 tokens)
🛠️ MCP Tools
1. store_memory
Store a new memory in the Cortex Memory system.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
content |
string | ✅ | - | Memory content to store |
thread_id |
string | ❌ | "default" |
Session ID for organizing related memories |
role |
string | ❌ | "user" |
Message role: "user", "assistant", or "system" |
Example Request
Response
2. query_memory
Search memories using semantic vector search with L0/L1/L2 layered results.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
query |
string | ✅ | - | Search query string |
thread_id |
string | ❌ | - | Limit search to this session |
limit |
number | ❌ | 10 |
Maximum number of results |
scope |
string | ❌ | "session" |
Search scope: "session", "user", or "agent" |
Scope URI Mapping
| Scope | URI Pattern |
|---|---|
session |
cortex://session |
user |
cortex://user |
agent |
cortex://agent |
| (with thread_id) | cortex://session/{thread_id} |
Example Request
Response
3. list_memories
List memories from a specific URI path.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
uri |
string | ❌ | "cortex://session" |
URI path to list |
limit |
number | ❌ | 50 |
Maximum number of entries |
include_abstracts |
boolean | ❌ | false |
Include L0 abstracts |
Supported URI Patterns
| URI Pattern | Description |
|---|---|
cortex://session |
List all sessions |
cortex://user/{user-id} |
List user memories |
cortex://agent/{agent-id} |
List agent memories |
cortex://session/{session-id}/timeline |
List session timeline |
Example Request
Response
4. get_memory
Retrieve complete content of a specific memory.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
uri |
string | ✅ | - | Full URI of the memory |
Example Request
Response
5. delete_memory
Delete a specific memory entry.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
uri |
string | ✅ | - | URI of the memory to delete |
Example Request
Response
6. get_abstract
Get the L0 abstract summary (~100 tokens) of a memory for quick relevance checking.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
uri |
string | ✅ | - | URI of the memory |
Example Request
Response
🚀 Installation & Configuration
Build Requirements
- Rust 1.70 or later
- Cross-platform support: Linux, macOS, Windows
Build
# Clone repository
# Build the server
# Binary location
Command-line Arguments
| Argument | Default | Description |
|---|---|---|
--config / -c |
config.toml |
Path to configuration file |
--tenant |
default |
Tenant ID for memory isolation |
Configure Claude Desktop
Edit Claude Desktop configuration file:
macOS:
Windows:
Add configuration:
Configuration File (config.toml)
[]
# Data directory (optional, has smart defaults)
= "/path/to/cortex-data"
[]
# LLM API configuration
= "https://api.openai.com/v1"
= "your-api-key"
= "gpt-4o-mini"
= 0.1
= 4096
[]
# Embedding configuration
= "https://api.openai.com/v1"
= "your-embedding-api-key"
= "text-embedding-3-small"
= 10
= 30
[]
# Vector database configuration
= "http://localhost:6333"
= "cortex_memories"
= 1536
= 30
Data Directory Resolution
Priority order:
cortex.data_dirconfig valueCORTEX_DATA_DIRenvironment variable- System app data directory (e.g.,
%APPDATA%/tars/cortexon Windows) - Fallback:
./.cortexin current directory
🔄 MCP Workflow
Typical Memory Workflow
// 1. Start of conversation: Query relevant memories
await ;
// 2. During conversation: Store new information
await ;
// 3. End of conversation: Store summary
await ;
Advanced Search Strategy
// 1. Search in sessions first
const sessionResults = await ;
// 2. If more context needed, search user memories
if
// 3. Get full content
const fullContent = await ;
// 4. Or get abstract for quick preview
const abstract = await ;
🔧 Troubleshooting
Common Issues
1. Connection Failed
Error: Failed to connect to MCP server
Solution:
- Check Claude Desktop configuration file path
- Verify binary file path and permissions
- View log output
# Test run
RUST_LOG=debug
2. Memory Storage Failed
Error: Failed to store memory
Solution:
- Check data directory permissions
- Verify LLM API configuration
- Confirm Qdrant service is running
- Check embedding configuration
# Check directory permissions
# Check Qdrant connection
3. Empty Search Results
Error: Search returned empty results
Solution:
- Check if memories exist
- Verify search query format
- Confirm search scope
// Test listing
await ;
4. Qdrant Connection Failed
Error: Failed to connect to Qdrant
Solution:
- Ensure Qdrant service is running
- Check URL configuration
- Verify collection name exists
# Start Qdrant (Docker)
# Check connection
Debug Mode
# Enable verbose logging
RUST_LOG=debug
🔗 Related Resources
- Cortex Memory Main Documentation
- Cortex Memory Core
- Cortex Memory Tools
- Model Context Protocol
- Claude Desktop MCP Documentation
🤝 Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Create a Pull Request
📄 License
MIT License - see the LICENSE file for details.
Built with ❤️ using Rust and Model Context Protocol