Skip to main content
Glama
vincent623
by vincent623
README.md
# ๐Ÿ“Š Article Quadrant Analyzer MCP Server (Enhanced + OCR)

A powerful Model Context Protocol (MCP) server that extracts core insights from articles with OCR support and generates intelligent Chinese quadrant analysis with direct text matrix visualization.

## โœจ Features

- **Multi-Source Content Processing**: URLs, files, screenshots (OCR), and direct text
- **Professional OCR**: Integration with Mistral Document AI API for high-accuracy screenshot analysis
- **4 Powerful Tools**: Content extraction, OCR processing, insights analysis, quadrant generation
- **Chinese Text Matrix Output**: Direct ASCII quadrant visualization in dialogue
- **2x2 Quadrant Analysis**: Automatic generation of insightful quadrant visualizations
- **Agent-Centric Design**: Optimized for AI agent workflows
- **UVX Deployment**: Zero-dependency deployment for minimal cost

## ๐Ÿš€ Quick Start

### 1. Fast Deployment (5 minutes)

```bash
# Deploy to Cursor
./deploy_to_ide_standard.sh cursor

# Deploy to VS Code
./deploy_to_ide_standard.sh vscode

# Deploy to Claude Desktop
./deploy_to_ide_standard.sh claude

# Validate deployment
./deploy_to_ide_standard.sh validate
```

### 2. Manual Setup

```bash
# Install dependencies
uvx --quiet --python 3.12 --with fastmcp python test_simple_server.py

# Start MCP Inspector for testing
fastmcp dev test_simple_server.py
```

## ๐Ÿ“ Project Structure

```
mcp-server-article-quadrant/
โ”œโ”€โ”€ test_simple_server.py              # Main MCP server (3 tools)
โ”œโ”€โ”€ deploy_to_ide_standard.sh          # Automated deployment script
โ”œโ”€โ”€ config/                            # IDE configurations
โ”‚   โ”œโ”€โ”€ config_cursor_standard.json
โ”‚   โ”œโ”€โ”€ config_vscode_standard.json
โ”‚   โ”œโ”€โ”€ config_claude_desktop_standard.json
โ”‚   โ”œโ”€โ”€ config_emacs.el
โ”‚   โ””โ”€โ”€ config_neovim.lua
โ”œโ”€โ”€ src/mcp_server_article_quadrant/   # Modular source code
โ”‚   โ”œโ”€โ”€ server.py                      # FastMCP server setup
โ”‚   โ”œโ”€โ”€ tools/                         # MCP tools
โ”‚   โ”‚   โ”œโ”€โ”€ extract_content.py
โ”‚   โ”‚   โ”œโ”€โ”€ analyze_insights.py
โ”‚   โ”‚   โ””โ”€โ”€ generate_quadrant.py
โ”‚   โ”œโ”€โ”€ models/                        # Pydantic models
โ”‚   โ”‚   โ”œโ”€โ”€ content.py
โ”‚   โ”‚   โ”œโ”€โ”€ analysis.py
โ”‚   โ”‚   โ””โ”€โ”€ quadrant.py
โ”‚   โ””โ”€โ”€ utils/                         # Utilities
โ”‚       โ”œโ”€โ”€ content_extractor.py
โ”‚       โ”œโ”€โ”€ quadrant_generator.py
โ”‚       โ””โ”€โ”€ image_processor.py
โ”œโ”€โ”€ .trae/specs/article-quadrant-analyzer/  # Technical specifications
โ”‚   โ”œโ”€โ”€ spec.md (24KB)                 # Complete MCP server specification
โ”‚   โ””โ”€โ”€ api-research.md (25KB)         # API research and content sources
โ”œโ”€โ”€ pyproject.toml                     # Project configuration
โ”œโ”€โ”€ .env.example                       # Environment variables template
โ”œโ”€โ”€ 2X2ๅˆ†ๆžprompt.md                   # Original analysis prompt
โ””โ”€โ”€ DOCUMENTATION_SUMMARY.md           # Documentation cleanup summary
```

## ๐Ÿ”ง Configuration

### Environment Variables

```bash
# Mistral Document AI API (for OCR)
MISTRAL_API_KEY=your_api_key_here

# Content Processing
CONTENT_MAX_LENGTH=50000
OCR_MAX_FILE_SIZE=10485760
```

### IDE Configuration Examples

**Cursor:**
```json
{
  "mcpServers": {
    "article-quadrant-analyzer": {
      "command": "uvx",
      "args": [
        "--quiet", "--python", "3.12", "--with", "fastmcp",
        "python", "/Users/vincent/Library/CloudStorage/SynologyDrive-vincent/My.create/Developer/MCP/test_simple_server.py"
      ]
    }
  }
}
```

More configuration examples in `config/` directory.

## ๐Ÿ› ๏ธ MCP Tools

