Skip to main content
Glama

Memory Bank MCP - Semantic Code Indexing

MCP (Model Context Protocol) server for semantic code indexing. Enables AI agents like Claude, Copilot, Cursor, and others to maintain a "persistent memory" of entire codebases through vector embeddings and semantic search.

๐Ÿง  What is Memory Bank?

Memory Bank is an external memory system for code agents that solves the fundamental problem of context loss in AIs. It works as the project's "external brain":

  • Indexes all your code using OpenAI embeddings

  • Chunks intelligently using AST parsing (functions, classes, methods)

  • Stores vectors in LanceDB for ultra-fast searches

  • Searches semantically: ask in natural language, get relevant code

  • Updates incrementally: only reindexes modified files

  • Multi-project: query code from any indexed project from any workspace

Why do you need it?

Without Memory Bank, AIs:

  • โŒ Forget everything between sessions

  • โŒ Only see small code snippets

  • โŒ Hallucinate non-existent implementations

  • โŒ Give generic answers without context

With Memory Bank, AIs:

  • โœ… Remember the entire codebase

  • โœ… Understand architecture and patterns

  • โœ… Respond with real project code

  • โœ… Generate code consistent with your style

  • โœ… Query multiple indexed projects simultaneously

Related MCP server: local-memory-mcp

๐Ÿš€ Features

  • ๐Ÿ” Semantic Search: Ask "how does authentication work?" and get relevant code

  • ๐Ÿงฉ Intelligent Chunking: AST parsing for TS/JS/Python with token limits (8192 max)

  • โšก Incremental Updates: Only reindexes modified files (hash-based detection)

  • ๐Ÿ’พ Embedding Cache: Avoids regenerating embeddings unnecessarily

  • ๐ŸŽฏ Advanced Filters: By file, language, chunk type

  • ๐Ÿ“Š Detailed Statistics: Know the state of your index at all times

  • ๐Ÿ”’ Privacy: Local vector store, respects .gitignore and .memoryignore

  • ๐Ÿ”€ Multi-Project: Query any indexed project using its projectId

Project Knowledge Layer (Global Knowledge)

  • ๐Ÿ“„ Automatic Documentation: Generates 6 structured markdown documents about the project

  • ๐Ÿง  AI with Reasoning: Uses OpenAI Responses API with reasoning models (gpt-5-mini)

  • ๐Ÿ”„ Smart Updates: Only regenerates documents affected by changes

  • ๐Ÿ“š Global Context: Complements precise search with high-level vision

Context Management (Session Management) ๐Ÿ†•

  • ๐Ÿš€ Quick Initialization: Creates Memory Bank structure with initial templates (no AI)

  • ๐Ÿ“ Session Tracking: Records active context, recent changes, and next steps

  • ๐Ÿ“‹ Decision Log: Documents technical decisions with rationale and alternatives

  • ๐Ÿ“Š Progress Tracking: Manages tasks, milestones, and blockers

  • ๐Ÿ“ก MCP Resources: Direct read-only access to documents via URIs

Multi-Agent Coordination (Team Sync) ๐Ÿค–

  • ๐Ÿšฆ Traffic Control: Prevents multiple agents from modifying the same files simultaneously

  • ๐Ÿ“Œ Agent Board: Centralized view of active agents, claimed tasks, and locked files

  • ๐Ÿ†” Identity Management: Tracks who is doing what (GitHub Copilot, Cursor, etc.)

  • ๐Ÿ”’ Atomic Locks: File-system based locking safe across different processes/IDEs

Task Orchestration (Smart Routing) ๐Ÿงญ NEW

  • ๐ŸŽฏ Intelligent Routing: Analyzes tasks BEFORE implementation to determine ownership

  • ๐Ÿ“‹ Enriched Project Registry: Projects have responsibilities, ownership, and exports metadata

  • ๐Ÿค– AI Reasoning: Uses reasoning models to distribute work across projects

  • ๐Ÿ”€ Auto-Delegation: Automatically identifies what should be delegated to other projects

  • ๐Ÿ“ฆ Import Suggestions: Recommends what to import from other projects instead of reimplementing

๐Ÿ“‹ Requirements

  • Node.js >= 18.0.0

  • OpenAI API Key: Get one here

  • Disk space: ~10MB per 10,000 files (embeddings + metadata)

๐Ÿ› ๏ธ Installation

The easiest way to use Memory Bank MCP without local installation:

npx @grec0/memory-bank-mcp@latest

