MCP Memory Server
Provides intelligent memory management capabilities using Qdrant vector database for semantic search and storage. Supports global, learned, and agent-specific memory types with markdown processing and duplicate detection.
README
MCP Memory Server with Qdrant Vector Database
A Model Context Protocol (MCP) server that provides intelligent memory management capabilities using Qdrant vector database for semantic search and storage. Built specifically for Cursor IDE integration.
Features
🧠 Multiple Memory Types
- Global Memory: Shared across all agents for common knowledge
- Learned Memory: Lessons learned and mistakes to avoid
- Agent-Specific Memory: Individual agent contexts and specialized knowledge
🔍 Semantic Search
- Vector-based similarity search using sentence transformers
- Duplicate detection to prevent redundant content
- Configurable similarity thresholds
📝 Markdown Processing
- Intelligent content cleaning and optimization
- YAML front matter extraction
- Section-based content organization
🔧 MCP Integration
- Standard MCP protocol compliance for Cursor
- stdin/stdout communication
- Comprehensive tool set for memory operations
Architecture
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ │ │ │ │ │
│ Cursor IDE │◄──►│ MCP Server │◄──►│ Qdrant Vector │
│ │ │ (stdin/stdout) │ │ Database │
│ │ │ │ │ │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│
▼
┌──────────────────┐
│ Sentence │
│ Transformers │
│ (Embeddings) │
└──────────────────┘
Installation
Prerequisites
- Python 3.10+ with pip
- Qdrant Database (can run locally with Docker)
- Cursor IDE for MCP integration
Setup Qdrant Database
Using Docker (recommended):
docker run -p 6333:6333 -v $(pwd)/qdrant_storage:/qdrant/storage qdrant/qdrant
Or install Qdrant locally following their installation guide.
Install Dependencies
Using Poetry (recommended):
# Install dependencies using Poetry
poetry install
Or using pip:
# Install Python dependencies
pip install -r requirements.txt
Configuration
- Copy the example environment file:
cp .env.example .env
- Edit
.envwith your settings:
# Qdrant Configuration
QDRANT_HOST=localhost
QDRANT_PORT=6333
QDRANT_API_KEY=
# Embedding Model Configuration
EMBEDDING_MODEL=all-MiniLM-L6-v2
EMBEDDING_DIMENSION=384
# Memory Configuration
SIMILARITY_THRESHOLD=0.8
MAX_RESULTS=10
# Agent Configuration
DEFAULT_AGENT_ID=default
# Server Configuration
LOG_LEVEL=INFO
Usage
Starting the Server
python server.py
The server will:
- Connect to Qdrant database
- Initialize vector collections
- Load the embedding model
- Start listening for MCP commands via stdin/stdout
Cursor IDE Integration
Add the server to your Cursor MCP configuration:
{
"mcpServers": {
"memory-server": {
"command": "/media/hannesn/storage/Code/MCP/.venv/bin/python",
"args": ["/media/hannesn/storage/Code/MCP/server.py"],
"cwd": "/media/hannesn/storage/Code/MCP",
"env": {
"PYTHONPATH": "/media/hannesn/storage/Code/MCP",
"QDRANT_HOST": "localhost",
"QDRANT_PORT": "6333",
"EMBEDDING_MODEL": "all-MiniLM-L6-v2",
"SIMILARITY_THRESHOLD": "0.8",
"MAX_RESULTS": "10",
"LOG_LEVEL": "INFO"
}
}
}
}
Alternatively, you can run the server using Poetry:
poetry run python server.py
MCP Tools
1. set_agent_context
Initialize agent context from a markdown file.
Parameters:
agent_id(string): Unique identifier for the agentcontext_file_path(string): Path to markdown file with agent contextdescription(string, optional): Description of the context
Example:
{
"tool": "set_agent_context",
"arguments": {
"agent_id": "frontend_dev",
"context_file_path": "./contexts/frontend_agent.md",
"description": "Frontend development agent context"
}
}
2. add_to_global_memory
Add content to global memory shared across all agents.
Parameters:
file_path(string): Path to markdown filedescription(string, optional): Content description
Example:
{
"tool": "add_to_global_memory",
"arguments": {
"file_path": "./docs/coding_standards.md",
"description": "Company coding standards"
}
}
3. add_to_learned_memory
Store lessons learned to avoid repeated mistakes.
Parameters:
file_path(string): Path to markdown file with lessonslesson_type(string): Type of lesson (e.g., "deployment", "security")description(string, optional): Lesson description
Example:
{
"tool": "add_to_learned_memory",
"arguments": {
"file_path": "./lessons/deployment_issues.md",
"lesson_type": "deployment",
"description": "Critical deployment lessons"
}
}
4. add_to_agent_memory
Add content to agent-specific memory.
Parameters:
agent_id(string): Target agent identifierfile_path(string): Path to markdown filedescription(string, optional): Content description
Example:
{
"tool": "add_to_agent_memory",
"arguments": {
"agent_id": "backend_dev",
"file_path": "./docs/api_patterns.md",
"description": "Backend API design patterns"
}
}
5. query_memory
Search memory collections for relevant content.
Parameters:
query(string): Search querymemory_type(string): "global", "learned", "agent", or "all"agent_id(string, optional): Agent ID for agent-specific queriesmax_results(integer, optional): Maximum results (default: 10)
Example:
{
"tool": "query_memory",
"arguments": {
"query": "authentication best practices",
"memory_type": "all",
"max_results": 5
}
}
6. compare_against_learned_memory
Check proposed actions against past lessons learned.
Parameters:
action_description(string): Description of proposed actionagent_id(string, optional): Agent making the request
Example:
{
"tool": "compare_against_learned_memory",
"arguments": {
"action_description": "Deploy database migration on Friday afternoon",
"agent_id": "devops_agent"
}
}
Memory Types Explained
Global Memory
- Purpose: Store knowledge shared across all agents
- Content: Coding standards, documentation, best practices
- Access: All agents can query this memory
- Use Case: Company-wide policies, architectural decisions
Learned Memory
- Purpose: Store lessons learned from past mistakes
- Content: Incident reports, post-mortems, anti-patterns
- Access: Most agents (exclude "human-like" testers)
- Use Case: Avoid repeating past mistakes, improve decisions
Agent-Specific Memory
- Purpose: Store knowledge specific to individual agents
- Content: Role definitions, specialized knowledge, context
- Access: Only the specific agent
- Use Case: Agent initialization, specialized expertise
Testing
Run Basic Functionality Tests
python tests/test_basic_functionality.py
This will test:
- Qdrant connection and collection setup
- Memory operations (add, query, duplicate detection)
- Markdown processing and content cleaning
- Vector embedding and similarity search
Manual Testing with Sample Data
- Start the server:
python server.py
- Use the provided sample markdown files in
sample_data/:frontend_agent_context.md: Frontend agent contextbackend_agent_context.md: Backend agent contextdeployment_lessons.md: Learned lessonsglobal_standards.md: Global development standards
Troubleshooting
Common Issues
Qdrant Connection Failed
❌ Failed to initialize Qdrant: ConnectionError
- Ensure Qdrant is running on configured host/port
- Check firewall settings
- Verify API key if using Qdrant Cloud
Embedding Model Download Issues
❌ Failed to load embedding model
- Ensure internet connection for first download
- Check available disk space (models can be large)
- Try alternative model in configuration
Memory Full / Performance Issues
- Reduce
EMBEDDING_DIMENSIONfor smaller models - Increase
SIMILARITY_THRESHOLDto reduce results - Consider pruning old content from collections
Debugging
Enable debug logging:
export LOG_LEVEL=DEBUG
python server.py
Check Qdrant collections:
curl http://localhost:6333/collections
Configuration Reference
Environment Variables
| Variable | Default | Description |
|---|---|---|
QDRANT_HOST |
localhost | Qdrant server host |
QDRANT_PORT |
6333 | Qdrant server port |
QDRANT_API_KEY |
API key for Qdrant Cloud | |
EMBEDDING_MODEL |
all-MiniLM-L6-v2 | Sentence transformer model |
EMBEDDING_DIMENSION |
384 | Vector dimension size |
SIMILARITY_THRESHOLD |
0.8 | Duplicate detection threshold |
MAX_RESULTS |
10 | Default max query results |
DEFAULT_AGENT_ID |
default | Default agent identifier |
LOG_LEVEL |
INFO | Logging verbosity |
Collection Names
- Global Memory:
global_memory - Learned Memory:
learned_memory - Agent Memory:
agent_specific_memory_{agent_id}
Development
Project Structure
mcp-memory-server/
├── server.py # Main MCP server
├── src/
│ ├── __init__.py
│ ├── config.py # Configuration management
│ ├── memory_manager.py # Qdrant operations
│ └── markdown_processor.py # Markdown handling
├── tests/
│ └── test_basic_functionality.py
├── sample_data/ # Example markdown files
├── docs/ # Additional documentation
├── requirements.txt # Python dependencies
├── pyproject.toml # Poetry configuration
└── README.md # This file
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests:
python -m pytest tests/ - Submit a pull request
Adding New Tools
- Add tool function to
MCPMemoryServer._register_tools() - Update
_list_tools()method with tool schema - Add tests for the new functionality
- Update this README
License
MIT License - see LICENSE file for details.
Support
For issues and questions:
- Check the troubleshooting section above
- Review Qdrant documentation for database issues
- Check MCP protocol documentation for integration issues
- Open an issue with detailed logs and configuration
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。