KuzuMem-MCP logo

KuzuMem-MCP

Community
Jakedismo

KuzuDB-powered memory bank for code agents built with TypeScript and follows MCP protocol

PublisherJakedismo
RepositoryKuzuMem-MCP
LanguageTypeScript
Forks
7
Stars
24
Available tools
0
Transport typestdio
Categories
Links
  • Connect tools to AI workflows

    KuzuMem-MCP exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    24 stars and 7 forks from the linked repository.

KuzuMem-MCP

A TypeScript implementation of a distributed memory bank as an MCP (Model Context Protocol) tool, storing memories in a KùzuDB graph database with repository and branch filtering capabilities. Branch isolation is achieved by using a graph-unique identifier for entities, enabling a centralized memory bank while allowing repository-specific and branch-specific views. Fully compliant with MCP specification for seamless integration with IDEs and AI agents.

Key Features

  • 🧠 AI-Powered Memory Optimization - Advanced reasoning models (OpenAI o3/o4-mini, Claude 4) with MCP sampling for intelligent memory management
  • 🛡️ Production-Ready Safety - Automatic snapshot system with guaranteed rollback capabilities
  • 🎯 Context-Aware Intelligence - MCP sampling analyzes actual memory state for adaptive optimization strategies
  • 🔧 Unified Tool Architecture - 12 consolidated tools covering all memory bank operations
  • 🧵 Thread-Safe Singleton Pattern - Ensures each resource is instantiated only once, with proper thread safety
  • 📊 Distributed Graph Structure - Follows the advanced memory bank specification using a KùzuDB graph
  • 🌿 Repository & Branch Awareness - All operations are contextualized by repository name and branch
  • ⚡ Asynchronous Operations - Uses async/await for better performance
  • 🔌 Multiple Access Interfaces - Access via CLI and multiple MCP server implementations
  • 💾 KùzuDB Backend - Utilizes KùzuDB for graph-based memory storage and querying
  • ✅ Fully MCP Compliant - All tools follow the Model Context Protocol for client integration
  • 📡 Progressive Results Streaming - Supports streaming for long-running graph operations
  • 🏠 Client Project Root Isolation - Each client project gets its own isolated database instance
  • 🧠 High-Reasoning Analysis - Leverages OpenAI HIGH reasoning and Anthropic extended thinking for memory optimization
  • 🗑️ Safe Bulk Operations - Advanced bulk deletion with dependency validation and dry-run capabilities

Unified Tools

The system currently broadcasts 12 unified tools that consolidate all memory bank operations:

  1. memory-bank - Initialize and manage memory bank metadata
  2. entity - Create, update, delete, and retrieve all entity types (components, decisions, rules, files, tags)
  3. introspect - Explore graph schema and metadata
  4. context - Manage work session context
  5. query - Unified search across contexts, entities, relationships, dependencies, governance, history, and tags
  6. associate - Create relationships between entities
  7. analyze - Run graph algorithms (PageRank, K-Core, Louvain, Shortest Path)
  8. detect - Detect patterns (strongly/weakly connected components)
  9. bulk-import - Efficient bulk entity import
  10. search - Full-text search across all entity types with KuzuDB FTS integration
  11. delete - Safe deletion of entities with dependency validation and bulk operations
  12. memory-optimizer - 🧠 AI-powered core memory optimization with MCP sampling, snapshots, and rollback

For detailed tool documentation, see Unified Tools Documentation.

Documentation

Installation

bash
# Clone the repository
git clone git@github.com:Jakedismo/KuzuMem-MCP.git
cd kuzumem-mcp

# Install dependencies
npm install

# Build the project
npm run build

Configuration

Create a .env file in the root directory (copy from .env.example):

env
# Database Configuration
DB_FILENAME="memory-bank.kuzu"

# Server Configuration
HTTP_STREAM_PORT=3001
HOST=localhost

# Debug Logging (0=Error, 1=Warn, 2=Info, 3=Debug, 4=Trace)
DEBUG=1

# Core Memory Optimization Agent - AI Provider Configuration
# Required for memory optimization features
OPENAI_API_KEY=sk-your-openai-api-key-here
ANTHROPIC_API_KEY=sk-ant-your-anthropic-api-key-here

# Optional: Custom API endpoints
# OPENAI_BASE_URL=https://api.openai.com/v1
# ANTHROPIC_BASE_URL=https://api.anthropic.com

Core Memory Optimization Setup

The Core Memory Optimization Agent requires API keys for high-reasoning models:

Supported Models:

  • OpenAI: o3, o4-mini (with HIGH reasoning, 32,768 tokens)
  • Anthropic: claude-4 (with extended thinking, 2,048 tokens)

For detailed setup instructions, see Core Memory Optimization Setup Guide.

Add to your IDE's MCP configuration:

json
{
  "mcpServers": {
    "KuzuMem-MCP": {
      "command": "npx",
      "args": ["-y", "ts-node", "/absolute/path/to/kuzumem-mcp/src/mcp-stdio-server.ts"],
      "env": {
        "PORT": "3000",
        "HOST": "localhost",
        "DB_FILENAME": "memory-bank.kuzu",
        "HTTP_STREAM_PORT": "3001"
      }
    }
  }
}

Quick Start

1. Initialize Memory Bank

json
{
  "tool": "memory-bank",
  "operation": "init",
  "clientProjectRoot": "/path/to/your/project",
  "repository": "my-app",
  "branch": "main"
}

2. Create Entities

json
{
  "tool": "entity",
  "operation": "create",
  "entityType": "component",
  "repository": "my-app",
  "branch": "main",
  "data": {
    "id": "comp-auth-service",
    "name": "Authentication Service",
    "kind": "service",
    "depends_on": ["comp-user-service"]
  }
}

3. Query Dependencies

json
{
  "tool": "query",
  "type": "dependencies",
  "repository": "my-app",
  "branch": "main",
  "componentId": "comp-auth-service",
  "direction": "dependencies"
}

4. Run Analysis

json
{
  "tool": "analyze",
  "type": "pagerank",
  "repository": "my-app",
  "branch": "main",
  "projectedGraphName": "component-importance",
  "nodeTableNames": ["Component"],
  "relationshipTableNames": ["DEPENDS_ON"]
}

🧠 Core Memory Optimization Agent

The Core Memory Optimization Agent provides AI-powered memory graph optimization with advanced reasoning capabilities and production-ready safety features:

Features

  • 🧠 High-Reasoning Analysis: Uses OpenAI o3/o4-mini (HIGH reasoning) or Claude (extended thinking) for intelligent memory analysis
  • 🎯 MCP Sampling: Context-aware prompts that adapt to actual memory state and project characteristics
  • 🛡️ Automatic Snapshots: Production-ready safety with automatic backup before optimization
  • 🔄 Guaranteed Rollback: Complete state restoration with transactional safety
  • ⚖️ Safe Optimization: Conservative, balanced, and aggressive strategies with safety validation
  • 🔍 Stale Entity Detection: Identifies outdated entities based on age and usage patterns
  • 🔗 Redundancy Removal: Finds and consolidates duplicate or redundant entities
  • 📊 Dependency Optimization: Optimizes relationship chains while preserving integrity
  • 👀 Dry-Run Mode: Preview optimizations without making changes
  • 📈 Project Intelligence: Automatic project maturity, activity, and complexity analysis

Quick Start

1. Analyze Memory Graph (with MCP Sampling)

json
{
  "tool": "memory-optimizer",
  "operation": "analyze",
  "repository": "my-app",
  "branch": "main",
  "llmProvider": "openai",
  "model": "o4-mini",
  "strategy": "conservative",
  "enableMCPSampling": true,
  "samplingStrategy": "representative"
}

2. Preview Optimization (Dry Run)

json
{
  "tool": "memory-optimizer",
  "operation": "optimize",
  "repository": "my-app",
  "branch": "main",
  "dryRun": true,
  "strategy": "conservative"
}

3. Execute Optimization (with Automatic Snapshot)

json
{
  "tool": "memory-optimizer",
  "operation": "optimize",
  "repository": "my-app",
  "branch": "main",
  "dryRun": false,
  "confirm": true,
  "strategy": "conservative"
}

4. List Available Snapshots

json
{
  "tool": "memory-optimizer",
  "operation": "list-snapshots",
  "repository": "my-app",
  "branch": "main"
}

5. Rollback to Previous State

json
{
  "tool": "memory-optimizer",
  "operation": "rollback",
  "repository": "my-app",
  "branch": "main",
  "snapshotId": "snapshot-1703123456789-xyz789"
}

Optimization Strategies

  • Conservative: Max 5 deletions, 6-month stale threshold (recommended for production)
  • Balanced: Max 20 deletions, 3-month stale threshold (recommended for development)
  • Aggressive: Max 50 deletions, 1-month stale threshold (use with caution)

MCP Sampling Strategies

  • Representative: Balanced sample across all entity types (default)
  • Problematic: Focus on stale, disconnected, or deprecated entities
  • Recent: Sample newly created entities (< 30 days) for safety analysis
  • Diverse: Ensure representation from all entity types for complex systems

Safety Features

  • 🛡️ Automatic Snapshots: Created before every optimization (unless dry-run)
  • 🔄 Transactional Rollback: Complete state restoration with database consistency
  • ✅ Validation System: Snapshot integrity checks before rollback operations
  • 📊 Context-Aware Safety: Activity-level and complexity-based safety measures

For complete setup and usage instructions, see:

Testing

bash
# Run unit tests
npm test

# Run E2E tests (requires API keys)
npm run test:e2e

# Run specific E2E tests
npm run test:e2e:stdio
npm run test:e2e:httpstream

# Run memory optimizer E2E tests
npm run test:e2e -- --testNamePattern="Memory Optimizer E2E Tests"

