codebase-memory

codebase-memory

MCP server for local codebase memory: semantic indexing, hybrid search, and clean code analysis (static + LLM) with retrievable project notes, designed to run fully local on modest hardware.

Category
Visit Server

README

codebase-memory

Serveur MCP de mémoire de codebase : index sémantique + analyse "clean code", 100 % local, pensé pour être scalable à des machines modestes.

Ce que ça fait

  • Indexation : découpe un dépôt en chunks (AST pour Python, structurel sinon), les plonge en embeddings (fastembed ONNX par défaut — CPU, portable ; backend llama.cpp GPU en option), et les stocke dans un SQLite unique (FTS5 + BLOBs).
  • Recherche hybride : fusion RRF entre BM25 (FTS5) et cosinus sémantique.
  • Analyse clean code : règles statiques (complexité cyclomatique, longueur, TODO, exceptions avalées, duplicats…) + revue LLM (Hermes 4 14B via llama.cpp, ou Gemma 2B via OpenVINO GenAI en fallback CPU léger).
  • Mémoire de conventions : notes projet retrievables sémantiquement.

Démarrage rapide

cd D:\codebase-memory
uv sync                 # installe les dépendances
uv sync --extra openvino   # + fallback Gemma 2B OpenVINO
uv run codebase-memory index D:\mon\repo          # CLI
uv run python -m codebase_memory                  # serveur MCP (stdio)

Plug dans Hermes

# ~/.hermes/config.yaml (clé mcp_servers)
mcp_servers:
  codebase-memory:
    command: "D:\\codebase-memory\\.venv\\Scripts\\python.exe"
    args: ["-m", "codebase_memory"]
    env:
      CODEBASE_MEMORY_EMBED_BACKEND: "fastembed"
      CODEBASE_MEMORY_LLM_BACKEND: "openvino"
      CODEBASE_MEMORY_OV_MODEL_DIR: "D:\\gemma-2b-int4-ov"
    timeout: 300

Outils exposés : mcp_codebase_memory_index_codebase, search_code, analyze_code, remember_note, recall_notes, memory_status.

GitHub Copilot (VS Code)

Copilot Chat / Agent mode sait consommer des serveurs MCP. Dans le workspace que tu veux analyser, crée .vscode/mcp.json (copie de .vscode/mcp.json.example fourni dans ce repo) :

{
  "servers": {
    "codebase-memory": {
      "type": "stdio",
      "command": "uv",
      "args": ["run", "python", "-m", "codebase_memory"],
      "cwd": "${workspaceFolder}/../codebase-memory"
    }
  }
}
  • Ajuste cwd : chemin du clone de codebase-memory (ou clone-le dans le workspace).
  • Recharge VS Code (Reload Window) puis accepte la connexion MCP quand Copilot le propose (onglet Copilot → section "MCP" pour vérifier que le serveur est vert).
  • Indexe d'abord le code : uv run codebase-memory index "C:/chemin/de/ton/workspace".
  • Ensuite, en Agent mode : "cherche où les patches WSI sont extraits", "analyse la qualité de ce fichier" → Copilot appelle mcp_codebase_memory_search_code / analyze_code.

Notes : les outils MCP ne sont utilisables que dans Chat / Agent mode (pas en complétion classique). JetBrains (2025.2+) sait aussi brancher des serveurs MCP pour Copilot (Settings → Tools → MCP Servers).

Installation sur une autre machine

git clone https://github.com/H-Gelender/codebase-memory
cd codebase-memory
uv sync                 # dépendances de base (fastembed ONNX, mcp, radon)
uv sync --extra openvino   # + fallback Gemma 2B OpenVINO (optionnel)
uv run codebase-memory index "C:/chemin/de/mon/repo"   # 1er run : télécharge bge-small (~130 Mo)
uv run codebase-memory search "comment X est implémenté"
uv run codebase-memory analyze "src/module.py"
uv run python -m codebase_memory     # serveur MCP (stdio) pour Hermes / Copilot

Windows + Smart App Control : si le python.exe du venv est bloqué (erreur 4551), base le venv sur un interpréteur déjà autorisé et remplace python.exe/pythonw.exe par des hardlinks (recette détaillée dans le skill Hermes hermes-agentnative-mcp.md).

Configuration par variables d'environnement (CODEBASE_MEMORY_*) : voir src/codebase_memory/config.py (backends embedding/LLM, chemins, seuils).

R&D

Hypothèses, design et résultats de benchmarks : docs/RND_BRIEF.md.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured