Memory Graph
STDIOMCP server providing persistent memory through local knowledge graph with cross-session context
MCP server providing persistent memory through local knowledge graph with cross-session context
An MCP server that provides persistent memory capabilities through a local knowledge graph implementation. This server enables AI assistants to maintain context and information across chat sessions using a graph-based storage system.
# Install dependencies npm install # Build the TypeScript code npm run build # Clean build directory npm run clean
The server is available as a Docker container from GitHub Container Registry:
# Pull the image docker pull ghcr.io/aaronsb/memory-graph:latest # Or build locally ./scripts/build-local.sh
Run the container with your desired configuration:
# Using STDIO transport (default) docker run -v /path/to/data:/app/data \ -e MEMORY_DIR=/app/data \ -e TRANSPORT_TYPE=STDIO \ -e STORAGE_TYPE=sqlite \ ghcr.io/aaronsb/memory-graph:latest # Using HTTP transport docker run -v /path/to/data:/app/data \ -e MEMORY_DIR=/app/data \ -e TRANSPORT_TYPE=HTTP \ -e PORT=3000 \ -e HOST=127.0.0.1 \ -p 3000:3000 \ ghcr.io/aaronsb/memory-graph:latest # Using MariaDB storage docker run -v /path/to/data:/app/data \ --network=host \ -e MEMORY_DIR=/app/data \ -e STORAGE_TYPE=mariadb \ -e MARIADB_HOST=localhost \ -e MARIADB_PORT=3306 \ -e MARIADB_USER=memory_user \ -e MARIADB_PASSWORD=secure_password \ -e MARIADB_DATABASE=memory_graph \ ghcr.io/aaronsb/memory-graph:latest
For convenience, a Docker Compose configuration is provided:
# Start with Docker Compose docker-compose up -d # Stop services docker-compose down
# Start the server npm start # Run using custom configuration MEMORY_DIR=/path/to/data STORAGE_TYPE=sqlite npm start
The server can be configured using environment variables:
MEMORY_DIR: Directory to store memory files (default: ./data)MEMORY_FILES: Comma-separated list of specific memory files to useLOAD_ALL_FILES: Set to 'true' to load all JSON files in the storage directoryDEFAULT_PATH: Default path for storing memoriesSTRICT_MODE: Set to 'true' to ensure all logging goes to stderr, preventing interference with JSON-RPC communication on stdoutSTORAGE_TYPE: Storage backend to use (json, sqlite, or mariadb, default: json)STORAGE_TYPE=mariadb)MARIADB_HOST: Database server hostname (default: localhost)MARIADB_PORT: Database server port (default: 3306)MARIADB_USER: Database username (default: root)MARIADB_PASSWORD: Database password (default: empty)MARIADB_DATABASE: Database name (default: memory_graph)MARIADB_CONNECTION_LIMIT: Maximum number of connections in the pool (default: 10)TRANSPORT_TYPE: Communication transport to use (STDIO or HTTP, default: STDIO)PORT: Port number for HTTP transport (required when TRANSPORT_TYPE=HTTP)HOST: Host address for HTTP transport (default: 127.0.0.1, only used when TRANSPORT_TYPE=HTTP)To use this server with an AI assistant via MCP, add it to your MCP configuration file:
{ "mcpServers": { "memory-graph": { "command": "node", "args": ["/path/to/memory-graph/build/index.js"], "env": { "MEMORY_DIR": "/path/to/memory/storage", "STORAGE_TYPE": "sqlite", "STRICT_MODE": "true" }, "disabled": false, "autoApprove": [] } } }
{ "mcpServers": { "memory-graph": { "command": "node", "args": ["/path/to/memory-graph/build/index.js"], "env": { "MEMORY_DIR": "/path/to/memory/storage", "STORAGE_TYPE": "sqlite", "TRANSPORT_TYPE": "HTTP", "PORT": "3000", "STRICT_MODE": "true" }, "disabled": false, "autoApprove": [] } } }
{ "mcpServers": { "memory-graph": { "command": "docker", "args": [ "run", "--rm", "-i", "--network=host", "-v", "/path/to/data:/app/data", "-e", "MEMORY_DIR=/app/data", "-e", "STORAGE_TYPE=mariadb", "-e", "MARIADB_HOST=localhost", "-e", "MARIADB_PORT=3306", "-e", "MARIADB_USER=memory_user", "-e", "MARIADB_PASSWORD=secure_password", "-e", "MARIADB_DATABASE=memory_graph", "-e", "STRICT_MODE=true", "ghcr.io/aaronsb/memory-graph:latest" ], "disabled": false, "autoApprove": [] } } }
The Memory Graph MCP supports three storage backends:
JSON: Simple file-based storage (default)
memories/ directorySQLite: Database storage with improved performance
MariaDB: Production-ready database storage
To switch between storage types, set the STORAGE_TYPE environment variable to json, sqlite, or mariadb.
For detailed information about storage options, including how to convert between formats, see Storage Overview and Converting Between Storage Types.
The Memory Graph MCP provides the following tools:
select_domain: Switch to a different memory domainlist_domains: List all available memory domainscreate_domain: Create a new memory domainstore_memory: Store new information in the memory graphrecall_memories: Retrieve memories using various strategiesedit_memory: Edit an existing memory or move it to another domainforget_memory: Remove a memory from the graphgenerate_mermaid_graph: Generate a visual representation of memory relationshipssearch_memory_content: Full-text search capabilities (with SQLite and MariaDB backends)traverse_memories: Explore connections between memories across domainsFor detailed information about all tools and their parameters, see the Memory Tools Reference.
memory-graph/
├── src/
│ ├── graph/ # Knowledge graph implementation
│ ├── storage/ # Storage backends (JSON, SQLite, MariaDB)
│ ├── tools/ # MCP tool implementations
│ ├── types/ # TypeScript type definitions
│ └── index.ts # Main server entry
├── data/ # Memory storage (created at runtime)
└── docs/ # Project documentation
# Build the TypeScript code npm run build # Build local Docker image ./scripts/build-local.sh
# Run all tests npm test # Run tests in watch mode npm test:watch
# Convert from JSON to SQLite npx ts-node scripts/convert-storage.ts json2sqlite /path/to/json/data /path/to/sqlite/file.db # Convert from SQLite to JSON npx ts-node scripts/convert-storage.ts sqlite2json /path/to/sqlite/file.db /path/to/json/data # Convert from JSON to MariaDB npx ts-node scripts/convert-storage.ts json2mariadb /path/to/json/data "mariadb://user:password@localhost:3306/memory_graph"
MIT