codebase-mcp

danyQe/codebase-mcp

3.3

If you are the rightful owner of codebase-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

Model Context Protocol (MCP) servers are designed to manage and control codebases efficiently using various tools and resources.

Tools
4
Resources
0
Prompts
0

Codebase MCP

Privacy-first AI development assistant via MCP | Turn Claude into your personal coding assistant | Semantic code search β€’ AI-assisted editing β€’ Quality-checked generation β€’ Persistent memory | Free open-source alternative to Cursor & paid AI coding tools | Python, React, TypeScript, FastAPI

Open Source**

Python MCP Version

Codebase MCP is an open-source AI-powered development assistant that connects Claude Desktop (or any MCP-compatible LLM) to your codebase through the Model Context Protocol. Stop paying for separate coding assistants - if you already have a Claude subscription, that's all you need.

πŸ“– Read Full Documentation | πŸ—οΈ | 🀝


🌟 Why Codebase MCP?

The Problem

Modern AI coding assistants like Cursor, Windsurf, and others charge $20-40+/month on top of your existing LLM subscription. If you already pay for Claude, why pay again for a coding assistant?

The Solution

Codebase MCP turns your existing Claude subscription into a powerful coding assistant:

  • βœ… One subscription - Use your existing Claude Pro/Team plan
  • βœ… Privacy-first - Local embeddings and processing (except edit operations)
  • βœ… Open source - Apache 2.0 license, community-driven
  • βœ… Extensible - Works with any MCP-compatible LLM via Model Context Protocol
  • βœ… Lightweight - ~100MB memory footprint for medium projects
  • βœ… Fast - Sub-second semantic search with local FAISS indexing

⚑ Quick Start

Prerequisites

  • Python 3.11+
  • Claude Desktop (or any MCP-compatible client)
  • Git installed
  • uv package manager (recommended)

Installation

1. Clone the repository:

git clone https://github.com/danyQe/codebase-mcp.git
cd codebase-mcp

2. Install globally (recommended):

# Install uv if you haven't
pip install uv

# Create virtual environment and install dependencies
uv venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
uv pip install -r requirements.txt

# Install formatters globally (required for code formatting)
pip install black ruff

3. Configure Gemini API (for edit tool):

# Create .env file
cp .env.example .env

# Get free API key from: https://aistudio.google.com/app/apikey
# Add to .env:
GEMINI_API_KEY=your_api_key_here

4. Configure Claude Desktop:

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "codebase-manager": {
      "command": "/path/to/your/.venv/bin/python",
      "args": [
        "/path/to/codebase-mcp/mcp_server.py"
      ]
    }
  }
}

5. Start the FastAPI server:

# In a separate terminal, navigate to your project directory
python main.py /path/to/your/project

# Server starts on http://localhost:6789
# You can access the web dashboard at: http://localhost:6789

6. Use with Claude Desktop:

  • Restart Claude Desktop
  • Start chatting - Claude now has access to 13+ MCP tools for codebase management!

🎯 Key Features

πŸ” Semantic Code Search

  • AI-powered code understanding with local embeddings
  • Multi-language support (Python, JavaScript, TypeScript)
  • Symbol-level indexing (functions, classes, interfaces)
  • Fuzzy search and exact matching modes

🧠 Persistent Memory System

  • Remember context across chat sessions
  • Categorize learnings: progress, mistakes, solutions, architecture
  • Semantic memory search with importance scoring
  • Never repeat the same mistake twice

🌿 Session-Based Git Workflow

  • Isolated development branches for each feature
  • Automatic commit tracking in .codebase directory
  • Separate from user's .git - track AI changes independently
  • Auto-merge support with quality gates

✍️ Intelligent Code Writing

  • Write Tool: Create new files with auto-formatting and quality scoring
  • Edit Tool: AI-assisted editing with Gemini integration (inspired by Cursor)
  • Quality Gates: Auto-commit only when code quality β‰₯ 80%
  • Dependency Checking: Prevent code duplication and missing imports

🎨 Auto-Formatting

  • Python: Black + Ruff (PEP 8 compliant)
  • TypeScript/JavaScript: Prettier + ESLint
  • Quality Scoring: Automatic code quality assessment
  • Error Recovery: Intelligent retry with corrections

πŸ“Š Project Intelligence

  • Real-time codebase analysis
  • File structure visualization
  • Dependency tracking
  • Symbol extraction and indexing

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Claude Desktop  β”‚  User interacts via chat
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚ MCP Protocol (stdio)
         ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   MCP Server    β”‚  13+ Tools (proxy layer)
β”‚  (mcp_server.py)β”‚  Lightweight, fast
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚ HTTP/REST
         ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ FastAPI Server  β”‚  Port 6789 (main.py)
β”‚   Core Engine   β”‚  40+ API endpoints
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
    β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    ↓          ↓         ↓          ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚Semanticβ”‚ β”‚Memoryβ”‚ β”‚  Git   β”‚ β”‚Code Tools β”‚
