Local Knowledge Graph Memory Server for MCP
An improved implementation of persistent memory using a local knowledge graph with a customizable --memory-path
.
Quick machine-readable installation sequence for automated setup:
# Copy custom implementation
cp -r ~/local/dev/0xsalt/repos/mcp-knowledge-graph .
cd mcp-knowledge-graph/
# Build and install
npm install
npm run build
node dist/index.js --help
# Make globally available
npm link
mcp-knowledge-graph --help
# Configure Claude Code MCP
claude mcp add-json memory '{"command": "mcp-knowledge-graph", "args": ["--memory-path", "/home/username/.claude/memory.jsonl"], "autoapprove": ["create_entities", "create_relations", "add_observations", "delete_entities", "delete_observations", "delete_relations", "read_graph", "search_nodes", "open_nodes"]}' -s user
# Verify connection
claude mcp list
Expected result: MCP server shows as "âś“ Connected" using global memory path /home/username/.claude/memory.jsonl
Works with any AI model or client that supports the Model Context Protocol (MCP) or function-calling interfaces. Use a stable path so memory survives restarts and npx cache wipes.
Note
This repository is a public fork and is currently under active development.
Features are being added, but things may be broken at the moment.
You’re welcome to clone and experiment.
Setup instructions are currently messy so walk through them carefully until I can clean them up.
For the original, stable version, see: upstream repository.
Note
- Original: Memory Server, Anthropic
- Fork: shaneholloman/mcp-knowledge-graph
- avoids the ephemeral npx install method
- This repo: maintains persistent, explicit storage via
--memory-path
Ensure you have the following installed:
- Node.js (version 18 or higher)
- npm (comes with Node.js)
Verify your installation:
node --version
npm --version
# Clone the repository
git clone https://github.com/0xsalt/mcp-knowledge-graph.git
cd mcp-knowledge-graph
# Install dependencies
npm install
# Build the project
npm run build
# Verify the build was successful
node dist/index.js --help
Expected output:
MCP Knowledge Graph Server
Usage: node dist/index.js [options]
Options:
--memory-path <path> Custom path for memory.jsonl file
--help, -h Show this help message
Examples:
node dist/index.js --memory-path ~/.claude/memory.jsonl
node dist/index.js --memory-path ./my-memory.jsonl
Default memory location: ./memory.jsonl (relative to current working directory)
# Make the command available globally
npm link
# Verify global installation
mcp-knowledge-graph --help
Troubleshooting: If mcp-knowledge-graph
command is not found after npm link
, try:
- Restart your terminal
- Check if your npm global bin is in your PATH
- Use the full path:
node /path/to/mcp-knowledge-graph/dist/index.js
Pick where you want to store your memory file:
- Local (project folder):
./memory.jsonl
(default) - System-wide:
/home/username/.claude/memory.jsonl
(replaceusername
) - Custom location:
/your/custom/path/memory.jsonl
Create the directory if it doesn't exist:
# For system-wide
mkdir -p ~/.claude
# For custom path
mkdir -p /your/custom/directory
Note: The memory file will be created automatically when the server first runs. You don't need to create it manually.
If you used npm link
(cleaner approach):
{
"mcpServers": {
"memory": {
"command": "mcp-knowledge-graph",
"args": [
"--memory-path",
"/home/username/.claude/memory.jsonl"
],
"autoapprove": [
"mcp__memory__create_entities",
"mcp__memory__create_relations",
"mcp__memory__add_observations",
"mcp__memory__delete_entities",
"mcp__memory__delete_observations",
"mcp__memory__delete_relations",
"mcp__memory__read_graph",
"mcp__memory__search_nodes",
"mcp__memory__open_nodes"
]
}
}
}
If you didn't use npm link
(full path approach):
{
"mcpServers": {
"memory": {
"command": "node",
"args": [
"/full/path/to/mcp-knowledge-graph/dist/index.js",
"--memory-path",
"/home/username/.claude/memory.jsonl"
],
"autoapprove": [
"mcp__memory__create_entities",
"mcp__memory__create_relations",
"mcp__memory__add_observations",
"mcp__memory__delete_entities",
"mcp__memory__delete_observations",
"mcp__memory__delete_relations",
"mcp__memory__read_graph",
"mcp__memory__search_nodes",
"mcp__memory__open_nodes"
]
}
}
}
Examples for different memory locations:
- Local:
"--memory-path", "./memory.jsonl"
- System-wide:
"--memory-path", "/home/username/.claude/memory.jsonl"
- Custom:
"--memory-path", "/your/custom/path/memory.jsonl"
Important: Replace /full/path/to/mcp-knowledge-graph
with the actual path where you cloned the repository.
Configure the MCP server using the claude mcp add-json
command:
If you used npm link
(global installation):
claude mcp add-json memory '{"command": "mcp-knowledge-graph", "args": ["--memory-path", "/home/username/.claude/memory.jsonl"], "autoapprove": ["create_entities", "create_relations", "add_observations", "delete_entities", "delete_observations", "delete_relations", "read_graph", "search_nodes", "open_nodes"]}' -s user
If you didn't use npm link
(local installation):
# Replace /full/path/to/mcp-knowledge-graph with your actual project path
claude mcp add-json memory '{"command": "node", "args": ["/full/path/to/mcp-knowledge-graph/dist/index.js", "--memory-path", "/home/username/.claude/memory.jsonl"], "autoapprove": ["create_entities", "create_relations", "add_observations", "delete_entities", "delete_observations", "delete_relations", "read_graph", "search_nodes", "open_nodes"]}' -s user
- Verify the configuration:
claude mcp list
Expected output:
memory: node dist/index.js --memory-path /home/username/.claude/memory.jsonl - âś“ Connected
Examples for different memory locations:
- Local:
"--memory-path", "./memory.jsonl"
- System-wide:
"--memory-path", "/home/username/.claude/memory.jsonl"
- Custom:
"--memory-path", "/your/custom/path/memory.jsonl"
Important Configuration Notes:
- Replace
/home/username/.claude/memory.jsonl
with your chosen memory path - Replace
/full/path/to/mcp-knowledge-graph
with the actual path where you cloned the repository - The
autoapprove
array ensures all memory operations are automatically approved without prompting - The
-s user
flag ensures the configuration is available from any directory globally, making the MCP server accessible across all projects
Additional Claude Code Configuration:
Add the following to your Claude Code ~/.claude/settings.json
to auto-approve memory operations and avoid permission prompts:
"permissions": {
"allow": [
"mcp__memory__read_graph",
"mcp__memory__add_observations",
"mcp__memory__create_entities",
"mcp__memory__create_relations",
"mcp__memory__delete_entities",
"mcp__memory__delete_observations",
"mcp__memory__delete_relations",
"mcp__memory__search_nodes",
"mcp__memory__open_nodes",
"mcp__memory__query_relationships_by_type",
"mcp__memory__find_relationship_paths",
"mcp__memory__get_relationship_suggestions"
]
}
Why -s user
scope? This makes the memory system available from any directory, enabling persistent memory that works across all your projects and conversations.
For other MCP-compatible platforms (Cursor, VS Code with MCP extensions, etc.), refer to their specific MCP configuration documentation. The server configuration remains the same - just adapt the config format to your platform.
For optimal memory usage across different project types, see the Adaptive Memory Management Guide which provides:
- Universal memory categories that adapt to any project context
- Entity addition criteria to prevent information overload
- Integration instructions for project-specific customization
In Claude Projects, you can set custom instructions by:
- Navigate to claude.ai/projects
- Click "+ New Project" in the upper right corner
- Click "Set Custom Instructions" inside your project
- Copy and paste the following text directly into the custom instructions field:
For Claude CLI users, you can set up custom instructions in multiple ways:
Global Instructions (applies to all projects):
Create or edit ~/.claude/CLAUDE.md
and paste the following text:
Project-Specific Instructions:
Create .claude/CLAUDE.md
in your project directory and paste the following text:
Follow these steps for each interaction:
1. User Identification:
- You should assume that you are interacting with default_user
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 described in mcp-knowledge-graph.mdc Section 3: Context, Conventions, Decisions, Habits, Identity, Memory, Objectives, Projects, Relationships, Resources, Retros, or Risks.
4. Memory Update:
- If any new information was gathered during the interaction, update your memory as follows:
a) Create entities for categories described in mcp-knowledge-graph.mdc Section 3
b) Connect them to the current entities using relation tags defined in mcp-knowledge-graph.mdc Section 3
c) Categories into the above categories and link where relevant
For agentic coding partners or other platforms, refer to: mcp-knowledge-graph.mdc
Set up your knowledge graph with the comprehensive TELOS taxonomy structure:
# Initialize TELOS taxonomy with sample data (uses memory path from MCP configuration)
npm run setup:taxonomy -- --memory-path /home/username/.claude/memory.jsonl
# Validate the setup (optional)
npm run validate:taxonomy -- --memory-path /home/username/.claude/memory.jsonl
Important: Replace /home/username/.claude/memory.jsonl
with the same path you configured in your MCP server setup.
What this does:
- Creates 12 sample entities covering all TELOS categories
- Establishes 15 relationships demonstrating all 7 relationship types
- Sets up your
memory.jsonl
file with a working knowledge graph - Provides examples of Identity, Projects, Habits, Resources, Objectives, etc.
Expected output:
PASS TELOS taxonomy setup completed successfully!
Memory file created: ./memory.jsonl
Created 12 entities and 15 relationships
Your TELOS knowledge graph is ready to use!
Check that your MCP server is properly configured:
# For Claude CLI
claude mcp list
# Expected output:
# memory: mcp-knowledge-graph --memory-path /path/to/memory.jsonl - âś“ Connected
Start Claude and test the memory system:
# Start Claude CLI
claude
# Test the memory system (should work without prompts)
"What do you remember about me?"
Expected Response: The AI should respond with "Remembering..." and show you the sample TELOS entities you just created, including your default_user identity and the knowledge graph structure.
- Restart Claude Desktop
- Start a new conversation
- Ask: "What do you remember about me?"
Expected Response: The AI should respond with "Remembering..." and show you the sample TELOS entities you just created.
If MCP server shows as disconnected:
- Check that you built the project:
npm run build
- Verify the memory path exists and is writable
- Ensure you have Node.js 18+ installed
If Claude CLI shows "No MCP servers configured":
- CRITICAL: Run the
claude mcp add-json
command from Option B before testing - Verify with
claude mcp list
that the server shows as "âś“ Connected" - Check that the JSON syntax is correct
- Verify the command and args are valid
If Claude asks for permission to use tools:
- The
autoapprove
array in yourclaude mcp add-json
command is missing or incorrect - Re-run the
claude mcp add-json
command with the complete autoapprove configuration - Check that all tool names are spelled correctly (without
mcp__memory__
prefix)
If memory operations fail:
- Check file permissions on your memory path
- Ensure the directory exists and is writable
- Verify the memory file isn't corrupted
- Run
npm run validate:taxonomy
to check knowledge graph integrity - Test the server directly:
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "read_graph", "arguments": {}}}' | mcp-knowledge-graph --memory-path /your/path/memory.jsonl
If TELOS taxonomy setup fails:
- Ensure you've run
npm run build
first - Important: Use the
--memory-path
parameter to match your MCP server configuration - Check that the memory directory is writable
- Run
npm run validate:taxonomy -- --memory-path /your/path/memory.jsonl
to diagnose issues - Delete the memory file and rerun setup with the correct path
If Claude doesn't see your TELOS data:
- Verify the memory paths match between setup script and MCP server configuration
- Check
claude mcp list
to see the configured memory path - Ensure both setup and MCP server use the same
--memory-path
If you want to completely remove the MCP Knowledge Graph server and start fresh, follow these steps:
For Claude CLI:
# Remove the MCP server from Claude CLI
claude mcp remove memory -s local
# Verify it's removed
claude mcp list
For Claude Desktop:
- Remove the
mcpServers
section from yourclaude_desktop_config.json
- Or delete the entire
claude_desktop_config.json
file
# If you used npm link, unlink it
npm unlink mcp-knowledge-graph
# Verify it's removed
which mcp-knowledge-graph
# Remove your memory file (replace with your actual path)
rm /home/username/.claude/memory.jsonl
# Or remove the entire memory directory
rm -rf /home/username/.claude/
# Or remove custom memory location
rm /your/custom/path/memory.jsonl
# Remove the entire project directory
cd ..
rm -rf mcp-knowledge-graph/
# Or if you want to keep the project but start fresh
cd mcp-knowledge-graph
rm -rf dist/
rm -rf node_modules/
rm package-lock.json
If you want to completely clean Claude CLI's project configuration:
# Backup your global Claude CLI config first
cp ~/.claude.json ~/.claude.json.backup
# Remove the project-specific section from ~/.claude.json
# This requires manual editing to remove the project entry
# Check that MCP server is gone
claude mcp list
# Check that global command is gone
which mcp-knowledge-graph
# Check that memory file is gone
ls -la /home/username/.claude/memory.jsonl
Expected results:
claude mcp list
should show "No MCP servers configured"which mcp-knowledge-graph
should return nothing- Memory file should not exist
After complete removal, you can follow the Quick Start instructions from the beginning to reinstall everything fresh.
New in v1.0.3+: This version introduces a comprehensive relationship taxonomy based on the TELOS structure, supporting 7 distinct relationship types across 12 categories for rich semantic knowledge modeling.
supports
- Forward progress toward goals (default for most connections)enables
- Provides capability, resources, or toolsconstrains
- Limitations, boundaries, or restrictionsmentors
- Human relationships and guidance (people only)informs
- Knowledge, context, or information sharingreflects_on
- Retrospective analysis and learningthreatens
- Risk relationships and potential negative impacts
- Identity: Values, mission, principles
- Memory: Past experiences, lessons learned
- Resources: Tools, assets, capabilities
- Context: Environment, situation, constraints
- Conventions: Standards, processes, methodologies
- Objectives: Goals, targets, desired outcomes
- Projects: Active initiatives and implementations
- Habits: Routines, practices, regular behaviors
- Risks: Threats, concerns, potential issues
- DecisionJournal: Choices made and their reasoning
- Relationships: People, teams, stakeholder connections
- Retros: Reflections, reviews, feedback loops
The new taxonomy adds these relationship query capabilities:
query_relationships_by_type
- Filter relationships by typefind_relationship_paths
- Discover connection paths between entitiesget_relationship_suggestions
- Get AI-suggested relationship types
All entities now support automatic TELOS category detection and relationship validation.
For complete documentation, see docs/relationship-taxonomy.md
.
mcp-knowledge-graph
Entities are the primary nodes in the knowledge graph. Each entity has:
- A unique name (identifier)
- An entity type (e.g., "person", "organization", "event")
- A TELOS category (auto-detected or manually specified)
- A list of observations
Example:
{
"name": "John_Smith",
"entityType": "person",
"telosCategory": "Relationships",
"observations": ["Speaks fluent Spanish"]
}
Relations define directed connections between entities. They are always stored in active voice and describe how entities interact or relate to each other.
Example:
{
"from": "John_Smith",
"to": "ExampleCorp",
"relationType": "works_at"
}
Observations are discrete pieces of information about an entity. They are:
- Stored as strings
- Attached to specific entities
- Can be added or removed independently
- Should be atomic (one fact per observation)
Example:
{
"entityName": "John_Smith",
"observations": [
"Speaks fluent Spanish",
"Graduated in 2019",
"Prefers morning meetings"
]
}
-
create_entities
- Create multiple new entities in the knowledge graph
- Input:
entities
(array of objects)- Each object contains:
name
(string): Entity identifierentityType
(string): Type classificationtelosCategory
(string, optional): TELOS category (auto-detected if not provided)observations
(string[]): Associated observations
- Each object contains:
- Ignores entities with existing names
- Automatically detects TELOS categories based on content
-
create_relations
- Create multiple new relations between entities
- Input:
relations
(array of objects)- Each object contains:
from
(string): Source entity nameto
(string): Target entity namerelationType
(string): Relationship type (validates against TELOS taxonomy)
- Each object contains:
- Skips duplicate relations
- Validates relationship types against TELOS category matrix
- Auto-suggests valid relationship types for invalid combinations
-
add_observations
- Add new observations to existing entities
- Input:
observations
(array of objects)- Each object contains:
entityName
(string): Target entitycontents
(string[]): New observations to add
- Each object contains:
- Returns added observations per entity
- Fails if entity doesn't exist
-
delete_entities
- Remove entities and their relations
- Input:
entityNames
(string[]) - Cascading deletion of associated relations
- Silent operation if entity doesn't exist
-
delete_observations
- Remove specific observations from entities
- Input:
deletions
(array of objects)- Each object contains:
entityName
(string): Target entityobservations
(string[]): Observations to remove
- Each object contains:
- Silent operation if observation doesn't exist
-
delete_relations
- Remove specific relations from the graph
- Input:
relations
(array of objects)- Each object contains:
from
(string): Source entity nameto
(string): Target entity namerelationType
(string): Relationship type
- Each object contains:
- Silent operation if relation doesn't exist
-
read_graph
- Read the entire knowledge graph
- No input required
- Returns complete graph structure with all entities and relations
-
search_nodes
- Search for nodes based on query
- Input:
query
(string) - Searches across:
- Entity names
- Entity types
- Observation content
- Returns matching entities and their relations
-
open_nodes
- Retrieve specific nodes by name
- Input:
names
(string[]) - Returns:
- Requested entities
- Relations between requested entities
- Silently skips non-existent nodes
-
query_relationships_by_type
- Query relationships filtered by type
- Input:
relationshipType
(string) - Returns: All relationships of the specified type
- Supports all 7 TELOS relationship types
-
find_relationship_paths
- Find connection paths between two entities
- Input:
fromEntity
(string): Starting entity nametoEntity
(string): Target entity namemaxDepth
(number, optional): Maximum search depth (default: 3)
- Returns: Array of paths with relationship types
- Useful for discovering indirect connections
-
get_relationship_suggestions
- Get suggested relationship types between entities
- Input:
fromEntity
(string): Source entity nametoEntity
(string): Target entity name
- Returns: Suggested relationship types based on TELOS categories
- Includes category information for both entities
This server can be used with any AI platform that supports the Model Context Protocol (MCP) or function calling capabilities, including Claude, GPT, Llama, and others.
Add this to your claude_desktop_config.json:
{
"mcpServers": {
"memory": {
"command": "npx",
"args": [
"-y",
"mcp-knowledge-graph",
"--memory-path",
"/home/username/.claude/memory.jsonl"
],
"autoapprove": [
"mcp__memory__create_entities",
"mcp__memory__create_relations",
"mcp__memory__add_observations",
"mcp__memory__delete_entities",
"mcp__memory__delete_observations",
"mcp__memory__delete_relations",
"mcp__memory__read_graph",
"mcp__memory__search_nodes",
"mcp__memory__open_nodes"
]
},
}
}
Any AI platform that supports function calling or the MCP standard can connect to this server. The specific configuration will depend on the platform, but the server exposes standard tools through the MCP interface.
You can specify a custom path for the memory file:
{
"mcpServers": {
"memory": {
"command": "npx",
"args": [
"-y",
"mcp-knowledge-graph",
"--memory-path",
"/home/username/.claude/memory.jsonl"
],
"autoapprove": [
"mcp__memory__create_entities",
"mcp__memory__create_relations",
"mcp__memory__add_observations",
"mcp__memory__delete_entities",
"mcp__memory__delete_observations",
"mcp__memory__delete_relations",
"mcp__memory__read_graph",
"mcp__memory__search_nodes",
"mcp__memory__open_nodes"
]
},
}
}
If no path is specified, it will default to memory.jsonl in the server's installation directory.
The prompt for utilizing memory depends on the use case and the AI model you're using. Changing the prompt will help the model determine the frequency and types of memories created.
Here is an example prompt for chat personalization that can be adapted for any AI model. For Claude users, you could use this prompt in the "Custom Instructions" field of a Claude.ai Project. For other models, adapt it to their respective instruction formats.
Follow these steps for each interaction:
1. User Identification:
- You should assume that you are interacting with default_user
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"
- If your memory is empty on first use, immediately create a default_user entity and init a single entry that today their TELOS-structured knowledge graph began. No other content at this time.
3. Memory Gathering:
- While conversing with the user, be attentive to any new information that falls into these categories described in mcp-knowledge-graph.mdc Section 3: Context, Conventions, Decisions, Habits, Identity, Memory, Objectives, Projects, Relationships, Resources, Retros, or Risks.
4. Memory Update:
- If any new information was gathered during the interaction, update your memory as follows:
a) Create entities for categories described in mcp-knowledge-graph.mdc Section 3
b) Connect them to the current entities using relation tags defined in mcp-knowledge-graph.mdc Section 3
c) Categories into the above categories and link where relevant
This server implements the Model Context Protocol (MCP) standard, making it compatible with any AI model that supports function calling. The knowledge graph structure and API are model-agnostic, allowing for flexible integration with various AI platforms.
To integrate with other models:
- Configure the model to access the MCP server
- Ensure the model can make function calls to the exposed tools
- Adapt the system prompt to the specific model's instruction format
- Use the same knowledge graph operations regardless of the model
This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.