Option 2: Local Installation

For development or contribution:

# Clone repository
git clone https://github.com/gcorroto/memory-bank-mcp.git
cd memory-bank-mcp

# Install dependencies
npm install

# Build
npm run build

# Run
npm run start

โš™๏ธ Complete Configuration

Environment Variables

Memory Bank is configured through environment variables. You can set them in your MCP client or in a .env file:

Required Variables

Variable

Description

OPENAI_API_KEY

REQUIRED. Your OpenAI API key

Indexing Variables

Variable

Default

Description

MEMORYBANK_STORAGE_PATH

.memorybank

Directory where the vector index is stored

MEMORYBANK_WORKSPACE_ROOT

process.cwd()

Workspace root (usually auto-detected)

MEMORYBANK_EMBEDDING_MODEL

text-embedding-3-small

OpenAI embedding model

MEMORYBANK_EMBEDDING_DIMENSIONS

1536

Vector dimensions (1536 or 512)

MEMORYBANK_MAX_TOKENS

7500

Maximum tokens per chunk (limit: 8192)

MEMORYBANK_CHUNK_OVERLAP_TOKENS

200

Overlap between chunks to maintain context

Project Knowledge Layer Variables

Variable

Default

Description

MEMORYBANK_REASONING_MODEL

gpt-5-mini

Model for generating documentation (supports reasoning)

MEMORYBANK_REASONING_EFFORT

medium

Reasoning level: low, medium, high

MEMORYBANK_AUTO_UPDATE_DOCS

false

Auto-regenerate docs when indexing code

Map-Reduce Auto-Summarization (v0.2.0+)

For large projects that exceed the LLM context window, Memory Bank automatically uses Map-Reduce summarization:

  1. Map Phase: Splits chunks into batches (~100K chars each), summarizes each batch

  2. Reduce Phase: Combines batch summaries into a coherent final summary

  3. Recursive: If combined summaries still exceed threshold, recurses up to 3 levels

This happens automatically when content exceeds 400K characters. No configuration needed.

Configuration in Cursor IDE

Edit your MCP configuration file:

Windows: %APPDATA%\Cursor\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json

Minimal Configuration

{
  "mcpServers": {
    "memory-bank-mcp": {
      "type": "stdio",
      "command": "npx",
      "args": ["@grec0/memory-bank-mcp@latest"],
      "env": {
        "OPENAI_API_KEY": "sk-your-api-key-here"
      }
    }
  }
}
{
  "mcpServers": {
    "memory-bank-mcp": {
      "type": "stdio",
      "command": "npx",
      "args": ["@grec0/memory-bank-mcp@latest"],
      "env": {
        "OPENAI_API_KEY": "sk-your-api-key-here",
        "MEMORYBANK_REASONING_MODEL": "gpt-5-mini",
        "MEMORYBANK_REASONING_EFFORT": "medium",
        "MEMORYBANK_AUTO_UPDATE_DOCS": "false",
        "MEMORYBANK_MAX_TOKENS": "7500",
        "MEMORYBANK_CHUNK_OVERLAP_TOKENS": "200",
        "MEMORYBANK_EMBEDDING_MODEL": "text-embedding-3-small",
        "MEMORYBANK_EMBEDDING_DIMENSIONS": "1536"
      }
    }
  }
}

Configuration in Claude Desktop

Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Linux: ~/.config/claude/claude_desktop_config.json

{
  "mcpServers": {
    "memory-bank": {
      "command": "npx",
      "args": ["@grec0/memory-bank-mcp@latest"],
      "env": {
        "OPENAI_API_KEY": "sk-your-api-key-here",
        "MEMORYBANK_REASONING_MODEL": "gpt-5-mini",
        "MEMORYBANK_REASONING_EFFORT": "medium"
      }
    }
  }
}

Configuration with Local Installation

{
  "mcpServers": {
    "memory-bank": {
      "command": "node",
      "args": ["/absolute/path/memory-bank-mcp/dist/index.js"],
      "cwd": "/absolute/path/memory-bank-mcp",
      "env": {
        "OPENAI_API_KEY": "sk-your-api-key-here"
      }
    }
  }
}

๐Ÿ“„ Project Documentation System (Project Knowledge Layer)

Memory Bank includes an intelligent documentation system that generates and maintains structured knowledge about your project using AI with reasoning capabilities.

