Memory Graph Configuration Guide

May 8, 2025 ยท View on GitHub

This guide covers all configuration options for the Memory Graph MCP server, including environment variables, storage options, transport types, and special modes like strict mode.

Table of Contents

  1. Environment Variables
  2. Storage Configuration
  3. Transport Configuration
  4. Strict Mode
  5. MCP Configuration Examples

Environment Variables

The Memory Graph MCP server can be configured using the following environment variables:

General Configuration

VariableDescriptionDefaultExample
MEMORY_DIRDirectory to store memory files./data/path/to/data
MEMORY_FILESComma-separated list of specific memory files to use(none)general.json,work.json
LOAD_ALL_FILESLoad all JSON files in the storage directoryfalsetrue
DEFAULT_PATHDefault path for storing memories//memories
STRICT_MODEEnsure all logging goes to stderrfalsetrue

Storage Configuration

VariableDescriptionDefaultExample
STORAGE_TYPEStorage backend to use (json, sqlite, or mariadb)jsonsqlite

MariaDB Configuration

These variables are only used when STORAGE_TYPE=mariadb:

VariableDescriptionDefaultExample
MARIADB_HOSTDatabase server hostnamelocalhostdb.example.com
MARIADB_PORTDatabase server port33063307
MARIADB_USERDatabase usernamerootmemory_user
MARIADB_PASSWORDDatabase password(empty)secure_password
MARIADB_DATABASEDatabase namememory_graphmy_memory_db
MARIADB_CONNECTION_LIMITMaximum connections in pool1020

Transport Configuration

VariableDescriptionDefaultExample
TRANSPORT_TYPECommunication transport (STDIO or HTTP)STDIOHTTP
PORTPort number for HTTP transport(required)3000
HOSTHost address for HTTP transport127.0.0.10.0.0.0

Storage Configuration

The Memory Graph MCP supports three storage backends:

JSON Storage

The simplest storage option, using JSON files:

STORAGE_TYPE=json
  • One JSON file per domain in the memories/ directory
  • Good for smaller datasets and simple deployments
  • Easy to inspect and manually edit if needed

SQLite Storage

A more efficient database storage option:

STORAGE_TYPE=sqlite
  • Single SQLite database file for all domains
  • Better performance for large datasets
  • Full-text search capabilities
  • More efficient memory usage
  • Good for local deployments

MariaDB Storage

A production-ready database storage option:

STORAGE_TYPE=mariadb
MARIADB_HOST=localhost
MARIADB_PORT=3306
MARIADB_USER=memory_user
MARIADB_PASSWORD=secure_password
MARIADB_DATABASE=memory_graph
  • Uses a MariaDB/MySQL database server
  • Ideal for large-scale deployments
  • Full-text search capabilities
  • Better scalability and concurrency support
  • Suitable for deployments with high load or multiple concurrent users

For more details on storage options and how to convert between them, see the Storage Switching Guide.

Transport Configuration

The Memory Graph MCP supports two transport types:

STDIO Transport

The default transport, suitable for direct MCP integration:

TRANSPORT_TYPE=STDIO
  • Simple stdin/stdout communication
  • No network configuration required
  • Used by default when integrating with AI assistants

HTTP Transport

A network-based transport suitable for remote connections:

TRANSPORT_TYPE=HTTP
PORT=3000
HOST=127.0.0.1
  • RESTful API over HTTP
  • Accessible over the network
  • Suitable for multi-user deployments
  • Allows connection from multiple clients

Strict Mode

Strict mode ensures clean JSON-RPC communication by redirecting all logging to stderr instead of stdout. This prevents parsing errors in MCP clients that expect only valid JSON-RPC messages on stdout.

Problem Addressed

Some MCP clients have difficulty handling mixed output on stdio where both error messages and informational logging get mingled in the JSON-RPC stream. This can lead to errors like:

SyntaxError: Unexpected token 'S', "STORAGE_TYPE: sqlite" is not valid JSON

Enabling Strict Mode

To enable strict mode, set the STRICT_MODE environment variable to true:

STRICT_MODE=true

How It Works

When strict mode is enabled:

  1. All proper JSON-RPC communication goes to stdout
  2. All informational logging is redirected to stderr

This implementation ensures that the stdout stream contains only valid JSON-RPC messages, while all logging information is sent to stderr.

MCP Configuration Examples

Basic Configuration with STDIO

{
  "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": []
    }
  }
}

HTTP Transport Configuration

{
  "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": []
    }
  }
}

Docker with MariaDB Configuration

{
  "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": []
    }
  }
}

For a better user experience, consider auto-approving these common tools:

"autoApprove": [
  "store_memory",
  "recall_memories",
  "list_domains",
  "select_domain",
  "generate_mermaid_graph"
]

This allows the AI assistant to use these tools without requiring explicit user approval each time.