### 1. `extract_article_content_simple`
**Enhanced content extraction with AI-friendly interface**

**Intelligent Processing:**
- Automatic HTML/XML tag removal
- Language detection (Chinese/English/Mixed)
- Content quality analysis
- URL and format detection
- Comprehensive metrics (characters, words, sentences, paragraphs)

**Universal Input Support:**
- URLs (news websites, WeChat public accounts)
- Text files and documents
- Direct text input
- OCR processed content
- Mixed-format content

**Smart Output:**
- Content preview with truncation
- Complexity assessment
- Processing recommendations
- Next-step guidance

### 2. `analyze_article_insights_simple`
**Advanced content insights extraction**

**Keyword Analysis:**
- Frequency-based keyword extraction
- Topic identification and clustering
- Content summarization
- Trend detection

**Intelligence Features:**
- Automatic topic categorization
- Insight relevance scoring
- Content structure analysis
- Actionable insight generation

### 3. `extract_text_from_image`
**Professional OCR with Mistral Document AI API**

**Advanced OCR Processing:**
- High-accuracy text extraction from images and screenshots
- Support for multiple image formats (PNG, JPG, WEBP)
- Automatic language detection (Chinese/English/Mixed)
- Mistral Document AI API integration for best results

**Smart Error Handling:**
- Graceful fallback when API key not configured
- Detailed error messages and troubleshooting guidance
- Image validation and preprocessing
- Network timeout and retry logic

**Input/Output Support:**
- File paths to local images
- Base64 encoded image data
- Real-time confidence scoring
- Extracted text ready for quadrant analysis

### 4. `generate_quadrant_analysis_simple`
**Enhanced Chinese quadrant analysis engine**

**Smart Content Processing:**
- Intelligent Chinese language detection and analysis
- Context-aware content preprocessing
- Flexible axis labeling (supports Chinese labels)
- Robust error handling and parameter validation

**Advanced Classification Logic:**
- **Collaboration Analysis**: Detects team work, coordination, and group activities
- **Textual Analysis**: Identifies documentation, writing, and formal communication
- **Pattern Recognition**: Maps content to appropriate quadrants based on actual text patterns
- **Chinese Context Support**: Specifically trained for Chinese business and work scenarios

**Direct Matrix Output:**
- **Real-time ASCII Visualization**: Matrix appears directly in dialogue
- **Chinese Quadrant Names**: ้‡็‚นๆŠ•ๅ…ฅๅŒบ, ไธ“ไธšๅˆ†ๆžๅŒบ, ๅŸบ็ก€็ปดๆŠคๅŒบ, ๅˆ›ๆ„ๅไฝœๅŒบ
- **Content-Specific Mapping**: Analyzes your actual content for accurate placement
- **No Conversion Needed**: Instant results without SVG/PNG conversion steps

**Rich Output Format:**
- Professional quadrant mapping
- Detailed content metrics
- Strategic insights and recommendations
- **Direct text matrix visualization** (Chinese)
- **Smart content classification** based on actual text analysis

**AI-Friendly Features:**
- Automatic XML/HTML tag cleanup
- Flexible parameter format support
- Comprehensive error handling
- Context-aware response generation
- **Chinese language support** with intelligent content analysis

**๐ŸŽจ Enhanced Visualization Capabilities:**
- **Intelligent Text Matrix**: Direct ASCII quadrant display in dialogue
- **Chinese Content Analysis**: Smart classification based on collaboration vs text levels
- **Context-Aware Mapping**: Analyzes content patterns for accurate quadrant placement
- **Real-time Results**: No SVG conversion needed - matrix appears immediately
- **Dynamic Naming**: Quadrants named in Chinese (้‡็‚นๆŠ•ๅ…ฅๅŒบ, ไธ“ไธšๅˆ†ๆžๅŒบ, ๅŸบ็ก€็ปดๆŠคๅŒบ, ๅˆ›ๆ„ๅไฝœๅŒบ)

## ๐Ÿ“‹ Supported Content Sources

- **News Websites**: Major news platforms and online publications
- **WeChat Public Accounts**: Articles from WeChat official accounts
- **Screenshots**: OCR processing via Mistral Document AI API
- **Text Files**: Direct file content extraction
- **Direct Input**: Manual text entry for analysis

## ๐ŸŽฏ Use Cases

- **Work Process Analysis**: Analyze team collaboration workflows and documentation patterns
- **Project Management**: Visualize task distribution and work flow efficiency
- **Team Coordination**: Identify collaboration bottlenecks and optimization opportunities
- **Content Strategy**: Map content types across collaboration and formality dimensions
- **Decision Making**: Framework for resource allocation and task prioritization

## ๐Ÿ“Š Sample Output