How Does It Work?

  1. Code Analysis: The system analyzes indexed code using semantic search

  2. AI Generation: Uses reasoning models (gpt-5-mini) to generate structured documentation

  3. Incremental Updates: Only regenerates documents affected by significant changes

  4. Persistent Storage: Documents are saved in .memorybank/projects/{projectId}/docs/

Generated Documents

The system generates 6 markdown documents that provide different perspectives of the project:

Document

Purpose

Content

projectBrief.md

General Description

What the project is, its main purpose, key features

productContext.md

Business Perspective

Why it exists, problems it solves, target users, UX

systemPatterns.md

Architecture and Patterns

Code structure, design patterns, technical decisions

techContext.md

Tech Stack

Technologies, dependencies, configurations, integrations

activeContext.md

Current State

What's being worked on, recent changes, next steps

progress.md

Tracking

Change history, what works, what's missing, known issues

Documentation Tools

memorybank_generate_project_docs

Generates or regenerates project documentation.

{
  "projectId": "my-project",
  "force": false
}
  • projectId (REQUIRED): Project ID

  • force (optional): true to regenerate everything, false for incremental updates

memorybank_get_project_docs

Reads generated documentation.

// Get summary of all documents
{
  "projectId": "my-project",
  "document": "summary"
}

// Get specific document
{
  "projectId": "my-project",
  "document": "systemPatterns"
}

// Get all complete documents
{
  "projectId": "my-project",
  "document": "all",
  "format": "full"
}

Documentation Workflow

1. Index code
   memorybank_index_code({ projectId: "my-project" })

2. Generate documentation (also updates global registry)
   memorybank_generate_project_docs({ projectId: "my-project" })

3. Query documentation at the start of each session
   memorybank_get_project_docs({ projectId: "my-project", document: "activeContext" })

4. Route task BEFORE implementing (mandatory in auto-index mode)
   memorybank_route_task({ projectId: "my-project", taskDescription: "..." })

5. Search specific code
   memorybank_search({ projectId: "my-project", query: "..." })

Auto-Update Documentation

If you configure MEMORYBANK_AUTO_UPDATE_DOCS=true, documents will be automatically regenerated after each indexing. This is useful for keeping documentation always up to date but consumes more API tokens.

Upgrading Existing Projects ๐Ÿ†•

If you have projects already initialized with a previous version, simply regenerate the docs to enable Task Orchestration:

// For each existing project:
memorybank_generate_project_docs({ "projectId": "your-project", "force": true })

This will:

  1. Regenerate all 6 markdown documents

  2. NEW: Extract responsibilities, ownership, and exports

  3. NEW: Update global_registry.json with enriched metadata

  4. Enable memorybank_route_task to work with this project


๐Ÿค– Multi-Agent Coordination

Memory Bank includes a Coordination Layer to support multiple agents (e.g., in different IDEs, parallel sessions, or team members) working on the same project without conflicts.

Why is this needed?

When you have multiple AI agents (e.g., one in VS Code, one in Cursor, one in Windsurf) or multiple developers working on the same codebase, they often collide:

  • Modifying the same file simultaneously

  • Duplicating work

  • Halucinating that a task is "todo" when someone else is already doing it

How It Works

  1. Agent Board (agentBoard.md): A central "whiteboard" in the .memorybank/ folder that tracks active agents and locks.

  2. Protocol: Agents follow a strict "Check -> Claim -> Work -> Release" protocol.

  3. Atomic Locks: Uses file-system based locking (.lock directories) to ensure safety even across different processes and machines accessing the same filesystem.

Workflow

  1. Check Board: Agents consult the Agent Board before starting work.

  2. Register Identity: Agents identify themselves (e.g., Dev-VSCode-GPT4-8A2F).

  3. Claim Resource: Agents "lock" files or tasks they are working on.

  4. Work & Release: Agents work on the task and release the lock when finished (or when the lock expires/stales).

New Tool: memorybank_manage_agents

This tool allows agents to interact with the board:

// Register on the board
{
  "projectId": "my-project",
  "action": "register",
  "agentId": "Dev-VSCode-GPT4-8A2F"
}

// See what others are doing
{
  "projectId": "my-project",
  "action": "get_board"
}

// Claim a task/file
{
  "projectId": "my-project",
  "action": "claim_resource",
  "agentId": "Dev-VSCode-GPT4-8A2F",
  "resource": "src/auth/login.ts"
}

Protocol for Cross-Project Delegation (Handoff) ๐Ÿ†•

Agents can also discover and delegate tasks to other projects in the ecosystem.

1. Discovery: Find other agents/projects.

