Memory MCP Server
Servidor MCP de Memoria
Un servidor del Protocolo de Contexto de Modelo (MCP) que proporciona funcionalidad de grafo de conocimiento para gestionar entidades, relaciones y observaciones en memoria, con reglas de validación estrictas para mantener la consistencia de los datos.
Instalación
Instala el servidor en Claude Desktop:
mcp install main.py -v MEMORY_FILE_PATH=/path/to/memory.jsonlRelated MCP server: MCP Memory Server - HTTP Streaming
Reglas de Validación de Datos
Nombres de Entidad
Deben comenzar con una letra minúscula
Pueden contener letras minúsculas, números y guiones
Longitud máxima de 100 caracteres
Deben ser únicos dentro del grafo
Ejemplos de nombres válidos:
python-project,meeting-notes-2024,user-john
Tipos de Entidad
Se admiten los siguientes tipos de entidad:
person: Entidades humanasconcept: Ideas o principios abstractosproject: Iniciativas o tareas de trabajodocument: Cualquier forma de documentacióntool: Herramientas o utilidades de softwareorganization: Empresas o gruposlocation: Lugares físicos o virtualesevent: Sucesos limitados en el tiempo
Observaciones
Cadenas no vacías
Longitud máxima de 500 caracteres
Deben ser únicas por entidad
Deben ser declaraciones objetivas y basadas en hechos
Incluir marca de tiempo cuando sea relevante
Relaciones
Se admiten los siguientes tipos de relación:
knows: Conexión de persona a personacontains: Relación padre/hijouses: Entidad que utiliza otra entidadcreated: Relación de autoría/creaciónbelongs-to: Pertenencia/propiedaddepends-on: Relación de dependenciarelated-to: Relación genérica
Reglas de relación adicionales:
Tanto la entidad de origen como la de destino deben existir
No se permiten relaciones autorreferenciales
No se permiten dependencias circulares
Se deben utilizar tipos de relación predefinidos
Uso
El servidor proporciona herramientas para gestionar un grafo de conocimiento:
Obtener Entidad
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}")Obtener Grafo
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}")Crear Entidades
# 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}")Añadir Observación
# 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}")Crear Relación
# 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}")Buscar en Memoria
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}")La funcionalidad de búsqueda admite:
Consultas temporales (p. ej., "más reciente", "último", "latest")
Consultas de actividad (p. ej., "entrenamiento", "ejercicio")
Búsquedas generales de entidades
Coincidencia difusa con un umbral de similitud del 80%
Búsqueda ponderada a través de:
Nombres de entidad (peso: 1.0)
Tipos de entidad (peso: 0.8)
Observaciones (peso: 0.6)
Eliminar Entidades
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}")Eliminar Relación
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}")Vaciar Memoria
result = await session.call_tool("flush_memory", {})
if not result.success:
print(f"Error flushing memory: {result.error}")Tipos de Error
El servidor utiliza los siguientes tipos de error:
NOT_FOUND: Entidad o recurso no encontradoVALIDATION_ERROR: Datos de entrada no válidosINTERNAL_ERROR: Error del lado del servidorALREADY_EXISTS: El recurso ya existeINVALID_RELATION: Relación no válida entre entidades
Modelos de Respuesta
Todas las herramientas devuelven respuestas tipadas utilizando estos modelos:
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] = NoneDesarrollo
Ejecución de Pruebas
pytest tests/Añadir Nuevas Funcionalidades
Actualiza las reglas de validación en
validation.pyAñade pruebas en
tests/test_validation.pyImplementa los cambios en
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