# Project Configuration: Case Study Generator MCP Server
## Project Overview
A simple MCP server that processes document content and GitHub repositories with Gemma3 to extract structured business insights for case study generation. Claude Desktop handles all document retrieval, reasoning, writing, and saving.
## Architecture Decision
**Simple Data Flow**: User → Claude Desktop → Google Drive (retrieve) → MCP Server (process) → Claude Desktop (reason & write) → Google Drive (save)
## Technical Stack
- **MCP Server**: Python 3.11+
- **Local LLM**: Gemma3 8B-Instruct via Ollama
- **Integration**: Model Context Protocol SDK
- **APIs**: GitHub API for repository analysis
## Project Structure
```
case-study-mcp/
├── mcp_server.py # Main MCP server entry point
├── gemma3_client.py # Simple Gemma3 wrapper
├── document_processor.py # Process document text with Gemma3
├── github_analyzer.py # Analyze GitHub repos with Gemma3
├── company_researcher.py # Basic company research
├── prompts.py # Gemma3 prompt templates
├── requirements.txt
├── README.md
└── project_config.md
```
## MCP Server Tools
```python
TOOLS = [
{
"name": "process_document_text",
"description": "Process document content with Gemma3 to extract business insights",
"parameters": {
"text": "document content from Google Drive",
"doc_type": "proposal|case_study|contract|general"
}
},
{
"name": "analyze_github_repo",
"description": "Analyze GitHub repository for business value and technical insights",
"parameters": {
"repo_url": "github.com/owner/repo"
}
},
{
"name": "research_company_basic",
"description": "Basic company research and context",
"parameters": {
"company_name": "company name"
}
}
]
```
## Core Workflow
1. **User Input**: "Create case study for TechCorp using repo X and these Google Drive docs"
2. **Claude Desktop**: Retrieves documents from Google Drive (built-in integration)
3. **Claude Desktop**: Calls `process_document_text` with document content
4. **MCP Server**: Processes with Gemma3, returns structured insights
5. **Claude Desktop**: Calls `analyze_github_repo` with repository URL
6. **MCP Server**: Analyzes repo with Gemma3, returns technical analysis
7. **Claude Desktop**: Synthesizes all data into compelling case study
8. **User Feedback**: "Make it more technical"
9. **Claude Desktop**: Refines case study (no MCP calls needed)
10. **Claude Desktop**: Saves final document to Google Drive
## Implementation Plan
### Phase 1: Core MCP Server (Week 1)
- [ ] Set up MCP server with Ollama/Gemma3 integration
- [ ] Implement `process_document_text` tool
- [ ] Implement `analyze_github_repo` tool
- [ ] Basic error handling and logging
### Phase 2: Enhanced Processing (Week 2)
- [ ] Implement `research_company_basic` tool
- [ ] Improve document insight extraction
- [ ] Add GitHub repository analysis depth
- [ ] Testing and refinement
### Phase 3: Polish & Deploy (Week 3)
- [ ] Performance optimization
- [ ] Better error messages
- [ ] Documentation and examples
- [ ] Integration testing with Claude Desktop
## Key Classes
### DocumentProcessor
```python
class DocumentProcessor:
def __init__(self, gemma3_client):
self.gemma3 = gemma3_client
def process_document_content(self, text: str, doc_type: str) -> dict:
"""Extract business insights from document text using Gemma3"""
# Returns: challenges, solutions, metrics, context
def _get_document_prompt(self, doc_type: str) -> str:
"""Get specialized prompt based on document type"""
```
### GitHubAnalyzer
```python
class GitHubAnalyzer:
def __init__(self, gemma3_client, github_client):
self.gemma3 = gemma3_client
self.github = github_client
def analyze_repository(self, repo_url: str) -> dict:
"""Analyze GitHub repository for business value"""
# Returns: problem_solved, key_features, business_value, tech_stack
def _fetch_repository_data(self, repo_url: str) -> dict:
"""Fetch repository metadata and key files"""
```
### CompanyResearcher
```python
class CompanyResearcher:
def __init__(self, gemma3_client):
self.gemma3 = gemma3_client
def research_company(self, company_name: str) -> dict:
"""Basic company research and context"""
# Returns: company_profile, industry, business_model, challenges
```
## Gemma3 Configuration
```python
GEMMA3_CONFIG = {
"model": "gemma3:8b-instruct",
"temperature": 0.1, # Low for consistent extraction
"num_ctx": 8192, # Context window
"top_p": 0.9,
"repeat_penalty": 1.1
}
```
## Prompt Templates
### Document Processing
```python
DOCUMENT_PROMPT = """
Extract key business insights from this {doc_type} document:
{document_text}
Return JSON with this exact structure:
{
"challenges": ["specific business problems mentioned"],
"solutions": ["proposed solutions or approaches"],
"metrics": ["success metrics, KPIs, or quantifiable results"],
"context": "industry or company context",
"key_stakeholders": ["mentioned stakeholders or roles"],
"timeline": "project timeline if mentioned"
}
"""
```
### GitHub Analysis
```python
GITHUB_PROMPT = """
Analyze this GitHub repository for business value:
Repository: {repo_name}
Description: {description}
Tech Stack: {tech_stack}
Key Files: {key_files}
Return JSON with this exact structure:
{
"problem_solved": "what business problem this solves",
"key_features": ["main features and capabilities"],
"business_value": "why this matters to businesses",
"technical_benefits": ["technical advantages"],
"target_users": "who would use this solution",
"scalability": "scalability considerations",
"integration_points": ["systems it can integrate with"]
}
"""
```
## Expected Input/Output
### process_document_text
**Input**:
```python
{
"text": "TechCorp needs to modernize their e-commerce platform...",
"doc_type": "proposal"
}
```
**Output**:
```python
{
"challenges": ["Legacy platform scalability issues", "Peak season traffic handling"],
"solutions": ["Microservices architecture", "Cloud-native deployment"],
"metrics": ["90% improvement in load times", "99.9% uptime target"],
"context": "Mid-market e-commerce company",
"key_stakeholders": ["CTO", "Engineering Team"],
"timeline": "6-month implementation"
}
```
### analyze_github_repo
**Input**:
```python
{
"repo_url": "github.com/example/ecommerce-platform"
}
```
**Output**:
```python
{
"problem_solved": "Scalable e-commerce platform for high-traffic scenarios",
"key_features": ["Microservices architecture", "Redis caching", "Payment integration"],
"business_value": "Enables 10x traffic scaling without system crashes",
"technical_benefits": ["Horizontal scaling", "Fault tolerance", "Performance optimization"],
"target_users": "Mid to large-scale e-commerce businesses",
"scalability": "Designed for high-traffic, seasonal peaks",
"integration_points": ["CRM systems", "Payment gateways", "Analytics platforms"]
}
```
## Development Guidelines
### Error Handling
- Graceful degradation when Gemma3 is unavailable
- Clear error messages for invalid inputs
- Retry logic for transient failures
- Fallback responses for partial failures
### Performance Targets
- Document processing: < 10 seconds
- GitHub analysis: < 5 seconds
- Company research: < 8 seconds
- Memory usage: < 2GB for Gemma3
### Testing Strategy
- Unit tests for each processor class
- Integration tests with sample documents
- Performance testing with various document sizes
- Error scenario testing
## Dependencies
```
ollama>=0.2.0
@octokit/rest>=20.0.0
requests>=2.31.0
python-dotenv>=1.0.0
```
## Success Metrics
- **Processing Accuracy**: High-quality structured insights from documents
- **Response Time**: Fast enough for real-time case study generation
- **Reliability**: 95%+ successful processing rate
- **Integration**: Seamless operation with Claude Desktop
## User Experience (from Claude Desktop perspective)
```
User: "Create case study for TechCorp using github.com/example/repo and my retail proposal docs"
Claude: "I'll create that case study. Let me gather information..."
[Retrieves documents from Google Drive]
[Calls MCP: process_document_text with document content]
[Calls MCP: analyze_github_repo with repo URL]
[Calls MCP: research_company_basic with "TechCorp"]
Claude: "Based on TechCorp's challenges and the e-commerce solution, here's the case study draft..."
[Uses structured insights to create compelling narrative]
User: "Make it more technical and add ROI projections"
Claude: "Here's the revised version with technical details and ROI analysis..."
[Updates using its own reasoning - no MCP calls needed]
User: "Perfect, save it to Google Drive"
Claude: [Saves to Google Drive] "Case study saved as TechCorp_CaseStudy.docx"
```
This configuration focuses on building a simple, effective MCP server that processes data while leveraging Claude Desktop's existing strengths for reasoning, writing, and Google Drive integration.