Memory MCP Server
Сервер памяти MCP
Сервер протокола контекста модели (MCP), который предоставляет функциональность графа знаний для управления сущностями, отношениями и наблюдениями в памяти со строгими правилами проверки для поддержания согласованности данных.
Установка
Установите сервер в Claude Desktop:
mcp install main.py -v MEMORY_FILE_PATH=/path/to/memory.jsonlRelated MCP server: MCP Memory Server - HTTP Streaming
Правила проверки данных
Имена сущностей
Должны начинаться со строчной буквы
Могут содержать строчные буквы, цифры и дефисы
Максимальная длина 100 символов
Должны быть уникальными в пределах графа
Примеры допустимых имен:
python-project,meeting-notes-2024,user-john
Типы сущностей
Поддерживаются следующие типы сущностей:
person: Людиconcept: Абстрактные идеи или принципыproject: Рабочие инициативы или задачиdocument: Любая форма документацииtool: Программные инструменты или утилитыorganization: Компании или группыlocation: Физические или виртуальные местаevent: События, ограниченные по времени
Наблюдения
Непустые строки
Максимальная длина 500 символов
Должны быть уникальными для каждой сущности
Должны быть фактическими и объективными утверждениями
Включайте временную метку, когда это уместно
Отношения
Поддерживаются следующие типы отношений:
knows: Связь между людьмиcontains: Отношение родитель/потомокuses: Сущность, использующая другую сущностьcreated: Отношение авторства/созданияbelongs-to: Принадлежность/владениеdepends-on: Отношение зависимостиrelated-to: Общее отношение
Дополнительные правила отношений:
Исходная и целевая сущности должны существовать
Самореферентные отношения не допускаются
Циклические зависимости не допускаются
Необходимо использовать предопределенные типы отношений
Использование
Сервер предоставляет инструменты для управления графом знаний:
Получить сущность
result = await session.call_tool("get_entity", {
"entity_name": "example"
})
if not result.success:
if result.error_type == "NOT_FOUND":
print(f"Entity not found: {result.error}")
elif result.error_type == "VALIDATION_ERROR":
print(f"Invalid input: {result.error}")
else:
print(f"Error: {result.error}")
else:
entity = result.data
print(f"Found entity: {entity}")Получить граф
result = await session.call_tool("get_graph", {})
if result.success:
graph = result.data
print(f"Graph data: {graph}")
else:
print(f"Error retrieving graph: {result.error}")Создать сущности
# Valid entity creation
entities = [
Entity(
name="python-project", # Lowercase with hyphens
entityType="project", # Must be a valid type
observations=["Started development on 2024-01-29"]
),
Entity(
name="john-doe",
entityType="person",
observations=["Software engineer", "Joined team in 2024"]
)
]
result = await session.call_tool("create_entities", {
"entities": entities
})
if not result.success:
if result.error_type == "VALIDATION_ERROR":
print(f"Invalid entity data: {result.error}")
else:
print(f"Error creating entities: {result.error}")Добавить наблюдение
# Valid observation
result = await session.call_tool("add_observation", {
"entity": "python-project",
"observation": "Completed initial prototype" # Must be unique for entity
})
if not result.success:
if result.error_type == "NOT_FOUND":
print(f"Entity not found: {result.error}")
elif result.error_type == "VALIDATION_ERROR":
print(f"Invalid observation: {result.error}")
else:
print(f"Error adding observation: {result.error}")Создать отношение
# Valid relation
result = await session.call_tool("create_relation", {
"from_entity": "john-doe",
"to_entity": "python-project",
"relation_type": "created" # Must be a valid type
})
if not result.success:
if result.error_type == "NOT_FOUND":
print(f"Entity not found: {result.error}")
elif result.error_type == "VALIDATION_ERROR":
print(f"Invalid relation data: {result.error}")
else:
print(f"Error creating relation: {result.error}")Поиск в памяти
result = await session.call_tool("search_memory", {
"query": "most recent workout" # Supports natural language queries
})
if result.success:
if result.error_type == "NO_RESULTS":
print(f"No results found: {result.error}")
else:
results = result.data
print(f"Search results: {results}")
else:
print(f"Error searching memory: {result.error}")Функциональность поиска поддерживает:
Временные запросы (например, "самый недавний", "последний")
Запросы активности (например, "тренировка", "упражнение")
Общий поиск сущностей
Нечеткий поиск с порогом сходства 80%
Взвешенный поиск по:
Именам сущностей (вес: 1.0)
Типам сущностей (вес: 0.8)
Наблюдениям (вес: 0.6)
Удалить сущности
result = await session.call_tool("delete_entities", {
"names": ["python-project", "john-doe"]
})
if not result.success:
if result.error_type == "NOT_FOUND":
print(f"Entity not found: {result.error}")
else:
print(f"Error deleting entities: {result.error}")Удалить отношение
result = await session.call_tool("delete_relation", {
"from_entity": "john-doe",
"to_entity": "python-project"
})
if not result.success:
if result.error_type == "NOT_FOUND":
print(f"Entity not found: {result.error}")
else:
print(f"Error deleting relation: {result.error}")Очистить память
result = await session.call_tool("flush_memory", {})
if not result.success:
print(f"Error flushing memory: {result.error}")Типы ошибок
Сервер использует следующие типы ошибок:
NOT_FOUND: Сущность или ресурс не найденVALIDATION_ERROR: Неверные входные данныеINTERNAL_ERROR: Ошибка на стороне сервераALREADY_EXISTS: Ресурс уже существуетINVALID_RELATION: Неверное отношение между сущностями
Модели ответов
Все инструменты возвращают типизированные ответы, используя следующие модели:
EntityResponse
class EntityResponse(BaseModel):
success: bool
data: Optional[Dict[str, Any]] = None
error: Optional[str] = None
error_type: Optional[str] = NoneGraphResponse
class GraphResponse(BaseModel):
success: bool
data: Optional[Dict[str, Any]] = None
error: Optional[str] = None
error_type: Optional[str] = NoneOperationResponse
class OperationResponse(BaseModel):
success: bool
error: Optional[str] = None
error_type: Optional[str] = NoneРазработка
Запуск тестов
pytest tests/Добавление новых функций
Обновите правила проверки в
validation.pyДобавьте тесты в
tests/test_validation.pyРеализуйте изменения в
knowledge_graph_manager.py
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseBqualityDmaintenanceScalable, high-performance knowledge graph memory system with semantic search, temporal awareness, and advanced relation management.Last updated1769424MIT
- Flicense-qualityDmaintenanceEnables creation and management of knowledge graphs with entities, relationships, and observations through HTTP streaming. Supports persistent storage, search functionality, and CRUD operations for building and querying interconnected knowledge bases.Last updated2
- AlicenseCqualityDmaintenanceProvides persistent memory and knowledge graph capabilities for AI assistants using local SQLite storage. Enables creating, searching, and managing entities, relationships, and observations with vector search support across conversations.Last updated78814MIT
- Alicense-qualityDmaintenanceProvides LLMs with persistent memory across conversations using a knowledge graph that stores entities, relationships, and observations with support for PostgreSQL or SQLite backends.Last updated7924MIT
Related MCP Connectors
Manage TTRPG campaigns: NPCs, locations, factions, quests, sessions, lore, and knowledge graphs.
AI knowledge graph for architecture, portfolio, and digital strategy management.
End-to-end agent-managed company brain. Docs, diagrams, plans, Knowledge Graph. Lean & affordable.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/evangstav/python-memory-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server