๐ Tutorial 2: Working with Existing Projects
Learning Goal: Master analyzing existing codebases, discovering implicit architectural decisions, and creating comprehensive documentation for established projects.
Prerequisites:
- Completed Tutorial 1: Your First MCP Analysis
- Understanding of basic MCP concepts
- Access to an existing codebase
Time Required: 45 minutes
๐ What You'll Learnโ
- Project Discovery - Systematically analyze existing codebases
- Implicit Decision Detection - Find undocumented architectural choices
- ADR Generation from Code - Create documentation for existing decisions
- Gap Analysis - Identify missing documentation and decisions
- Legacy Integration - Work with existing documentation and patterns
๐ก Resuming Previous Work? Use @.mcp-server-context.mdโ
Quick Context Recoveryโ
If you're returning to a project you've analyzed before, the .mcp-server-context.md file is your best friend. Instead of re-running analysis or trying to remember what you discovered, simply ask:
@.mcp-server-context.md What was I working on? Show me the active intents
and what analysis has been done on this project.
The AI will tell you:
- What ADRs were suggested or created
- Which tools you used last time
- Patterns that were discovered
- Your last architecture score
- Recommended next steps
Real Exampleโ
You (after a week away):
@.mcp-server-context.md I'm back to work on the microservices migration project.
What's the current status and what should I focus on?
AI Response:
Based on the context file, you were working on:
1. **Active Intent**: Microservices communication strategy (started 7 days ago)
- Status: 60% complete
- Last action: Analyzed API gateway options
2. **Discovered Patterns**:
- Monolithic architecture (95% confidence)
- REST API design (88% confidence)
3. **Current Score**: 72/100 (up 8 points from initial)
4. **Next Steps**:
- Complete ADR for service communication
- Define service boundaries
- Plan data consistency strategy
Why This Matters for Existing Projectsโ
Existing projects often involve:
- Long analysis sessions spread across days/weeks
- Multiple team members working on different aspects
- Complex decision trees that need to be remembered
- Historical context that's easy to lose
The context file solves all of these problems automatically!
๐ Step 1: Comprehensive Project Discoveryโ
Understanding What You're Working Withโ
When analyzing an existing project, you need to understand:
- Technology stack and dependencies
- Architectural patterns and design choices
- Existing documentation and standards
- Team conventions and practices
- Live infrastructure and deployment state (using research-driven analysis)
Research-Driven Discoveryโ
Before running deep analysis, use research-driven tools to query your live environment:
{
"tool": "perform_research",
"parameters": {
"question": "What is the complete technology stack, deployment infrastructure, and architectural patterns in this existing project?",
"projectPath": ".",
"adrDirectory": "./adrs"
}
}
What the Research-Orchestrator Does:
- Scans Project Files: Analyzes package.json, requirements.txt, go.mod, etc.
- Queries Knowledge Graph: Checks existing ADRs for documented decisions
- Probes Live Environment: Detects Docker, Podman, kubectl, oc (OpenShift), ansible
- Assigns Confidence Score: Tells you how reliable the findings are
- Falls Back to Web Search: If confidence < 60%, searches for best practices
Example Output:
## Research Results
**Confidence**: 92.0% โ (High confidence, no web search needed)
### Technology Stack
- **Backend**: Node.js 20.x with Express.js 4.18.x
- **Database**: PostgreSQL 15.x (found in docker-compose.yml)
- **Frontend**: React 18.x with TypeScript
- **Container Orchestration**: Docker Compose (local), Kubernetes (production)
### Infrastructure Capabilities Detected
โ docker - Container runtime available
โ docker-compose - Multi-container orchestration
โ kubectl - Kubernetes CLI configured
โ oc - OpenShift CLI detected (Red Hat ecosystem)
โ podman - Not installed
โ ansible - Configuration management available
### Architectural Insights
- Microservices architecture with 3 services
- Event-driven communication via message queue
- RESTful API design with versioning
- Documented in ADR-001, ADR-003, ADR-007
Run Deep Analysisโ
Start with a comprehensive ecosystem analysis:
{
"tool": "analyze_project_ecosystem",
"parameters": {
"projectPath": ".",
"enhancedMode": true,
"knowledgeEnhancement": true,
"learningEnabled": true,
"includeEnvironment": true,
"recursiveDepth": "comprehensive"
}
}
What to Look For:
- Detected Technologies - Languages, frameworks, databases
- Architecture Patterns - MVC, microservices, monolith, etc.
- Code Organization - Directory structure and module organization
- Dependencies - External libraries and their versions
- Configuration - Environment setup and deployment configs
Exercise: Project Inventoryโ
Take 10 minutes to review the analysis results and answer:
- What is the primary technology stack?
- What architectural pattern is being used?
- Are there any outdated dependencies or technologies?
- What's the overall complexity level?
- Are there any obvious architectural concerns?
๐ Step 2: Discover Existing ADRsโ
Check for Current Documentationโ
Many projects have some architectural documentation, even if not formal ADRs.
{
"tool": "discover_existing_adrs",
"parameters": {
"adrDirectory": "./adrs",
"projectPath": "."
}
}
Common ADR Locations to Check:
././adrs/./decisions/./architecture/architecture/decisions/- Root-level
ARCHITECTURE.mdorDECISIONS.md
If No ADRs Foundโ
Don't worry! This is common. The tool will help you discover implicit decisions that should be documented.
If ADRs Existโ
Great! You can enhance and expand the existing documentation. Note:
- Format consistency - Are they using a standard template?
- Completeness - Do they cover all major decisions?
- Currency - Are they up to date with current implementation?
๐ Step 3: Identify Implicit Architectural Decisionsโ
Discover Hidden Decisionsโ
Every codebase contains implicit architectural decisions that aren't documented. Let's find them:
{
"tool": "suggest_adrs",
"parameters": {
"projectPath": ".",
"analysisScope": "all",
"maxSuggestions": 10
}
}
Common Implicit Decisions Include:
- Database choice and schema design
- Authentication and authorization approach
- API design patterns (REST, GraphQL, etc.)
- Error handling strategies
- Logging and monitoring approaches
- Testing strategies and frameworks
- Deployment and infrastructure choices
Prioritize by Impactโ
The tool will suggest decisions, but you should prioritize based on:
- Business Impact - Decisions affecting user experience or business goals
- Technical Risk - Decisions with significant technical debt or complexity
- Team Confusion - Areas where team members frequently ask questions
- Change Frequency - Parts of the system that change often
Exercise: Decision Mappingโ
Create a simple priority matrix:
| Decision | Business Impact | Technical Risk | Priority |
|---|---|---|---|
| Database Architecture | High | Medium | 1 |
| API Authentication | High | High | 1 |
| Frontend State Management | Medium | Low | 3 |