// Find backend projects
memorybank_discover_projects({ "query": "backend" })
// Returns: [{ projectId: "memory_bank_mcp", description: "Backend MCP Server..." }]

2. Delegation: Create a task in another project's board.

memorybank_delegate_task({
  "projectId": "frontend-app",
  "targetProjectId": "memory_bank_mcp",
  "title": "Add API endpoint",
  "description": "Please add a new endpoint...",
  "context": "Frontend needs this for feature X"
})

Task Orchestration (Smart Routing) ๐Ÿงญ NEW

The Task Orchestrator analyzes tasks BEFORE implementation to prevent agents from creating code that belongs to other projects.

Why is this needed?

Without orchestration, agents often:

  • โŒ Create DTOs in the API project when lib-dtos exists

  • โŒ Duplicate utilities that are already in shared-utils

  • โŒ Implement features that belong to other microservices

  • โŒ Violate architectural boundaries unknowingly

With the orchestrator:

  • โœ… Know exactly what belongs to this project

  • โœ… Automatically delegate work to the right project

  • โœ… Get import suggestions instead of reimplementing

  • โœ… Respect ecosystem boundaries

How It Works

  1. Enriched Registry: When you run memorybank_generate_project_docs, it automatically extracts:

    • responsibilities: What this project is responsible for

    • owns: Files/folders that belong to this project

    • exports: What this project provides to others

    • projectType: api, library, frontend, backend, etc.

  2. Route Before Implementing: Call memorybank_route_task BEFORE any code changes:

memorybank_route_task({
  "projectId": "my-api",
  "taskDescription": "Create DTOs for user management and expose REST endpoints"
})
  1. Orchestrator Response:

{
  "action": "partial_delegate",
  "myResponsibilities": [
    "Create REST endpoints in src/controllers/",
    "Implement business logic in src/services/"
  ],
  "delegations": [
    {
      "targetProjectId": "lib-dtos",
      "taskTitle": "Create UserDTO and UserResponseDTO",
      "reason": "DTOs belong to lib-dtos per project responsibilities"
    }
  ],
  "suggestedImports": [
    "import { UserDTO } from 'lib-dtos'"
  ],
  "architectureNotes": "Use shared DTOs to maintain consistency across services"
}

Possible Actions

Action

Meaning

implement_here

Everything belongs to this project, proceed

delegate_all

Nothing belongs here, delegate everything

partial_delegate

Some parts belong here, delegate the rest

needs_clarification

Task is ambiguous, ask user for details


๐Ÿ”€ Multi-Project: Cross-Project Queries

A powerful feature of Memory Bank is the ability to query any indexed project from any workspace.

How Does It Work?

All indexed projects are stored in a shared vector store, identified by their projectId. This means:

  1. You can work on Project A and query code from Project B

  2. Agents can learn from similar already-indexed projects

  3. Reuse patterns from other projects in your organization

Usage Example

# You're working on "frontend-app" but need to see how something was done in "backend-api"

User: How was authentication implemented in the backend-api project?

Agent: [executes memorybank_search({ 
  projectId: "backend-api",  // Another project
  query: "JWT middleware authentication"
})]

Found the implementation in backend-api:
- The auth middleware is in src/middleware/auth.ts
- Uses JWT with refresh tokens
- Validation is done with jsonwebtoken...

Requirements for Multi-Project

  1. The project must be previously indexed with its projectId

  2. Use the correct projectId when making queries

  3. Documentation is independent per project

// Project 1: a2a_gateway (already indexed)
memorybank_search({
  "projectId": "a2a_gateway",
  "query": "how agents are registered"
})

// Project 2: GREC0AI (current workspace)
memorybank_search({
  "projectId": "GREC0AI", 
  "query": "AgentEntity implementation"
})

// You can query both in the same session!

๐Ÿ“š Available Tools

โš ๏ธ IMPORTANT: All tools require mandatory projectId. This ID must match the one defined in your AGENTS.md file.

memorybank_index_code

Indexes code semantically to enable searches.

Parameters:

  • projectId (REQUIRED): Unique project identifier

  • path (optional): Relative or absolute path (default: workspace root)

  • recursive (optional): Index subdirectories (default: true)

  • forceReindex (optional): Force complete reindexing (default: false)

Example:

{
  "projectId": "my-project",
  "path": "src/auth",
  "recursive": true
}

Searches code by semantic similarity.

