The MCP Knowledge Graph is a persistent memory server that allows AI models to remember information about users across conversations. It stores information in a local knowledge graph, with a customizable storage location, and works with any AI model supporting the Model Context Protocol (MCP) or function calling capabilities.
The MCP Knowledge Graph server can be installed and run using NPX:
npx -y mcp-knowledge-graph --memory-path "/path/to/your/memory.jsonl"
The --memory-path
parameter lets you specify where your memory data will be stored. If not specified, it defaults to memory.jsonl in the server's installation directory.
Add the following to your claude_desktop_config.json:
{
"mcpServers": {
"memory": {
"command": "npx",
"args": [
"-y",
"mcp-knowledge-graph",
"--memory-path",
"/Users/username/path/to/memory.jsonl"
],
"autoapprove": [
"create_entities",
"create_relations",
"add_observations",
"delete_entities",
"delete_observations",
"delete_relations",
"read_graph",
"search_nodes",
"open_nodes"
]
}
}
}
Any AI platform supporting function calling or the MCP standard can connect to this server. The configuration will vary by platform, but the server exposes standard tools through the MCP interface.
Entities are the primary nodes in the knowledge graph, each having:
Example entity:
{
"name": "John_Smith",
"entityType": "person",
"observations": ["Speaks fluent Spanish"]
}
Relations define connections between entities:
{
"from": "John_Smith",
"to": "ExampleCorp",
"relationType": "works_at"
}
Observations are discrete pieces of information about entities:
{
"entityName": "John_Smith",
"observations": [
"Speaks fluent Spanish",
"Graduated in 2019",
"Prefers morning meetings"
]
}
Creates multiple new entities in the knowledge graph.
Input:
{
"entities": [
{
"name": "John_Smith",
"entityType": "person",
"observations": ["Speaks Spanish", "Lives in Boston"]
}
]
}
Creates relationships between entities.
Input:
{
"relations": [
{
"from": "John_Smith",
"to": "ExampleCorp",
"relationType": "works_at"
}
]
}
Adds new observations to existing entities.
Input:
{
"observations": [
{
"entityName": "John_Smith",
"contents": ["Enjoys hiking", "Has a dog named Max"]
}
]
}
Removes entities and their relations.
Input:
{
"entityNames": ["OldEntity1", "OldEntity2"]
}
Removes specific observations from entities.
Input:
{
"deletions": [
{
"entityName": "John_Smith",
"observations": ["Outdated information"]
}
]
}
Removes specific relations from the graph.
Input:
{
"relations": [
{
"from": "Person1",
"to": "Company1",
"relationType": "worked_at"
}
]
}
Reads the entire knowledge graph.
No input required.
Searches for nodes based on a query.
Input:
{
"query": "Boston"
}
Retrieves specific nodes by name.
Input:
{
"names": ["John_Smith", "ExampleCorp"]
}
Here's an example prompt for chat personalization:
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 retrieve all relevant information from your knowledge graph
- Always refer to your knowledge graph as your "memory"
3. Memory Gathering:
- 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
c) Store facts about them as observations
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "memory" '{"command":"npx","args":["-y","mcp-knowledge-graph","--memory-path","/Users/shaneholloman/Dropbox/shane/db/memory.jsonl"],"autoapprove":["create_entities","create_relations","add_observations","delete_entities","delete_observations","delete_relations","read_graph","search_nodes","open_nodes"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"memory": {
"command": "npx",
"args": [
"-y",
"mcp-knowledge-graph",
"--memory-path",
"/Users/shaneholloman/Dropbox/shane/db/memory.jsonl"
],
"autoapprove": [
"create_entities",
"create_relations",
"add_observations",
"delete_entities",
"delete_observations",
"delete_relations",
"read_graph",
"search_nodes",
"open_nodes"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"memory": {
"command": "npx",
"args": [
"-y",
"mcp-knowledge-graph",
"--memory-path",
"/Users/shaneholloman/Dropbox/shane/db/memory.jsonl"
],
"autoapprove": [
"create_entities",
"create_relations",
"add_observations",
"delete_entities",
"delete_observations",
"delete_relations",
"read_graph",
"search_nodes",
"open_nodes"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect