CodeBase Optimizer
Provides comprehensive codebase analysis including project structure evaluation, cross-language duplicate detection, microservices validation, and configuration optimization with AI-powered pattern learning that generates actionable improvement reports.
README
CodeBase Optimizer MCP Tool
A sophisticated Model Context Protocol (MCP) server that provides comprehensive codebase analysis, optimization, and duplicate detection capabilities for Claude Code.
Features
🔍 Comprehensive Analysis
- Project structure and architecture detection
- Cross-language code duplication detection
- Microservices architecture validation
- Configuration optimization analysis
- Security and performance insights
🤖 AI-Powered Learning
- Pattern recognition that improves with each use
- Project-specific recommendations
- Historical analysis tracking
- Custom rule learning
🚀 Zero Setup Required
- Integrates directly with Claude Code
- No additional installations needed
- Works with any programming language
- Portable across all projects
Available Tools
Individual Analysis Functions
analyze_project_structure- Analyze project organization and architecturedetect_code_duplicates- Find duplicate code across multiple languagesvalidate_microservices_architecture- Validate microservices patternsoptimize_configurations- Analyze configuration managementgenerate_improvement_report- Generate comprehensive actionable report
Master Orchestrator Function
run_complete_project_analysis- 🎯 ONE-COMMAND COMPLETE ANALYSIS- Runs all analyses in optimal order
- Provides prioritized action plan
- Generates health score and improvement roadmap
Installation & Setup
1. Install Dependencies
pip install mcp sqlite3
2. Add to Claude Code MCP Configuration
Add this to your Claude Code MCP configuration:
{
"mcpServers": {
"codebase-optimizer": {
"command": "python",
"args": ["/Users/liadgez/Documents/codebase-optimizer-mcp/server.py"],
"env": {
"PYTHONPATH": "/Users/liadgez/Documents/codebase-optimizer-mcp"
}
}
}
}
3. Restart Claude Code
The tool will be automatically available in all Claude Code sessions.
Usage Examples
Quick Project Health Check
Use run_complete_project_analysis with path "/path/to/your/project"
Focused Duplicate Detection
Use detect_code_duplicates with path "/path/to/project" and languages ["python", "javascript"]
Microservices Validation
Use validate_microservices_architecture with path "/path/to/microservices/project"
Comprehensive Report
Use generate_improvement_report with path "/path/to/project"
Output Examples
Health Score Dashboard
Health Score: 87/100
- Organization Score: 0.9/1.0
- Duplication: 3.2%
- Security Score: 0.95/1.0
Prioritized Recommendations
🔴 HIGH: Address security issues in configuration files
🟡 MEDIUM: Consolidate 12 duplicate functions into shared modules
🟢 LOW: Standardize naming conventions across directories
Action Plan
Phase 1: Critical Issues (1-2 days)
- Fix environment variable exposure
- Remove hardcoded secrets
Phase 2: Improvements (3-5 days)
- Refactor duplicate code blocks
- Standardize API error handling
Supported Languages
- Python (.py)
- JavaScript (.js)
- TypeScript (.ts)
- Java (.java)
- Go (.go)
- Rust (.rs)
- C/C++ (.c, .cpp)
- PHP (.php)
- Ruby (.rb)
Learning & Improvement
The tool automatically:
- Learns patterns from each project analyzed
- Builds knowledge database of common issues
- Improves recommendations based on past successes
- Adapts to your specific coding patterns
Troubleshooting
Common Issues
Tool not appearing in Claude Code:
- Verify MCP configuration path is correct
- Restart Claude Code after adding configuration
- Check Python dependencies are installed
Analysis fails:
- Ensure project path exists and is accessible
- Check that Python can read the project directory
- Verify no permission issues on the project folder
Performance issues:
- Large projects (>10k files) may take longer to analyze
- Use "quick" depth for faster analysis on huge codebases
- Pattern database improves performance over time
Technical Details
Architecture
- Engine: Sophisticated analysis engine with ML pattern recognition
- Database: SQLite for pattern learning and improvement tracking
- MCP Server: Standards-compliant Model Context Protocol implementation
- Extensibility: Plugin system for custom analyzers
Data Storage
- Pattern database stored in
codebase_patterns.db - No sensitive data stored - only patterns and metrics
- Database grows smarter with each project analyzed
Contributing
To extend the tool:
- Add new analyzers to
codebase_optimizer_engine.py - Expose new functions in
server.py - Update tool schema for new parameters
- Test with various project types
License
MIT License - Feel free to use and modify for your projects.
Made with ❤️ for better codebases everywhere
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。