codebase-mcp

danyQe/codebase-mcp

3.2

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
  1. create

    Tool for creating new code files or projects.

  2. write

    Tool for writing code into existing files.

  3. read

    Tool for reading and displaying code from files.

  4. execute

    Tool for executing code directly from the server.

๐Ÿš€ Codebase Manager MCP Server

Python MCP License Claude VS Code

Transform your AI coding workflow with powerful codebase management through Model Context Protocol (MCP)

A comprehensive Model Context Protocol (MCP) server that enables Claude AI, VS Code Copilot, and other MCP-compatible AI assistants to seamlessly interact with your codebase. Perform file operations, Git version control, command execution, and project analysisโ€”all through natural language commands.

๐ŸŒŸ Key Features

๐Ÿ“ Complete File System Management

  • Read, write, create, and delete files with AI assistance
  • Directory listing and navigation with detailed file information
  • Smart file search with content scanning capabilities
  • Secure path validation preventing unauthorized access

๐ŸŒฟ Advanced Git Integration

  • Real-time Git status monitoring and reporting
  • Branch management - create, switch, delete, and list branches
  • Commit operations with staged and unstaged change tracking
  • Diff visualization for files and branches
  • Commit history browsing with detailed logs

โšก Command Execution Engine

  • Safe command execution with whitelisted commands
  • Built-in test runners for multiple frameworks
  • Development tool integration (pytest, black, flake8, mypy)
  • Package manager support (npm, pip, cargo, etc.)

๐Ÿ“Š Project Intelligence

  • Dependency analysis across multiple project types
  • Project structure visualization with tree-like display
  • Automated project detection (Python, Node.js, Rust, Java)
  • Real-time project metrics and information

๐ŸŽฏ Perfect For

  • AI-Powered Development - Let Claude manage your codebase
  • Code Review Assistance - Automated analysis and suggestions
  • Project Documentation - Generate docs from codebase analysis
  • Debugging Support - AI-assisted troubleshooting
  • Team Collaboration - Shared codebase understanding
  • Learning & Education - Explore codebases with AI guidance

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.8+
  • Git (for version control features)
  • Claude Desktop or VS Code with Copilot
  • UV (recommended) or pip for package management

๐Ÿ”ง Installation

Option 1: Using UV (Recommended)
# Clone the repository
git clone https://github.com/yourusername/codebase-manager-mcp.git
cd codebase-manager-mcp

# Initialize UV project
uv init --name codebase-mcp-server

# Install dependencies
uv add "mcp[cli]" GitPython

# Test the server
uv run python server.py /path/to/your/project
Option 2: Using Pip
# Clone the repository
git clone https://github.com/yourusername/codebase-manager-mcp.git
cd codebase-manager-mcp

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install "mcp[cli]" GitPython

# Test the server
python server.py /path/to/your/project

โš™๏ธ Claude Desktop Configuration

Create or edit your Claude Desktop configuration file:

๐Ÿ“ Configuration File Locations:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/claude/claude_desktop_config.json
{
  "mcpServers": {
    "codebase-manager": {
      "command": "python",
      "args": ["/absolute/path/to/server.py", "/path/to/your/project"],
      "env": {}
    }
  }
}
For UV Users:
{
  "mcpServers": {
    "codebase-manager": {
      "command": "uv",
      "args": [
        "run", 
        "--project", "/path/to/codebase-manager-mcp",
        "python", "server.py",
        "/path/to/your/project"
      ],
      "env": {}
    }
  }
}

๐ŸŽฎ VS Code Integration

Create .vscode/mcp.json in your project:

{
  "mcp": {
    "servers": {
      "codebase-manager": {
        "command": "python",
        "args": ["/path/to/server.py", "${workspaceFolder}"]
      }
    }
  }
}

๐Ÿ’ก Usage Examples

Once configured, interact with your codebase using natural language:

๐Ÿ“ File Operations

"List all Python files in the src directory"
"Read the contents of main.py"
"Create a new file called utils.py with helper functions"
"Search for files containing 'database' in their name"
"Show me the project structure"

๐ŸŒฟ Git Operations

"What's my current git status?"
"Show me the files I've modified"
"Commit all changes with message 'Add new feature'"
"Create a new branch called 'feature-auth'"
"Show me the last 5 commits"
"What's the diff for auth.py?"

โšก Development Commands

"Run the test suite"
"Execute npm install"
"Check code style with flake8"
"Run black formatter on all Python files"
"Show me Python version"

๐Ÿ“Š Project Analysis

