CodeBase Optimizer

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.

Category
Visit Server

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

  1. analyze_project_structure - Analyze project organization and architecture
  2. detect_code_duplicates - Find duplicate code across multiple languages
  3. validate_microservices_architecture - Validate microservices patterns
  4. optimize_configurations - Analyze configuration management
  5. generate_improvement_report - Generate comprehensive actionable report

Master Orchestrator Function

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

  1. Add new analyzers to codebase_optimizer_engine.py
  2. Expose new functions in server.py
  3. Update tool schema for new parameters
  4. Test with various project types

License

MIT License - Feel free to use and modify for your projects.


Made with ā¤ļø for better codebases everywhere

Recommended Servers

playwright-mcp

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.

Official
Featured
TypeScript
Magic Component Platform (MCP)

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.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

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.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

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.

Official
Featured
TypeScript
Kagi MCP Server

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.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

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.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured