MCP DuckDB Knowledge Graph Memory Server
Сервер памяти графа знаний MCP DuckDB
Форк-версия официального сервера памяти Knowledge Graph .
Установка
Установка через Smithery
Чтобы автоматически установить DuckDB Knowledge Graph Memory Server для Claude Desktop через Smithery :
npx -y @smithery/cli install @IzumiSy/mcp-duckdb-memory-server --client claudeРучная установка
В противном случае добавьте @IzumiSy/mcp-duckdb-memory-server в ваш claude_desktop_config.json вручную ( MEMORY_FILE_PATH необязателен)
{
"mcpServers": {
"graph-memory": {
"command": "npx",
"args": [
"-y",
"@izumisy/mcp-duckdb-memory-server"
],
"env": {
"MEMORY_FILE_PATH": "/path/to/your/memory.data"
}
}
}
}Данные, хранящиеся по этому пути, представляют собой файл базы данных DuckDB.
Докер
Строить
docker build -t mcp-duckdb-graph-memory .Бегать
docker run -dit mcp-duckdb-graph-memoryRelated MCP server: Knowledge Graph Memory Server
Использование
Используйте пример инструкции ниже.
Follow these steps for each interaction:
1. User Identification:
- You should assume that you are interacting with default_user
- If you have not identified default_user, proactively try to do so.
2. Memory Retrieval:
- Always begin your chat by saying only "Remembering..." and search relevant information from your knowledge graph
- Create a search query from user words, and search things from "memory". If nothing matches, try to break down words in the query at first ("A B" to "A" and "B" for example).
- Always refer to your knowledge graph as your "memory"
3. Memory
- While conversing with the user, be attentive to any new information that falls into these categories:
a) Basic Identity (age, gender, location, job title, education level, etc.)
b) Behaviors (interests, habits, etc.)
c) Preferences (communication style, preferred language, etc.)
d) Goals (goals, targets, aspirations, etc.)
e) Relationships (personal and professional relationships up to 3 degrees of separation)
4. Memory Update:
- If any new information was gathered during the interaction, update your memory as follows:
a) Create entities for recurring organizations, people, and significant events
b) Connect them to the current entities using relations
b) Store facts about them as observationsМотивация
Этот проект улучшает исходный сервер памяти MCP Knowledge Graph, заменяя его бэкэнд на DuckDB.
Почему DuckDB?
Оригинальный сервер памяти MCP Knowledge Graph использовал файл JSON в качестве хранилища данных и выполнял поиск в памяти. Хотя этот подход хорошо работает для небольших наборов данных, он создает несколько проблем:
Производительность : производительность поиска в памяти снижается по мере роста набора данных.
Масштабируемость : использование памяти значительно увеличивается при обработке большого количества сущностей и отношений.
Гибкость запросов : сложные запросы и условные поиски трудно реализовать.
Целостность данных : обеспечение атомарности транзакций и операций CRUD является сложной задачей.
Для решения следующих задач была выбрана DuckDB:
Быстрая обработка запросов : DuckDB оптимизирован для аналитических запросов и хорошо работает даже с большими наборами данных.
Интерфейс SQL : стандартный SQL может использоваться для легкого выполнения сложных запросов.
Поддержка транзакций : поддерживает обработку транзакций для сохранения целостности данных.
Возможности индексирования : позволяет создавать индексы для повышения производительности поиска.
Встроенная база данных : работает внутри приложения, не требуя внешнего сервера базы данных.
Подробности реализации
В данной реализации в качестве внутренней системы хранения данных используется DuckDB, при этом особое внимание уделяется двум ключевым аспектам:
Структура базы данных
Граф знаний хранится в реляционной структуре базы данных, как показано ниже:
erDiagram
ENTITIES {
string name PK
string entityType
}
OBSERVATIONS {
string entityName FK
string content
}
RELATIONS {
string from_entity FK
string to_entity FK
string relationType
}
ENTITIES ||--o{ OBSERVATIONS : "has"
ENTITIES ||--o{ RELATIONS : "from"
ENTITIES ||--o{ RELATIONS : "to"Такая конструкция схемы обеспечивает эффективное хранение и извлечение компонентов графа знаний, сохраняя при этом взаимосвязи между сущностями, наблюдениями и отношениями.
Реализация нечеткого поиска
Реализация объединяет SQL-запросы с Fuse.js для гибкого поиска сущностей:
Запросы DuckDB SQL извлекают базовые данные из базы данных
Fuse.js предоставляет возможности нечеткого сопоставления на основе извлеченных данных
Этот гибридный подход позволяет выполнять как структурированные запросы, так и гибкое сопоставление текста.
Результаты поиска включают как точные, так и частичные совпадения, ранжированные по релевантности.
Разработка
Настраивать
pnpm installТестирование
pnpm testЛицензия
Данный проект лицензирован по лицензии MIT — подробности см. в файле LICENSE .
Available Tools
8 toolsadd_observationsC
Add new observations to existing entities in the knowledge graph
Inputs: observations (required).
create_entitiesC
Create multiple new entities in the knowledge graph
Inputs: entities (required).
create_relationsC
Create multiple new relations between entities in the knowledge graph. Relations should be in active voice
Inputs: relations (required).
delete_entitiesC
Delete multiple entities and their associated relations from the knowledge graph
Inputs: entityNames (required).
delete_observationsC
Delete specific observations from entities in the knowledge graph
Inputs: deletions (required).
delete_relationsC
Delete multiple relations from the knowledge graph
Inputs: relations (required).
open_nodesC
Open specific nodes in the knowledge graph by their names
Inputs: names (required).
search_nodesC
Search for nodes in the knowledge graph based on a query
Inputs: query (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Most tools have distinct purposes targeting different aspects of the knowledge graph (entities, relations, observations, nodes), though 'open_nodes' and 'search_nodes' could potentially overlap in functionality if opening involves searching. The descriptions clarify that 'open_nodes' accesses specific named nodes while 'search_nodes' performs query-based lookup, but agents might still confuse them in some scenarios.
All tools follow a consistent verb_noun pattern with snake_case naming (e.g., add_observations, create_entities, delete_relations). The verbs are clear and appropriate for the actions (add, create, delete, open, search), and there are no deviations in style or convention throughout the set.
With 8 tools, this server is well-scoped for a knowledge graph memory system. Each tool appears to serve a specific and necessary function for managing entities, relations, observations, and nodes, without being overly sparse or bloated. The count aligns well with the domain's typical CRUD and query operations.
The tool set provides strong coverage for core knowledge graph operations, including creation, deletion, and querying of entities, relations, and observations. A minor gap is the lack of update tools (e.g., update_entities or update_relations), which might require workarounds like delete-and-recreate, but the surface is otherwise comprehensive for the stated purpose.
Maintenance
Related MCP Connectors
Persistent, outcome-grounded episodic memory for Claude. 14ms CPU retrieval, no GPU, no vector DB.
Memory for Claude, ChatGPT and other AI apps: notes and docs as a searchable graph, EU-hosted.
Persistent memory for Claude Code and Cursor. Stop re-explaining your project every session.
Persistent memory and knowledge graph for AI assistants — keyword + vector + graph search.
Related MCP Servers
- AlicenseAqualityDmaintenanceAn improved implementation of persistent memory using a local knowledge graph with a customizable --memory-path. This lets Claude remember information about the user across chats.10887MIT
- AlicenseBqualityFmaintenanceA persistent memory implementation using a local knowledge graph that lets Claude remember information about users across conversations.96MIT
- AlicenseNot gradedqualityDmaintenanceA persistent memory system using a local knowledge graph that enables Claude to remember information about users across chats, with advanced search, graph traversal, and filtering capabilities for entities, relations, and observations.MIT
- AlicenseNot gradedqualityDmaintenanceA persistent memory server for Claude Code that captures session context and tool outputs to inject relevant history into future sessions. It enables long-term recall through semantic search and automatic context management, allowing for more consistent and context-aware coding interactions.253AGPL 3.0