"What dependencies does this project have?"
"Analyze the project structure"
"Show me project information"
"Find all TODO comments in the codebase"

๐Ÿ› ๏ธ Available Tools

ToolDescriptionExample Usage
read_fileRead file contents"Read the README.md file"
write_fileWrite to files"Update config.py with new settings"
list_directoryBrowse directories"List all files in the src folder"
search_filesFind files by pattern"Find all .js files containing 'api'"
git_statusGit repository status"What's my git status?"
git_commitCreate commits"Commit changes with message"
git_branch_operationsBranch management"Create branch feature-x"
execute_commandRun commands"Run pytest on the tests folder"

๐Ÿ”’ Security Features

  • Path Validation: Prevents access outside project directory
  • Command Whitelisting: Only allows safe, pre-approved commands
  • Timeout Protection: Commands timeout after 30 seconds
  • Error Handling: Comprehensive error reporting and recovery
  • Permission Boundaries: Respects file system permissions

๐Ÿ“‹ Project Structure

codebase-manager-mcp/
โ”œโ”€โ”€ server.py                 # Main MCP server
โ”œโ”€โ”€ setup.py                  # Auto-configuration script
โ”œโ”€โ”€ requirements.txt         # Pip dependencies
โ”œโ”€โ”€ README.md               # This file
โ”œโ”€โ”€ LICENSE                 # MIT License

๐Ÿ”ง Advanced Configuration

Multiple Projects

Configure multiple projects simultaneously:

{
  "mcpServers": {
    "project-frontend": {
      "command": "python",
      "args": ["/path/to/server.py", "/path/to/frontend"],
      "env": {}
    },
    "project-backend": {
      "command": "python", 
      "args": ["/path/to/server.py", "/path/to/backend"],
      "env": {}
    }
  }
}

Environment Variables

{
  "mcpServers": {
    "codebase-manager": {
      "command": "python",
      "args": ["/path/to/server.py", "${PROJECT_DIR}"],
      "env": {
        "PROJECT_DIR": "/current/project/path",
        "PYTHONPATH": "/custom/python/path"
      }
    }
  }
}

Custom Command Whitelist

Modify the ALLOWED_COMMANDS in server.py:

ALLOWED_COMMANDS = {
    'python', 'python3', 'pip', 'pip3',
    'node', 'npm', 'yarn', 'pnpm',
    'pytest', 'black', 'flake8', 'mypy',
    'docker', 'docker-compose',
    'your-custom-command'  # Add your commands here
}

๐Ÿšจ Troubleshooting

Common Issues

โŒ Import Error: No module named 'mcp'
# Install MCP SDK
pip install "mcp[cli]"
# or with UV
uv add "mcp[cli]"
โŒ Git operations not working
# Install GitPython
pip install GitPython
# or with UV  
uv add GitPython
โŒ Server not connecting to Claude
  1. Check file paths in configuration
  2. Restart Claude Desktop completely
  3. Verify Python is in system PATH
  4. Test server manually: python server.py /test/path
โŒ Permission denied errors
  • Ensure the project directory exists and is accessible
  • Check file permissions
  • Verify paths are correctly specified

Debug Mode

Test your server locally before connecting to Claude:

# Test with MCP inspector
mcp dev server.py /path/to/project

# Manual testing
python server.py /path/to/project --debug

๐Ÿค Contributing

We welcome contributions! Here's how to get started:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Make your changes and add tests
  4. Ensure all tests pass: pytest tests/
  5. Commit your changes: git commit -m 'Add feature'
  6. Push to your branch: git push origin feature-name
  7. Submit a pull request

Development Setup

# Clone your fork
git clone https://github.com/danyQe/codebase-mcp.git
cd codebase-mcp

# Install development dependencies
uv add --dev pytest black flake8 mypy

# Run tests
uv run pytest

# Format code
uv run black .

# Type checking
uv run mypy server.py

๐Ÿ“„ License

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

๐ŸŒŸ Star History

Star History Chart

๐Ÿ™ Acknowledgments

  • Anthropic for creating the Model Context Protocol
  • Claude AI for inspiring this integration
  • Open Source Community for continuous support and contributions

๐Ÿ“ž Support

๐Ÿท๏ธ Tags

mcp model-context-protocol claude-ai ai-development codebase-management git-integration python automation developer-tools ai-assistant vs-code file-management code-analysis ai-coding productivity


โญ Star this repository if it helped you!

Built with โค๏ธ for the AI development community

Report Bug โ€ข )