mcp memory custom
A customized MCP memory server that enables creation and management of a knowledge graph with features like custom memory paths and timestamping for capturing interactions via language models.
A customized MCP memory server that enables creation and management of a knowledge graph with features like custom memory paths and timestamping for capturing interactions via language models.
This project adds new features to the Memory server offered by the MCP team. It allows for the creation and management of a knowledge graph that captures interactions via a language model (LLM).
To install Knowledge Graph Memory Server for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @BRO3886/mcp-memory-custom --client claude
git clone [email protected]:BRO3886/mcp-memory-custom.git
cd mcp-memory-custom
npm install
Before running the server, you can set the MEMORY_FILE_PATH
environment variable to specify the path for the memory file. If not set, the server will default to using memory.json
in the same directory as the script.
Add this to your claude_desktop_config.json
/ .cursor/mcp.json
file:
{
"mcpServers": {
"memory": {
"command": "node",
"args": ["/path/to/mcp-memory-custom/dist/index.js"]
}
}
}
System Prompt changes:
Follow these steps for each interaction:
1. The memoryFilePath for this project is /path/to/memory/project_name.json - always pass this path to the memory file operations (when creating entities, relations, or retrieving memory etc.)
2. User Identification:
- You should assume that you are interacting with default_user
- If you have not identified default_user, proactively try to do so.
3. Memory Retrieval:
- Always begin your chat by saying only "Remembering..." and retrieve all relevant information from your knowledge graph
- Always refer to your knowledge graph as your "memory"
4. 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)
5. 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, add timestamps to wherever required. You can get current timestamp via get_current_time
b) Connect them to the current entities using relations
c) Store facts about them as observations, add timestamps to observations via get_current_time
IMPORTANT: Provide a helpful and engaging response, asking relevant questions to encourage user engagement. Update the memory during the interaction, if required, based on the new information gathered (point 4).
To start the Knowledge Graph Memory Server, run:
npm run build
node dist/index.js
The server will listen for requests via standard input/output.
The server exposes several tools that can be called with specific parameters:
[
{
"description": "Get the current time",
"inputSchema": {
"properties": {},
"type": "object"
},
"name": "get_current_time"
},
{
"description": "Set the memory file path",
"inputSchema": {
"properties": {
"memoryFilePath": {
"description": "Absolute path to the memory file",
"type": "string"
}
},
"required": [
"memoryFilePath"
],
"type": "object"
},
"name": "set_memory_file_path"
},
{
"description": "Create multiple new entities in the knowledge graph",
"inputSchema": {
"properties": {
"entities": {
"items": {
"properties": {
"entityType": {
"description": "The type of the entity",
"type": "string"
},
"name": {
"description": "The name of the entity",
"type": "string"
},
"observations": {
"description": "An array of observation contents associated with the entity",
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"name",
"entityType",
"observations"
],
"type": "object"
},
"type": "array"
}
},
"required": [
"entities"
],
"type": "object"
},
"name": "create_entities"
},
{
"description": "Create multiple new relations between entities in the knowledge graph. Relations should be in active voice",
"inputSchema": {
"properties": {
"relations": {
"items": {
"properties": {
"from": {
"description": "The name of the entity where the relation starts",
"type": "string"
},
"relationType": {
"description": "The type of the relation",
"type": "string"
},
"to": {
"description": "The name of the entity where the relation ends",
"type": "string"
}
},
"required": [
"from",
"to",
"relationType"
],
"type": "object"
},
"type": "array"
}
},
"required": [
"relations"
],
"type": "object"
},
"name": "create_relations"
},
{
"description": "Add new observations to existing entities in the knowledge graph",
"inputSchema": {
"properties": {
"observations": {
"items": {
"properties": {
"contents": {
"description": "An array of observation contents to add",
"items": {
"type": "string"
},
"type": "array"
},
"entityName": {
"description": "The name of the entity to add the observations to",
"type": "string"
}
},
"required": [
"entityName",
"contents"
],
"type": "object"
},
"type": "array"
}
},
"required": [
"observations"
],
"type": "object"
},
"name": "add_observations"
},
{
"description": "Delete multiple entities and their associated relations from the knowledge graph",
"inputSchema": {
"properties": {
"entityNames": {
"description": "An array of entity names to delete",
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"entityNames"
],
"type": "object"
},
"name": "delete_entities"
},
{
"description": "Delete specific observations from entities in the knowledge graph",
"inputSchema": {
"properties": {
"deletions": {
"items": {
"properties": {
"entityName": {
"description": "The name of the entity containing the observations",
"type": "string"
},
"observations": {
"description": "An array of observations to delete",
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"entityName",
"observations"
],
"type": "object"
},
"type": "array"
}
},
"required": [
"deletions"
],
"type": "object"
},
"name": "delete_observations"
},
{
"description": "Delete multiple relations from the knowledge graph",
"inputSchema": {
"properties": {
"relations": {
"description": "An array of relations to delete",
"items": {
"properties": {
"from": {
"description": "The name of the entity where the relation starts",
"type": "string"
},
"relationType": {
"description": "The type of the relation",
"type": "string"
},
"to": {
"description": "The name of the entity where the relation ends",
"type": "string"
}
},
"required": [
"from",
"to",
"relationType"
],
"type": "object"
},
"type": "array"
}
},
"required": [
"relations"
],
"type": "object"
},
"name": "delete_relations"
},
{
"description": "Read the entire knowledge graph",
"inputSchema": {
"properties": {},
"type": "object"
},
"name": "read_graph"
},
{
"description": "Search for nodes in the knowledge graph based on a query",
"inputSchema": {
"properties": {
"query": {
"description": "The search query to match against entity names, types, and observation content",
"type": "string"
}
},
"required": [
"query"
],
"type": "object"
},
"name": "search_nodes"
},
{
"description": "Open specific nodes in the knowledge graph by their names",
"inputSchema": {
"properties": {
"names": {
"description": "An array of entity names to retrieve",
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"names"
],
"type": "object"
},
"name": "open_nodes"
}
]