SP

sparshdrolia/persistent-code-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

6 stars 6 forks 质量 56 趋势 14

A Model Context Protocol (MCP) server that creates and maintains a semantic knowledge graph of code generated by Claude.

概览

A Model Context Protocol (MCP) server that creates and maintains a semantic knowledge graph of code generated by Claude. Powered by LlamaIndex, this allows maintaining context across sessions with advanced semantic search capabilities without requiring the entire codebase to be present in the context window. When developing software with Claude: - Context windows are limited, making it difficult to work with large codebases - Previous code context is lost between sessions - Claude lacks persistent understanding of project structure - Redundant explanation of code is required in each session - Maintaining implementation consistency is challenging Persistent-Code solves these problems by: - Creating a knowledge graph of code components and their relationships - Tracking implementation status of each component - Providing tools to navigate, query, and understand the codebase - Assembling minimal necessary context for specific coding tasks - Maintaining persistent knowledge across chat...

README

以下为原文 README 节选,完整内容请查看原文。

Persistent-Code MCP Server with LlamaIndex

A Model Context Protocol (MCP) server that creates and maintains a semantic knowledge graph of code generated by Claude. Powered by LlamaIndex, this allows maintaining context across sessions with advanced semantic search capabilities without requiring the entire codebase to be present in the context window.

Problem & Solution

When developing software with Claude:

  • Context windows are limited, making it difficult to work with large codebases
  • Previous code context is lost between sessions
  • Claude lacks persistent understanding of project structure
  • Redundant explanation of code is required in each session
  • Maintaining implementation consistency is challenging

Persistent-Code solves these problems by:

  • Creating a knowledge graph of code components and their relationships
  • Tracking implementation status of each component
  • Providing tools to navigate, query, and understand the codebase
  • Assembling minimal necessary context for specific coding tasks
  • Maintaining persistent knowledge across chat sessions

LlamaIndex Integration

Persistent-Code leverages LlamaIndex to provide enhanced semantic understanding:

  1. Semantic Search: Find code components based on meaning, not just keywords
  2. Vector Embeddings: Code is embedded into vector space for similarity matching
  3. Knowledge Graph: Relationships between components are tracked semantically
  4. Contextual Retrieval: Related code is retrieved based on semantic relevance

This integration allows Claude to understand your codebase at a deeper level:

  • Find functions based on what they do, not just what they’re called
  • Get more relevant code components when preparing context
  • Better understand the relationships between components
  • More accurately retrieve examples of similar implementations

Installation

Prerequisites

  • Python 3.10 or higher
  • UV package manager (recommended) or pip

Setting Up

# Clone repository
git clone https://github.com/your-username/persistent-code-mcp.git
cd persistent-code-mcp

# Set up environment with UV
uv venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
uv pip install -r requirements.txt

# Or with pip
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt

Usage

Initializing a Project

python -m persistent_code init --project-name "YourProject"

Starting the Server

python -m persistent_code serve --project-name "YourProject"

Configuring Claude for Desktop

  1. Edit your Claude for Desktop config file:
    • Location: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Add the following configuration:
{
  "mcpServers": {
    "persistent-code": {
      "command": "path to python in venv",
      "args": [
        "-m",
        "persistent_code",
        "serve",
        "--project-name",
        "default"
      ],
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "persistent-code": { "command": "path to python in venv", "args": [ "-m", "persistent_code", "serve", "--project-name", "default" ], "cwd": "persistent-code-mcp", "env": { "PYTHONPATH": "abs path to persistent-code-mcp" } } } }