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.
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:
Persistent-Code solves these problems by:
Persistent-Code leverages LlamaIndex to provide enhanced semantic understanding:
This integration allows Claude to understand your codebase at a deeper level:
# 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
python -m persistent_code init --project-name "YourProject"
python -m persistent_code serve --project-name "YourProject"
~/Library/Application Support/Claude/claude_desktop_config.json
{ "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" } } } }
add_component
: Add a new code component to the graphupdate_component
: Update an existing componentadd_relationship
: Create a relationship between componentsget_component
: Retrieve a component by ID or namefind_related_components
: Find components related to a given componentsearch_code
: Search the codebase semanticallyupdate_status
: Update implementation status of a componentget_project_status
: Retrieve implementation status across the projectfind_next_tasks
: Suggest logical next components to implementprepare_context
: Assemble minimal context for a specific taskcontinue_implementation
: Provide context to continue implementing a componentget_implementation_plan
: Generate a plan for implementing pending componentsanalyze_code
: Analyze code and update the knowledge graphInitialize 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
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".
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.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
Discover shared experiences
Shared threads will appear here, showcasing real-world applications and insights from the community. Check back soon for updates!