β”‚ Search β”‚ β”‚Systemβ”‚ β”‚Manager β”‚ β”‚  Pipeline β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
    β”‚          β”‚         β”‚          β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               ↓
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚   Local Storage      β”‚
    β”‚ β€’ FAISS (vectors)    β”‚
    β”‚ β€’ SQLite (metadata)  β”‚
    β”‚ β€’ .codebase (git)    β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Privacy Note: All processing is local except the edit tool, which uses Google's free Gemini API for AI-assisted code editing. Only the edited file is sent to Gemini - no project context or history.


πŸ› οΈ Available Tools

Codebase MCP provides 13 specialized MCP tools for comprehensive development automation:

ToolPurposeKey Features
session_toolManage dev sessionsCreate branches, auto-commit, merge
memory_toolStore/retrieve knowledgePersistent context, semantic search
git_toolGit operationsStatus, diff, log, commit, branches
write_toolIntelligent file creationAuto-format, quality scoring, dependency check
edit_fileAI-assisted editingGemini-powered, error recovery, format validation
search_toolSemantic code search4 modes: semantic, fuzzy, text, symbol
read_code_toolSmart code readingSymbol-level, line ranges, whole file
project_context_toolProject analysisStructure, dependencies, overview
list_directory_toolDirectory explorationTree view, metadata, gitignore support
code_analysis_toolCode quality checksSyntax, linting, imports, dependencies
list_file_symbols_toolSymbol extractionFunctions, classes, interfaces
read_symbol_from_databaseDB symbol lookupFast indexed retrieval
project_structure_toolProject visualizationEnhanced tree with stats

πŸ“ˆ Performance

  • Semantic Search: Sub-second response for typical codebases
  • Memory Footprint: ~100MB for medium projects (<20k lines)
  • Indexing Speed: ~30 seconds for 10k lines initial index
  • Edit Operations: 5-15 seconds (Gemini API + formatting)
  • Optimal Project Size: <20,000 lines (tested and verified)

Note: Edit tool can be slow due to Gemini API latency and code formatting. Claude Desktop may timeout on very large edits (use smaller, focused edits).


πŸŽ“ Usage Examples

Creating a New Feature

User: "Create a FastAPI endpoint for user authentication with JWT tokens"

Claude:
βœ… Searching for existing auth patterns...
βœ… Creating session: feat/user-auth
βœ… Writing authentication.py with JWT implementation
βœ… Auto-formatted with Black + Ruff
βœ… Quality score: 95% - Auto-committed
βœ… Storing solution in memory

Refactoring Code

User: "Refactor the user service to use dependency injection"

Claude:
βœ… Reading current user service implementation
βœ… Searching for DI patterns in codebase
βœ… Editing with AI assistance (Gemini)
βœ… Validating changes with quality gates
βœ… Session: refactor/user-di ready for review

Memory-Driven Development

User: "Continue working on the payment integration"

Claude:
βœ… Loading memory context...
βœ… Found previous progress: Stripe API setup complete
βœ… Found previous mistake: Don't use synchronous requests in async endpoints
βœ… Continuing from last checkpoint...

πŸ” Privacy & Security

Privacy-First Design

  • Local Embeddings: AllMiniLM-L6-v2 runs entirely on your machine
  • Local Processing: FAISS vector store, SQLite metadata - all local
  • No Cloud Dependencies: Except for Gemini API (edit tool only)

Gemini API Usage

  • Scope: Only edit_file tool uses Gemini
  • Data Sent: Only the file being edited (no project context)
  • Alternative: Contributors can add local LLM support (GPU required)
  • Cost: Free tier (15 RPM, 250K TPM, 1K RPD)

Security Best Practices

  • Never commit .env with API keys
  • Use .gitignore for sensitive files
  • Review AI-generated code before production deployment
  • Keep dependencies updated

🀝 Contributing

We welcome contributions! This project was built to be community-driven and extensible.

Priority Areas:

  • 🌐 Language Support: Add Java, Go, Rust, PHP, etc.
  • 🧠 Local LLM Integration: Replace Gemini with local models
  • πŸ” Search Improvements: Enhanced semantic algorithms
  • πŸ“Š UI/UX: Improve web dashboard
  • ⚑ Performance: Optimization for larger codebases

See for detailed guidelines.


πŸ“„ License

This project is licensed under the Apache License 2.0 - see file for details.

Credits:


πŸ—ΊοΈ Roadmap

Current Version: v1.0.0-beta

Upcoming Features:

  • Community-driven enhancements
  • More language support
  • Local LLM alternatives
  • Performance optimizations
  • Advanced prompt engineering templates

πŸ“ž Support


πŸŽ‰ Acknowledgments

Special thanks to:

  • Anthropic for Claude and the Model Context Protocol
  • Google for the free Gemini API
  • Cursor team for pioneering AI-assisted editing techniques
  • Open source community for making this possible

Made with ❀️ by developers, for developers

Stop paying for coding assistants. Start building with your own LLM.