Mnemos
A self-hosted, multi-context memory server that enables AI agents to search and retrieve information from local documents and crawled websites via MCP tools. It runs fully offline using Postgres and Ollama to provide secure, private knowledge management and retrieval-augmented generation.
README
🧠 Mnemos
Self-hosted, Multi-context Memory Server for Developers
Mnemos is an MCP compatible knowledge server that turns your documentation piles into a multi context memory system. It organizes documents into isolated collections, eliminates redundant processing with content hashing, and runs fully offline using Postgres + pgvector and Ollama.
Features
- Multi-context Collections: Isolate your memory by project (e.g.,
react-docs,rust-book,company-internal) with case insensitive search filtering. - Deterministic Re-ingestion: SHA-256 content hashing guarantees idempotent operation—skipping unchanged files and automatically re-chunking on diffs.
- Enhanced Terminal UI: Explore your context with a full screen search interface, result navigation, and detailed chunk inspection modals.
- Recursive Site Crawling: Ingest entire documentation sites with path based filtering (e.g., crawl only
/learnonreact.dev). - Stable Local Embeddings: Optimized for Ollama with persistent connections, automatic runner backoff, and load throttling.
- Chunk Quality Control: Automatic noise filtering (minimum length thresholds + alphanumeric validation) ensures high quality retrieval.
- 100% Private: Fully offline. Your context never leaves your local machine.
Quick Start
Prerequisites
- Docker & Docker Compose
- Python 3.11+
- Ollama (for local embeddings)
1. Install Ollama & Pull Embedding Model
brew install ollama
ollama serve
ollama pull nomic-embed-text
2. Start the Database
cd docker
docker-compose up -d
3. Install Dependencies
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
4. Start the Server
# Option A: Start via CLI (recommended)
python cli/mnemos.py server
# Option B: Run API directly (development)
uvicorn src.main:app --reload
5. Add Documents
python cli/mnemos.py add ./docs/my-document.pdf --collection my-project
# Or crawl a site
python cli/mnemos.py ingest https://react.dev/learn --path-filter /learn --collection react
6. Search
python cli/mnemos.py search "how to use useEffect"
CLI Commands
| Command | Description | Flags |
|---|---|---|
mnemos add <path> |
Add a document or directory | -c <collection>, -r (recursive) |
mnemos ingest <url> |
Ingest a URL or crawl a site | -c <collection>, --path-filter |
mnemos search <query> |
Search for relevant context | -c <collection>, -k <limit> |
mnemos list |
List all documents | -c <collection>, -n <limit> |
mnemos export <file> |
Backup knowledge base to JSON | -c <collection> |
mnemos delete <id> |
Delete a document | -f (force) |
mnemos server |
Start the API server | --host, --port |
API Endpoints
REST API
Mnemos provides a standard REST API for document management and operations.
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/documents |
Upload a document |
GET |
/api/documents |
List all documents |
GET |
/api/collections |
List all unique collections |
GET |
/api/documents/export |
Full JSON backup of chunks |
DELETE |
/api/documents/{id} |
Delete a document |
POST |
/api/search |
Vector similarity search |
POST |
/api/ingest/url |
Ingest a single URL |
POST |
/api/ingest/site |
Crawl a documentation site |
GET |
/api/health |
Health & Stats check |
MCP Endpoints
Mnemos exposes its retrieval capabilities via the Model Context Protocol (MCP), allowing AI agents to query it as an external context provider. Mnemos is designed to be stateless from the MCP client’s perspective; all persistence lives server-side.
| Method | Endpoint | Description |
|---|---|---|
GET |
/mcp/tools |
List available MCP tools |
POST |
/mcp/call |
Execute an MCP tool |
MCP Integration
Claude Desktop
Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"mnemos": {
"command": "curl",
"args": ["-X", "POST", "http://localhost:8000/mcp/call", "-H", "Content-Type: application/json", "-d"]
}
}
}
Available MCP Tools
- search_context: Search the knowledge base for relevant context
- list_documents: List all documents in the knowledge base
- get_document_info: Get detailed information about a document
Configuration
Environment variables (.env):
| Variable | Default | Description |
|---|---|---|
DATABASE_URL |
postgresql+asyncpg://... |
Postgres connection string |
EMBEDDING_PROVIDER |
ollama |
ollama (local-first default) or openai |
EMBEDDING_MODEL |
nomic-embed-text |
Ollama embedding model |
OLLAMA_BASE_URL |
http://127.0.0.1:11434 |
Ollama API URL |
CHUNK_SIZE |
300 |
Target characters per chunk |
CHUNK_OVERLAP |
40 |
Overlap between chunks |
Architecture
graph TD
User([User CLI / App]) --> API[FastAPI Server]
API --> DB[(PostgreSQL + pgvector)]
API --> Ollama[Ollama Local Embeddings]
subgraph Ingestion Pipeline
API --> Parser[Document Parser]
Parser --> Chunker[Text Chunker]
Chunker --> HashCheck[SHA-256 Content Hash]
HashCheck --> Embedding[Vector Generation]
end
subgraph Retrieval
API --> Search[Vector Search]
Search --> Context[Context Assembler]
end
Design Principles
- Local-first by default: All heavy lifting (vectors/search) happens on your hardware.
- Deterministic ingestion: SHA-256 hashing ensures idempotency and safe re-runs.
- Explicit context isolation: Multi-collection support prevents cross-project context pollution.
- Inspectable retrieval: Similarity scores and chunk metadata are exposed to build trust.
- Zero vendor lock-in: Standards-based tech stack (Postgres, MCP, REST).
Supported Embedding Models
| Model | Dimensions | Notes |
|---|---|---|
nomic-embed-text |
768 | Default, good balance |
mxbai-embed-large |
1024 | Higher quality |
all-minilm |
384 | Faster, smaller |
Security Posture
- Local-Only: By default, Mnemos binds to
0.0.0.0but does not include authentication. It is intended for local use or behind a secure tunnel. - No External Calls: All vector generation and retrieval happen locally. No telemetry or document data is sent to external servers.
- SQLi Prevention: Uses SQLAlchemy ORM and parameterized queries for all database interactions.
Non-Goals
- Cloud Hosting: Mnemos is not designed to be a multi-tenant cloud SaaS.
- Advanced LLM Orchestration: It focuses on context provision, not on being a full RAG agent.
- Browser Automation: Ingestion is via CLI or URL crawler, not a GUI automation tool.
Development
black src/ cli/
pytest tests/
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。