Parameters:

  • projectId (REQUIRED): Project identifier to search in

  • query (required): Natural language query

  • topK (optional): Number of results (default: 10)

  • minScore (optional): Minimum score 0-1 (default: 0.4)

  • filterByFile (optional): Filter by file pattern

  • filterByLanguage (optional): Filter by language

Example:

{
  "projectId": "my-project",
  "query": "function that authenticates users with JWT",
  "topK": 5,
  "minScore": 0.8
}

memorybank_read_file

Reads file contents.

Parameters:

  • path (required): File path

  • startLine (optional): Start line

  • endLine (optional): End line

memorybank_write_file

Writes a file and automatically reindexes it.

Parameters:

  • projectId (REQUIRED): Project identifier for reindexing

  • path (required): File path

  • content (required): File content

  • autoReindex (optional): Auto-reindex (default: true)

memorybank_get_stats

Gets Memory Bank statistics.

memorybank_analyze_coverage

Analyzes project indexing coverage.

Parameters:

  • projectId (REQUIRED): Project identifier to analyze

  • path (REQUIRED): Absolute workspace path to analyze

Example:

{
  "projectId": "my-project",
  "path": "C:/workspaces/my-project"
}

memorybank_route_task ๐Ÿ†•

Analyzes a task and determines what belongs to this project vs what should be delegated. MUST be called BEFORE any implementation.

Parameters:

  • projectId (REQUIRED): Project requesting the routing

  • taskDescription (REQUIRED): Detailed description of what needs to be implemented

Example:

{
  "projectId": "my-api",
  "taskDescription": "Create user registration endpoint with validation and DTOs"
}

Response:

{
  "action": "partial_delegate",
  "myResponsibilities": ["Create POST /users endpoint", "Add validation middleware"],
  "delegations": [{ "targetProjectId": "lib-dtos", "taskTitle": "Create UserDTO" }],
  "suggestedImports": ["import { UserDTO } from 'lib-dtos'"],
  "architectureNotes": "Follow REST conventions, use shared DTOs"
}

memorybank_generate_project_docs

Generates structured project documentation using AI with reasoning. Also automatically updates the global registry with enriched project metadata (responsibilities, owns, exports, projectType).

Parameters:

  • projectId (REQUIRED): Project identifier

  • force (optional): Force regeneration (default: false)

memorybank_get_project_docs

Reads AI-generated project documentation.

Parameters:

  • projectId (REQUIRED): Project identifier

  • document (optional): "summary", "all", or specific name (projectBrief, systemPatterns, etc.)

  • format (optional): "full" or "summary" (default: "full")


๐Ÿ”„ Context Management Tools (Cline-style)

These tools allow managing project context manually, complementing automatic AI generation.

memorybank_initialize

Initializes Memory Bank for a new project. Creates directory structure and 7 markdown documents with initial templates. Does not use AI.

Parameters:

  • projectId (REQUIRED): Unique project identifier

  • projectPath (REQUIRED): Absolute project path

  • projectName (optional): Human-readable project name

  • description (optional): Initial project description

Example:

{
  "projectId": "my-project",
  "projectPath": "C:/workspaces/my-project",
  "projectName": "My Awesome Project",
  "description": "A web application for..."
}

Created documents:

  • projectBrief.md - General description

  • productContext.md - Product context

  • systemPatterns.md - Architecture patterns

  • techContext.md - Tech stack

  • activeContext.md - Session context

  • progress.md - Progress tracking

  • decisionLog.md - Decision log

memorybank_update_context

Updates active context with current session information. Maintains history of the last 10 sessions. Does not use AI.

Parameters:

  • projectId (REQUIRED): Project identifier

  • currentSession (optional): Session information (date, mode, task)

  • recentChanges (optional): List of recent changes

  • openQuestions (optional): Pending questions

  • nextSteps (optional): Planned next steps

  • notes (optional): Additional notes

Example:

{
  "projectId": "my-project",
  "currentSession": {
    "mode": "development",
    "task": "Implementing authentication"
  },
  "recentChanges": ["Added JWT middleware", "Created user model"],
  "nextSteps": ["Add refresh token", "Create login endpoint"]
}

memorybank_record_decision

Records technical decisions with rationale in the decision log. Does not use AI.

Parameters:

  • projectId (REQUIRED): Project identifier

  • decision (REQUIRED): Object with decision information

    • title (REQUIRED): Decision title

    • description (REQUIRED): What was decided

    • rationale (REQUIRED): Why this decision was made

    • alternatives (optional): Considered alternatives

    • impact (optional): Expected impact

    • category (optional): architecture, technology, dependencies, etc.

