CodePilot
An autonomous AI software engineer and MCP server that uses LangGraph and a hybrid RAG index to autonomously edit, test, and debug codebases.
README
CodePilot
[!WARNING] Work in Progress (WIP): This project is under active development. Some components and agents are currently being optimized and refined.
CodePilot is a production-grade, autonomous AI software engineer and Model Context Protocol (MCP) server. It leverages LangGraph for task planning and execution, and uses a hybrid RAG index (combining SQLite for relational symbol mapping and ChromaDB for semantic code search) to edit, test, and debug codebases autonomously.
๐๏ธ System Architecture
CodePilot decouples the Editor UI/Extension from the AI Agent Runtime using the MCP protocol.
VS Code / Client (e.g. Cursor, Cline, Roo Code)
โ
โ MCP (stdio)
โผ
FastMCP Server (Python)
โ
โผ
LangGraph Supervisor
โ
Planner โโโบ Task Scheduler (Conditional Routing)
โ
โโโโโโโโโโโโโโโโโฌโโโโโโโโดโโโโโโโโฌโโโโโโโโโโโโโโโโ
โผ โผ โผ โผ
Retriever Coder Agent Tester Node Reflection
โ โ โ โ
โผ โผ โผ โผ
SQLite / Chroma Reviewer Gate Test Runner Git Safety Commit
โ
โผ
Patch Generator (Search/Replace Matcher)
โก Prerequisites
To run CodePilot locally, ensure the following are installed:
- Python >= 3.10
- Git
- Ollama (for local offline LLM execution):
- Download and run Ollama
- Pull the chat and embedding models in your terminal:
ollama pull qwen2.5-coder:1.5b ollama pull nomic-embed-text
๐ฆ Installation & Setup
-
Activate the Conda Environment:
conda activate codepilot -
Install CodePilot in Editable Mode:
python -m pip install -e . -
Configure Environment Variables (Optional): Create a
.envfile in the root directory:LLM_PROVIDER=ollama LLM_MODEL=qwen2.5-coder:1.5b OLLAMA_BASE_URL=http://localhost:11434
๐งช How to Verify and Run Tests
Run the full suite of unit tests to verify git safety tools, AST parser, indexers, scheduler graph routing, and FastMCP registration:
# Run all Phase 1-5 test suites
python -m unittest discover -s tests
To run a specific test suite directly:
# Test AST Parsers & DB RAG
python -m unittest tests/test_phase2.py
# Test LangGraph Compilation & Scheduler
python -m unittest tests/test_phase3.py
# Test FastMCP Server Registrations
python -m unittest tests/test_phase4.py
๐ Usage Guide
1. Direct Execution via CLI
Use the command-line interface to execute the autonomous coding agent directly on a codebase:
python main.py --query "Your task description" --repo "path/to/target/repository" --max-iterations 3
--query: The task you want the agent to accomplish (e.g. "Add JWT validation helper functions to auth.py").--repo: Absolute or relative path to the codebase repository you want CodePilot to index, modify, test, and commit.--max-iterations: The maximum number of self-healing compile/test debugging retries allowed before rolling back.
2. Stateful Interactive Shell Mode
Start CodePilot without a --query parameter to enter a stateful, interactive shell loop. The agent will greet you and keep track of modified files and conversation history across follow-up queries:
python main.py --repo "path/to/target/repository"
3. Integration via MCP Server (VS Code, Cursor, Claude)
Start the MCP server using:
python apps/mcp_server/server.py
To integrate CodePilot with client tools, register the Python script as an MCP server stdio transport in your settings.
Cursor Configuration
Add a new MCP server in Cursor settings (Cursor Settings -> Features -> MCP):
- Name: CodePilot
- Type:
stdio - Command:
conda run -n codepilot python "path/to/CodePilot/apps/mcp_server/server.py"
Claude Desktop Configuration
Add the following to your claude_desktop_config.json:
{
"mcpServers": {
"codepilot": {
"command": "conda",
"args": [
"run",
"-n",
"codepilot",
"python",
"path/to/CodePilot/apps/mcp_server/server.py"
]
}
}
}
โ๏ธ Modular Safety Strategy
- Git Safe Guarding: Before applying any changes, CodePilot creates a temporary safety commit. If linter checks or pytest runs fail during verification, CodePilot automatically rolls back modifications, leaving your active workspace clean and untouched.
- Fuzzy Matcher: The patching agent writes exact Search/Replace blocks. If minor spacing or indentation variations exist in the files, CodePilot's fuzzy sliding-window matcher resolves them safely.
# Create a Tic-Tac-Toe game
python main.py --query "Create a Tic-Tac-Toe game in game.py with a simple text UI" --repo projects/tictactoe
# Create a Flask app
python main.py --query "Create a Flask app in app.py with a /hello endpoint" --repo projects/flask_demo
# Add tests
python main.py --query "Create tests/test_calculator.py with pytest tests for add, subtract" --repo projects/codepilot_calc
# Interactive mode (type multiple queries)
python main.py --repo projects/codepilot_calc
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.