mcp-memory-sqlite
A personal knowledge graph and memory system for AI assistants using SQLite with FTS5 full-text search, enabling persistent memory across conversations with Claude or any MCP-compatible AI.
README
mcp-memory-sqlite
This repository has been superseded by alexfayers/mcp-memory, a full rewrite in Python. This TypeScript version is no longer maintained.
A personal knowledge graph and memory system for AI assistants using SQLite with FTS5 full-text search. Perfect for giving Claude (or any MCP-compatible AI) persistent memory across conversations!
Fork of spences10/mcp-memory-sqlite with additional tools and FTS5 search upgrade.
Why Use This?
Give your AI assistant a memory! This tool lets Claude (or other AI assistants) remember entities, concepts, and their relationships across conversations. Perfect for:
- 📚 Personal Knowledge Management - Build your own knowledge graph
- 🤖 AI Assistant Memory - Help Claude remember important information about your projects, preferences, and context
- 🔗 Relationship Tracking - Connect ideas, people, projects, and concepts
- 🔍 Smart Text Search - Find information using FTS5 full-text search with BM25 relevance ranking
Features
- 100% Local & Private: All your data stays on your machine
- Easy Setup: Works out-of-the-box with Claude Desktop
- FTS5 Full-Text Search: Multi-word queries with BM25 relevance ranking
- Smart Deduplication: Automatically prevents duplicate relationships
- Context-Optimized: Designed specifically for LLM context efficiency
- Safe Observation Updates: Append or delete individual observations without overwriting
- Graph Traversal: Explore 1-hop entity relationships filtered by type
Quick Start
For Claude Desktop users (recommended):
Add this to your Claude Desktop config:
{
"mcpServers": {
"memory": {
"command": "npx",
"args": ["-y", "mcp-memory-sqlite"]
}
}
}
That's it! Claude can now remember things across conversations.
Installation
If you want to use it in your own project:
npm install mcp-memory-sqlite
# or
pnpm add mcp-memory-sqlite
Configuration
Optional: Customize the database location with an environment variable:
SQLITE_DB_PATH: Where to store your data (default:./sqlite-memory.db)
MCP Tools
create_entities
Create or update entities with observations. Note: This overwrites
all existing observations for an entity - use add_observations to
append instead.
Parameters:
entities: Array of entity objectsname(string): Unique entity identifierentityType(string): Type/category of the entityobservations(string[]): Array of observation strings
Example:
{
"entities": [
{
"name": "Claude",
"entityType": "AI Assistant",
"observations": [
"Created by Anthropic",
"Focuses on being helpful, harmless, and honest"
]
}
]
}
add_observations
Append observations to an existing entity without overwriting existing ones. Skips duplicate observations. Throws if the entity does not exist.
Parameters:
entityName(string): Name of the entity to updateobservations(string[]): Observations to add
Example:
{
"entityName": "Claude",
"observations": ["Supports extended thinking mode"]
}
delete_observations
Delete specific observations from an existing entity by content match. Returns the count of deleted observations. Throws if the entity does not exist.
Parameters:
entityName(string): Name of the entity to updateobservations(string[]): Exact observation strings to delete
Example:
{
"entityName": "Claude",
"observations": ["Focuses on being helpful, harmless, and honest"]
}
search_nodes
Search for entities and their relations using FTS5 full-text search with BM25 relevance ranking. Multi-word queries match terms independently across entity names, types, and all observations.
Parameters:
query(string): Text to search forlimit(number, optional): Maximum results to return (default: 10, max: 50)
Example:
{
"query": "AI Assistant",
"limit": 5
}
read_graph
Get recent entities and their relations (returns last 10 entities by default).
Parameters: None
create_relations
Create relationships between entities. Duplicate relations (same source, target, and type) are automatically ignored.
Parameters:
relations: Array of relation objectssource(string): Source entity nametarget(string): Target entity nametype(string): Relationship type
Example:
{
"relations": [
{
"source": "Claude",
"target": "Anthropic",
"type": "created_by"
}
]
}
get_entity_with_relations
Get an entity along with all its relations and directly connected entities.
Parameters:
name(string): Entity name to retrieve
Example:
{
"name": "Claude"
}
search_related_nodes
Get an entity along with all its directly related entities. Optionally filter by entity type and/or relation type for targeted graph traversal.
Parameters:
name(string): Entity name to retrieveentityType(string, optional): Filter related entities by typerelationType(string, optional): Filter relations by type
Example:
{
"name": "my-project",
"entityType": "task",
"relationType": "implements"
}
delete_entity
Delete an entity and all associated data (observations and relations).
Parameters:
name(string): Entity name to delete
delete_relation
Delete a specific relation between entities.
Parameters:
source(string): Source entity nametarget(string): Target entity nametype(string): Relationship type
Usage with Claude Desktop
Add to your Claude Desktop configuration:
Minimal configuration (uses default ./sqlite-memory.db):
{
"mcpServers": {
"memory": {
"command": "npx",
"args": ["-y", "mcp-memory-sqlite"]
}
}
}
With custom database path:
{
"mcpServers": {
"memory": {
"command": "npx",
"args": ["-y", "mcp-memory-sqlite"],
"env": {
"SQLITE_DB_PATH": "/path/to/your/memory.db"
}
}
}
}
Database Schema
Tables
- entities: Stores entity metadata (name, type, creation time)
- observations: Stores observations linked to entities
- relations: Stores relationships between entities
- schema_version: Tracks applied migrations
- entities_fts: FTS5 virtual table for full-text search (with sync triggers)
Migrating from Old Single-Project Databases
If you have existing single-project memory databases (e.g., global.db, project.db), use the alexfayers-mcp-memory-sqlite-migrate tool to import them into the new unified multi-project database:
Migrate global memory:
alexfayers-mcp-memory-sqlite-migrate --source ~/.memory/global.db --project global --dest ~/.memory/memory.db
Migrate project memory (run from project root):
alexfayers-mcp-memory-sqlite-migrate --source .memory/project.db --project "$(basename "$PWD")" --dest ~/.memory/memory.db
The tool will:
- Create the destination DB if it doesn't exist
- Run all schema migrations automatically
- Import entities with their observations
- Import relations between entities
- Skip entities with no observations
- Deduplicate observations that already exist
Development
# Install dependencies
pnpm install
# Build
pnpm run build
# Run in development mode
pnpm run dev
License
MIT
Credits
Built with:
- better-sqlite3 - Fast SQLite driver
- tmcp - MCP server framework
Originally by Scott Spence.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。