Example:

{
  "projectId": "my-project",
  "decision": {
    "title": "JWT Authentication",
    "description": "Use JWT tokens for API authentication",
    "rationale": "Stateless, scalable, works well with microservices",
    "alternatives": ["Session-based auth", "OAuth only"],
    "category": "architecture"
  }
}

memorybank_track_progress

Updates progress tracking with tasks, milestones, and blockers. Does not use AI.

Parameters:

  • projectId (REQUIRED): Project identifier

  • progress (optional): Tasks to update

    • completed: Completed tasks

    • inProgress: Tasks in progress

    • blocked: Blocked tasks

    • upcoming: Upcoming tasks

  • milestone (optional): Milestone to add/update (name, status, targetDate, notes)

  • blockers (optional): List of blockers with severity (low/medium/high)

  • phase (optional): Current project phase

  • phaseStatus (optional): Phase status

Example:

{
  "projectId": "my-project",
  "progress": {
    "completed": ["Setup project structure", "Configure ESLint"],
    "inProgress": ["Implement user authentication"],
    "upcoming": ["Add unit tests"]
  },
  "milestone": {
    "name": "MVP",
    "status": "in_progress",
    "targetDate": "2026-02-01"
  }
}

๐Ÿ“ก MCP Resources (Direct Access)

Memory Bank exposes MCP resources for direct read-only access to project documents.

Resource URI

Content

memory://{projectId}/active

Active session context

memory://{projectId}/progress

Progress tracking

memory://{projectId}/decisions

Technical decision log

memory://{projectId}/context

Project context (brief + tech)

memory://{projectId}/patterns

System patterns

memory://{projectId}/brief

Project description

Usage example:

// Access active context for "my-project"
memory://my-project/active

// Access decision log
memory://my-project/decisions

Resources are read-only. To modify documents, use the corresponding tools (memorybank_update_context, memorybank_record_decision, etc.).


๐Ÿ“‹ Agent Instruction Templates

Memory Bank includes instruction templates in two formats to configure agent behavior:

  • AGENTS.md - Standard agents.md (compatible with Claude, Cursor, multiple agents)

  • VSCode/Copilot - .github/copilot-instructions.md format for GitHub Copilot in VS Code

Available Modes

Mode

File

Ideal Use

Basic

AGENTS.basic.md

Total control, manual indexing

Auto-Index

AGENTS.auto-index.md

Active development, automatic sync

Sandboxed

AGENTS.sandboxed.md

Environments without direct file access

1. Basic Mode

For projects where you want total control.

  • โœ… Agent ALWAYS consults Memory Bank before acting

  • โœ… Only indexes when user explicitly requests

  • โœ… Asks permission before modifying code

  • โœ… Suggests reindexing after changes

Ideal for: Critical projects, code review, onboarding.

2. Auto-Index Mode

For active development with automatic synchronization.

  • โœ… Agent consults Memory Bank automatically

  • โœ… Routes tasks before implementing (Rule 0.5)

  • โœ… Reindexes EVERY file after modifying it

  • โœ… Keeps Memory Bank always up to date

  • โœ… Can read/write files directly

  • โœ… Auto-delegates to other projects when appropriate

Ideal for: Active development, rapid iteration, teams, multi-project ecosystems.

3. Sandboxed Mode

For environments without direct file system access.

  • โœ… Does NOT have direct file access

  • โœ… MUST use memorybank_read_file to read

  • โœ… MUST use memorybank_write_file to write

  • โœ… Auto-reindexes automatically on each write

Ideal for: Restricted environments, remote development, security.

Available Templates

All templates are available in the GitHub repository:

AGENTS.md Format (Cursor, Claude, Multi-agent)

Installation:

# Download template (choose one)
curl -o AGENTS.md https://raw.githubusercontent.com/gcorroto/memory-bank-mcp/main/templates/AGENTS.basic.md
# Or
curl -o AGENTS.md https://raw.githubusercontent.com/gcorroto/memory-bank-mcp/main/templates/AGENTS.auto-index.md
# Or
curl -o AGENTS.md https://raw.githubusercontent.com/gcorroto/memory-bank-mcp/main/templates/AGENTS.sandboxed.md

# Edit placeholders:
# - Replace {{PROJECT_ID}} with your unique project ID
# - Replace {{WORKSPACE_PATH}} with the absolute workspace path

VS Code / GitHub Copilot Format

