danyQe/codebase-mcp
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.
create
Tool for creating new code files or projects.
write
Tool for writing code into existing files.
read
Tool for reading and displaying code from files.
execute
Tool for executing code directly from the server.
๐ Codebase Manager MCP Server
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
Tool | Description | Example Usage |
---|---|---|
read_file | Read file contents | "Read the README.md file" |
write_file | Write to files | "Update config.py with new settings" |
list_directory | Browse directories | "List all files in the src folder" |
search_files | Find files by pattern | "Find all .js files containing 'api'" |
git_status | Git repository status | "What's my git status?" |
git_commit | Create commits | "Commit changes with message" |
git_branch_operations | Branch management | "Create branch feature-x" |
execute_command | Run 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
- Check file paths in configuration
- Restart Claude Desktop completely
- Verify Python is in system PATH
- 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:
- Fork the repository
- Create a feature branch:
git checkout -b feature-name
- Make your changes and add tests
- Ensure all tests pass:
pytest tests/
- Commit your changes:
git commit -m 'Add feature'
- Push to your branch:
git push origin feature-name
- 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
๐ Acknowledgments
- Anthropic for creating the Model Context Protocol
- Claude AI for inspiring this integration
- Open Source Community for continuous support and contributions
๐ Support
- ๐ Bug Reports: GitHub Issues
- ๐ก Feature Requests: GitHub Discussions
- ๐ง Email:
- ๐ฌ Discord: Join our community
๐ท๏ธ 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 โข )