**Input:**
```
ๅทฅไฝœ็š„ๆตๅŠจๆ€ง: ๆฒกๆœ‰ไปปไฝ•ไธ€ไธชๅฒ—ไฝๅชๅญ˜ๅœจไบŽไธ€ไธช่ฑก้™...
ไพ‹ๅฆ‚ๅผ€ๅ‘ๆ–ฐๅŠŸ่ƒฝ: ๅ›ข้˜Ÿๅคด่„‘้ฃŽๆšด๏ผŒๆ’ฐๅ†™PRDๆ–‡ๆกฃ๏ผŒๅทฅ็จ‹ๅธˆ็‹ฌ็ซ‹็ผ–ๅ†™ไปฃ็ ...
```

**Direct Matrix Output:**
```
๐ŸŽฏ ๅ››่ฑก้™็Ÿฉ้˜ตๅ›พ

                    โ†‘ ๆ–‡ๆœฌๅŒ–็จ‹ๅบฆ โ†‘
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚     Q1: ้‡็‚นๆŠ•ๅ…ฅๅŒบ     โ”‚
                    โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
                    โ”‚  โ”‚ โ€ข ๅ›ข้˜Ÿๅไฝœๆ–‡ๆกฃ      โ”‚  โ”‚
                    โ”‚  โ”‚ โ€ข ้›†ไฝ“่ฎจ่ฎบ่ฎฐๅฝ•      โ”‚  โ”‚
                    โ”‚  โ”‚ โ€ข ๅ…ฑไบซๆˆๆžœๅฑ•็คบ      โ”‚  โ”‚
                    โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚     Q2: ไธ“ไธšๅˆ†ๆžๅŒบ     โ”‚
                    โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
                    โ”‚  โ”‚ โ€ข ็‹ฌ็ซ‹ๆทฑๅบฆๆ€่€ƒ      โ”‚  โ”‚
                    โ”‚  โ”‚ โ€ข ไธชไบบไธ“ไธšๅˆ†ๆž      โ”‚  โ”‚
                    โ”‚  โ”‚ โ€ข ๆ ธๅฟƒๆŠ€ๆœฏๅฎž็Žฐ      โ”‚  โ”‚
                    โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ† ๅไฝœ็จ‹ๅบฆ โ† โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ†’ ๅไฝœ็จ‹ๅบฆ โ†’
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚     Q3: ๅŸบ็ก€็ปดๆŠคๅŒบ     โ”‚
                    โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
                    โ”‚  โ”‚ โ€ข ๅŸบ็ก€็ปดๆŠคๅทฅไฝœ      โ”‚  โ”‚
                    โ”‚  โ”‚ โ€ข ๅธธ่ง„ๆ“ไฝœๆต็จ‹      โ”‚  โ”‚
                    โ”‚  โ”‚ โ€ข ๆ ‡ๅ‡†่ง„่Œƒๆ‰ง่กŒ      โ”‚  โ”‚
                    โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚     Q4: ๅˆ›ๆ„ๅไฝœๅŒบ     โ”‚
                    โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
                    โ”‚  โ”‚ โ€ข ๅˆ›ๆ„ๅคด่„‘้ฃŽๆšด      โ”‚  โ”‚
                    โ”‚  โ”‚ โ€ข ่ง†่ง‰ๅŒ–่กจ่พพ        โ”‚  โ”‚
                    โ”‚  โ”‚ โ€ข ไบ’ๅŠจๅไฝœๅฑ•็คบ      โ”‚  โ”‚
                    โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
```

## ๐Ÿ” Testing & Validation

```bash
# Test MCP Inspector
fastmcp dev test_simple_server.py
# Opens: http://127.0.0.1:6274

# Validate UVX deployment
./deploy_to_ide_standard.sh validate

# Test individual tools via MCP Inspector interface
```

## ๐Ÿ“š Documentation

- **[Technical Specification](.trae/specs/article-quadrant-analyzer/spec.md)** - Complete MCP server design (24KB)
- **[API Research](.trae/specs/article-quadrant-analyzer/api-research.md)** - Content source analysis (25KB)
- **[Documentation Summary](DOCUMENTATION_SUMMARY.md)** - Project organization and cleanup history

## โšก Performance

- **Startup Time**: <2 seconds with UVX
- **Memory Usage**: ~50MB baseline
- **Processing**: 1-5 seconds for typical articles
- **OCR Processing**: 3-10 seconds via Mistral API

## ๐ŸŽจ Generated Output Examples

The server generates professional quadrant analyses in SVG format showing:
- **Strategic Positioning**: Content mapped across two axes
- **Visual Clarity**: Clean, professional quadrants with labels
- **Actionable Insights**: Recommendations based on positioning
- **Contextual Analysis**: Tailored to content type and goals

---

**๐Ÿš€ Ready to transform your article analysis workflow!**

*Generated with FastMCP Spec-Driven Development Guide*