# Run all tests
npm run test:all

E2E Test Requirements

For memory optimizer E2E tests, set environment variables:

bash
export OPENAI_API_KEY="your-actual-openai-api-key"
export ANTHROPIC_API_KEY="your-actual-anthropic-api-key"

Note: All core functionality is operational with comprehensive E2E test coverage for both stdio and HTTP stream protocols.

Architecture

KuzuMem-MCP follows official MCP TypeScript SDK patterns with clean architecture:

text
┌─────────────────────────────────────────────────────────────┐
│                    MCP Protocol Layer                       │
├─────────────────────────────────────────────────────────────┤
│     HTTP Stream Server     │      Stdio Server             │
│   (StreamableHTTPTransport) │   (StdioTransport)            │
├─────────────────────────────────────────────────────────────┤
│                    Tool Handlers                            │
├─────────────────────────────────────────────────────────────┤
│                   Memory Service                            │
├─────────────────────────────────────────────────────────────┤
│                   Repository Layer                          │
├─────────────────────────────────────────────────────────────┤
│                    KuzuDB Client                            │
└─────────────────────────────────────────────────────────────┘

Key Components

  • MCP Servers: Official SDK implementations using McpServer with HTTP Stream and Stdio transports
  • Tool Handlers: Business logic for each MCP tool with simplified context handling
  • Memory Service: Core orchestration and repository management
  • Repository Layer: Thread-safe singletons for each entity type
  • Database Layer: KùzuDB embedded graph database

Official SDK Compliance

✅ Session Management: Uses built-in SDK session handling ✅ Tool Registration: Uses official tool() method with Zod validation ✅ Transport Handling: Leverages SDK transport implementations ✅ Error Handling: Follows SDK error patterns and best practices

For detailed architecture information, see Extended Documentation.

Agent Development Loop (Rules-Enforced)

When both the repository-level "Always-Applied Workspace Rules" (project_config_updated.md) and the short-term workflow rules (workflow_state_updated.mdc) are active, every IDE or AI agent that communicates with KuzuMem-MCP must follow the five-phase finite-state loop below. Each transition is observable via the unified context tool and is backed by mandatory MCP calls that keep the graph database in sync and governance rules enforced.

  1. ANALYZE – Pull the latest context, inspect 1-hop neighbourhood, and optionally execute a PageRank analysis. Produce a high-level problem statement.
  2. BLUEPRINT – Draft a numbered implementation plan and persist it as a Decision entity (status: proposed, tag architecture). Wait for explicit user approval.
  3. CONSTRUCT – Execute plan steps, apply code edits, and immediately mirror changes through entity, associate, and context tool calls while honouring dependency & tagging rules.
  4. VALIDATE – Run the full test & linter suite. If green, update the Decision to implemented; if red, log context and loop back to CONSTRUCT.
  5. ROLLBACK – Automatically triggered on unrecoverable errors, reverting partial work before returning to ANALYZE.

Phase Diagram

License

Apache-2.0

Contributing

Contributions are welcome! Please ensure:

  • All tests pass (or create issues for failing tests)
  • Code follows the existing style
  • New features include tests
  • Documentation is updated

Future Improvements

  • Vector Embeddings - Semantic similarity search (pending KuzuDB vector column updates)
  • Advanced Graph Algorithms - Additional analysis capabilities
  • Graph Schema Updates - Based on how well the automated development loop works, the graph schema may need to be updated to support new features
  • Complete Semantic Search - Implementation of the semantic-search tool (currently placeholder - KuzuDB Vector Indexes are immutable and would make developing this feature difficult since updating memories wouldn't update the vector indexes)

MCP Review

This MCP is verified by MCP Review

https://mcpreview.com/mcp-servers/Jakedismo/KuzuMem-MCP

Automatic Codereviews with Codrabbit

CodeRabbit Pull Request Reviews

Installation

TypingMind
Prerequisites:

Node.js 18+

{
  "mcpServers": {
    "jakedismo-kuzumem-mcp": {
      "command": "",
      "args": []
    }
  }
}

Use KuzuMem-MCP MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once KuzuMem-MCP is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add KuzuMem-MCP as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the KuzuMem-MCP MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "jakedismo-kuzumem-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "kuzumem-mcp"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the KuzuMem-MCP MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the KuzuMem-MCP MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use KuzuMem-MCP to help me with this task?
KuzuMem-MCP
Sure. I read it.
Here is what I found using KuzuMem-MCP.

Frequently asked questions

What is the KuzuMem-MCP MCP server used for?

KuzuMem-MCP is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use KuzuMem-MCP MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use KuzuMem-MCP with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use KuzuMem-MCP MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With KuzuMem-MCP connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect KuzuMem-MCP MCP to TypingMind?

KuzuMem-MCP runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does KuzuMem-MCP MCP provide in TypingMind?

KuzuMem-MCP exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use KuzuMem-MCP MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If KuzuMem-MCP requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