
Persistent-Code MCP Server
Creates and maintains a semantic knowledge graph of code that allows maintaining context across sessions with Claude, providing advanced search capabilities without requiring the entire codebase in the context window.
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:
- Semantic Search: Find code components based on meaning, not just keywords
- Vector Embeddings: Code is embedded into vector space for similarity matching
- Knowledge Graph: Relationships between components are tracked semantically
- 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
- Edit your Claude for Desktop config file:
- Location:
~/Library/Application Support/Claude/claude_desktop_config.json
- Add the following configuration:
- Location:
{
"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"
}
}
}
}
- Restart Claude for Desktop
- Connect to your MCP server by asking Claude about your code
Available Tools
Knowledge Graph Management
add_component
: Add a new code component to the graphupdate_component
: Update an existing componentadd_relationship
: Create a relationship between components
Code Retrieval and Navigation
get_component
: Retrieve a component by ID or namefind_related_components
: Find components related to a given componentsearch_code
: Search the codebase semantically
Status Management
update_status
: Update implementation status of a componentget_project_status
: Retrieve implementation status across the projectfind_next_tasks
: Suggest logical next components to implement
Context Assembly
prepare_context
: Assemble minimal context for a specific taskcontinue_implementation
: Provide context to continue implementing a componentget_implementation_plan
: Generate a plan for implementing pending components
Code Analysis
analyze_code
: Analyze code and update the knowledge graph
Example Workflow
-
Initialize a project:
python -m persistent_code init --project-name "TodoApp"
-
Start the server:
python -m persistent_code serve --project-name "TodoApp"
-
Ask Claude to design your project:
Can you help me design a Todo app with Python and FastAPI? Let's start with the core data models.
-
Claude will create components and track them in the knowledge graph
-
Continue development in a later session:
Let's continue working on the Todo app. What's our implementation status?
-
Claude will retrieve the current status and suggest next steps
-
Implement specific components:
Let's implement the task completion endpoint for our Todo app
-
Claude will retrieve relevant context and provide consistent implementation
Using Semantic Search
With the LlamaIndex integration, you can now use more natural language to find components:
Find me all code related to handling task completion
Claude will use semantic search to find relevant components, even if they don't explicitly contain the words "task completion".
Running the LlamaIndex Demo
We've included a demo script to showcase the semantic capabilities:
# Activate your virtual environment
source .venv/bin/activate # or source venv/bin/activate
# Run the demo
python examples/llama_index_demo.py
This will demonstrate analyzing a Calendar application and performing semantic searches for functionality.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Recommended Servers
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.
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.
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.

VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
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.
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.

E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
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.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.