Installation:

# Create .github folder if it doesn't exist
mkdir -p .github

# Download template (choose one)
curl -o .github/copilot-instructions.md https://raw.githubusercontent.com/gcorroto/memory-bank-mcp/main/templates/vscode/copilot-instructions.basic.md
# Or
curl -o .github/copilot-instructions.md https://raw.githubusercontent.com/gcorroto/memory-bank-mcp/main/templates/vscode/copilot-instructions.auto-index.md
# Or
curl -o .github/copilot-instructions.md https://raw.githubusercontent.com/gcorroto/memory-bank-mcp/main/templates/vscode/copilot-instructions.sandboxed.md

# Enable in VS Code settings.json:
# "github.copilot.chat.codeGeneration.useInstructionFiles": true

Instructions with Conditional Application (VS Code)

To use the .instructions.md file that applies only to certain files:

# Create instructions folder
mkdir -p .github/instructions

# Download base instructions
curl -o .github/instructions/memory-bank.instructions.md https://raw.githubusercontent.com/gcorroto/memory-bank-mcp/main/templates/vscode/memory-bank.instructions.md

This file includes applyTo: "**/*" which applies to all files, but you can modify it.

Configured AGENTS.md Example

# AGENTS.md

## Project Configuration
- **Project ID**: `my-awesome-app`
- **Workspace**: `C:/workspaces/my-awesome-app`

## Memory Bank Instructions

### CRITICAL: Always Consult Before Acting
Before any action, call `memorybank_search` with projectId="my-awesome-app"

### Auto-Indexing Policy
AFTER every file modification:
memorybank_index_code({ projectId: "my-awesome-app", path: "<modified_file>" })

### Session Start
At the beginning of each session, get context:
memorybank_get_project_docs({ projectId: "my-awesome-app", document: "activeContext" })

๐ŸŽฏ Use Cases

1. First Indexing

User: Hi, I want you to help me with my project. The projectId is "my-app"
Claude: [executes memorybank_get_stats]
        I see there's no code indexed yet. 
        Would you like me to index the project so I can help you better?

User: Yes
Claude: [executes memorybank_index_code({ projectId: "my-app" })]
        I've indexed 145 files (1,234 chunks) in 45 seconds.
        How can I help you?
User: How does authentication work in this project?
Claude: [executes memorybank_search({ projectId: "my-app", query: "authentication login users" })]
        
        Authentication is implemented in src/auth/authService.ts (lines 23-87):
        
        [Found code]
        
        The system uses JWT tokens with refresh token rotation. 
        Validation is done in the middleware src/middleware/auth.ts.

3. Cross-Project Query

User: I'm working on "frontend-v2" but I want to see how pagination was done 
      in the "admin-dashboard" project

Claude: [executes memorybank_search({ 
          projectId: "admin-dashboard", 
          query: "pagination table listing" 
        })]
        
        In admin-dashboard, pagination was implemented like this...
        [Shows code from the other project]
        
        Would you like me to implement something similar in frontend-v2?

4. Documentation Generation

User: Generate project documentation for new developers
Claude: [executes memorybank_generate_project_docs({ projectId: "my-app" })]
        
        I've generated 6 project knowledge documents:
        - projectBrief.md: General description
        - systemPatterns.md: Architecture and patterns
        - techContext.md: Tech stack
        ...
        
        Also updated the global registry with project responsibilities.
        You can query them anytime with memorybank_get_project_docs

5. Task Orchestration (Multi-Project) ๐Ÿ†•

User: I need to add a UserDTO for the new registration endpoint
Claude: [executes memorybank_route_task({ 
          projectId: "my-api", 
          taskDescription: "Create UserDTO for registration endpoint" 
        })]
        
        The orchestrator analyzed your ecosystem and determined:
        
        โŒ DTOs should NOT be created in my-api
        โœ… DTOs belong to lib-dtos project
        
        I'll delegate the DTO creation to lib-dtos and import it:
        
        [executes memorybank_delegate_task({
          projectId: "my-api",
          targetProjectId: "lib-dtos", 
          title: "Create UserDTO",
          description: "DTO for user registration with email, password fields"
        })]
        
        Task delegated! Once lib-dtos creates the DTO, you can:
        import { UserDTO } from 'lib-dtos'

๐Ÿ”ง Configuration Files

.memoryignore

Similar to .gitignore, specifies patterns to exclude from indexing:

# Dependencies
node_modules/
vendor/

