Track 2: MCP in Action - Enterprise Applications
An autonomous AI agent that modernizes legacy codebases through intelligent planning, reasoning, and execution using Model Context Protocol (MCP) tools.
Legacy Code Modernizer is a complete autonomous agent system that transforms outdated code into modern, secure, and maintainable software. The agent autonomously:
- Plans - Analyzes codebases and creates modernization strategies
- Reasons - Makes intelligent decisions about transformation priorities
- Executes - Applies transformations, generates tests, and validates changes
- Integrates - Creates GitHub PRs with comprehensive documentation
Multi-Phase Planning & Reasoning:
- Phase 1: Intelligent file discovery and classification using AI pattern detection
- Phase 2: Semantic code analysis with vector-based similarity search (LlamaIndex + Chroma)
- Phase 3: Deep pattern analysis using multiple AI models (Gemini, Nebius AI)
- Phase 4: Autonomous code transformation with context-aware reasoning
- Phase 5: Automated testing in isolated sandbox + GitHub PR creation
Context Engineering & RAG:
- Vector embeddings for semantic code search
- Pattern grouping across similar files
- Historical transformation caching via MCP Memory
- Real-time migration guide retrieval via MCP Search
The agent uses 4 MCP servers as autonomous tools:
- GitHub MCP - Autonomous PR creation with comprehensive documentation
- Tavily Search MCP - Real-time migration guide discovery
- Memory MCP - Pattern analysis caching and learning
- Filesystem MCP - Safe file operations (planned)
- Multi-language support: Python, Java, JavaScript, TypeScript
- Secure execution: Modal sandbox with isolated test environments
- Production-ready: Comprehensive test generation with coverage reporting
- Upload a code file (Python, Java, JavaScript, TypeScript)
- Select target version (auto-detected from your code)
- Click "Start Modernization"
- Watch the autonomous agent work through all 5 phases
- Download modernized code, tests, and reports
# Clone repository
git clone https://huggingface.co/spaces/MCP-1st-Birthday/legacy_code_modernizer_agent
cd legacy_code_modernizer_agent
# Set up environment variables
cp .env.example .env
# Edit .env with your API keys:
# - GEMINI_API_KEY (required)
# - GITHUB_TOKEN (for PR creation)
# - TAVILY_API_KEY (for search)
# - MODAL_TOKEN_ID & MODAL_TOKEN_SECRET (for sandbox)
# Set up Python virtual environment
# On macOS / Linux:
source venv/bin/activate
# On Windows PowerShell:
.\venv\Scripts\Activate.ps1
# On Windows CMD:
venv\Scripts\activate.bat
# Install dependencies
pip install -r requirements.txt
# Run the Gradio app
python app.pyInput: Legacy codebase
β
Agent analyzes file structure and content
β
Classifies files by modernization priority
β
Creates transformation roadmap
Agent groups similar patterns using vector search
β
Retrieves migration guides via Tavily MCP
β
Checks cached analyses via Memory MCP
β
Prioritizes transformations by risk/impact
Agent transforms code with AI models
β
Generates comprehensive test suites
β
Validates in isolated Modal sandbox
β
Auto-fixes export/import issues
Agent creates GitHub branch via GitHub MCP
β
Commits transformed files
β
Generates PR with deployment checklist
β
Adds rollback plan and test results
- Google Gemini - Primary reasoning engine with large context window
- Nebius AI - Alternative model for diverse perspectives
- LlamaIndex - RAG framework for semantic code search
- Chroma - Vector database for embeddings
- bge-large-en - Embedding model deployed on Modal for inference
- mcp (v1.22.0) - Model Context Protocol SDK
- @modelcontextprotocol/server-github - GitHub operations
- @modelcontextprotocol/server-tavily - Web search
- @modelcontextprotocol/server-memory - Persistent storage
- Modal - Serverless sandbox for secure test execution
- pytest/Jest/JUnit - Language-specific test frameworks
- Coverage.py/JaCoCo - Code coverage analysis
- Gradio 6.0 - Interactive web interface
- LangGraph - Agent workflow orchestration
- asyncio - Asynchronous execution
# Agent automatically detects legacy patterns:
- Deprecated libraries (MySQLdb β PyMySQL)
- Security vulnerabilities (SQL injection)
- Python 2 syntax β Python 3
- Missing type hints
- Old-style string formatting# Vector-based similarity search finds:
- Files with similar legacy patterns
- Related security vulnerabilities
- Common refactoring opportunities# Agent generates:
- Unit tests with pytest/Jest/JUnit
- Integration tests
- Edge case coverage
- Performance benchmarks# Automated PR includes:
- Comprehensive change summary
- Test results with coverage
- Risk assessment
- Deployment checklist
- Rollback plan- Versions: 3.10, 3.11, 3.12, 3.13, 3.14
- Frameworks: Django 5.2 LTS, Flask 3.1, FastAPI 0.122
- Testing: pytest with coverage
- Versions: Java 17 LTS, 21 LTS, 23, 25 LTS
- Frameworks: Spring Boot 3.4, 4.0
- Testing: Maven + JUnit 5 + JaCoCo
- Standards: ES2024, ES2025
- Runtimes: Node.js 22 LTS, 24 LTS, 25
- Frameworks: React 19, Angular 21, Vue 3.5, Express 5.1, Next.js 16
- Testing: Jest with coverage
- Versions: 5.6, 5.7, 5.8, 5.9
- Frameworks: React 19, Angular 21, Next.js 16
- Testing: Jest with ts-jest
- Network isolation: No external network access during tests
- Filesystem isolation: Temporary containers per execution
- Resource limits: CPU and memory constraints
- Automatic cleanup: Containers destroyed after execution
- Syntax checking: Pre-execution validation
- Import/export fixing: Automatic resolution of module issues
- Security scanning: Detection of vulnerabilities
- Type checking: Language-specific validation
- Sliding window context: Manages large files efficiently
- Cross-file analysis: Understands dependencies
- Pattern learning: Improves with usage via Memory MCP
- Semantic chunking: Intelligent code splitting
- Vector similarity: Finds related patterns
- Hybrid search: Combines keyword + semantic search
- Priority scoring: Risk vs. impact analysis
- Dependency tracking: Understands file relationships
Built for MCP's 1st Birthday Hackathon hosted by Anthropic and Gradio.
Powered by:
- Google Gemini & Nebius AI
- Model Context Protocol (MCP)
- LlamaIndex & Chroma
- Modal
- Gradio
Autonomous agents + MCP tools = The future of software development