# Build outputs
dist/
build/
*.min.js

# Memory Bank storage
.memorybank/

# Large data files
*.csv
*.log
*.db

# Binary and media
*.exe
*.pdf
*.jpg
*.png
*.mp4

Respecting .gitignore

Memory Bank automatically respects .gitignore patterns in your project, in addition to .memoryignore patterns.


๐Ÿ’ฐ OpenAI Costs

Memory Bank uses text-embedding-3-small which is very economical:

  • Embedding price: ~$0.00002 per 1K tokens

  • Example: 10,000 files ร— 1,000 average tokens = ~$0.20

  • Cache: Embeddings are cached, only regenerated if code changes

  • Incremental: Only modified files are reindexed

Searches are extremely cheap (only 1 embedding per query).

AI Documentation uses reasoning models which are more expensive but only run when explicitly requested.


๐Ÿงช Testing

# Run tests
npm test

# Tests with coverage
npm test -- --coverage

๐Ÿ” Security and Privacy

  • โœ… Local vector store: LanceDB runs on your machine

  • โœ… No telemetry: We don't send data to external servers

  • โœ… Embeddings only: OpenAI only sees code text, not sensitive metadata

  • โœ… Respects .gitignore: Ignored files are not indexed

  • โœ… Secure API key: Read from environment variables, never hardcoded

Recommendations

  1. Don't push .memorybank/ to git (already in .gitignore)

  2. Use .memoryignore to exclude sensitive files

  3. API keys in environment variables, never in code

  4. Verify .env is in .gitignore


๐Ÿ› Troubleshooting

Error: "OPENAI_API_KEY is required"

Solution: Configure your API key in the MCP environment variables.

Error: "No files found to index"

Possible causes:

  1. Directory is empty

  2. All files are in .gitignore/.memoryignore

  3. No recognized code files

Searches return irrelevant results

Solutions:

  1. Increase minScore: Use 0.8 or 0.9 for more precise results

  2. Use filters: filterByFile or filterByLanguage

  3. Rephrase query: Be more specific and descriptive

  4. Reindex: memorybank_index_code({ path: "..." }) (automatically detects changes by hash)

Error: "projectId is required"

Solution: All tools require projectId. Define projectId in your AGENTS.md file so the agent uses it consistently.

Outdated Index

memorybank_get_stats({})

If pendingFiles shows pending files, reindex the directory:

{
  "projectId": "my-project",
  "path": "C:/workspaces/my-project/src"
}

The system automatically detects changes by hash. Only use forceReindex: true if you need to regenerate embeddings even without changes.


๐Ÿ“– Additional Documentation

Instruction Templates

AGENTS.md Format (multi-agent standard):

VS Code / Copilot Format:


๐Ÿค Contributing

Contributions are welcome!

  1. Fork the project

  2. Create your feature branch (git checkout -b feature/AmazingFeature)

  3. Commit changes (git commit -m 'Add some AmazingFeature')

  4. Push to branch (git push origin feature/AmazingFeature)

  5. Open a Pull Request


๐ŸŽ“ Inspiration

This project combines the best concepts from two complementary approaches:

Cursor IDE - Semantic Indexing

The vector indexing and semantic search system is inspired by how Cursor IDE handles code memory:

Cline - Structured Project Documentation

The Project Knowledge Layer system (structured markdown documents) is inspired by the Cline Memory Bank approach:

Documents from the Cline approach we adopted:

Document

Purpose

projectBrief.md

Project requirements and scope

productContext.md

Purpose, target users, problems solved

activeContext.md

Current tasks, recent changes, next steps

systemPatterns.md

Architectural decisions, patterns, relationships

techContext.md

Tech stack, dependencies, configurations

progress.md

Milestones, overall status, known issues

Our Contribution

Memory Bank MCP merges both approaches:

  1. Semantic Search (Cursor-style): Vector embeddings + LanceDB to find relevant code instantly

  2. Structured Documentation (Cline-style): 6 AI-generated markdown documents providing global context

  3. Multi-Project: Unique capability to query multiple indexed projects from any workspace

This combination allows agents to have both precision (semantic search) and global understanding (structured documentation).


๐Ÿ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ†˜ Support


โญ If you find this project useful, consider giving it a star!

Made with โค๏ธ for the AI coding assistants community

Install Server
A
license - permissive license
A
quality
D
maintenance

Maintenance

โ€“Maintainers
โ€“Response time
โ€“Release cycle
โ€“Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/gcorroto/memory-bank-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server