File size: 5,422 Bytes
a6bfba7 6ce0b24 a6bfba7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# ๐ Stack Overflow MCP Server - Hackathon Demo
## ๐ฏ Project Overview
This project demonstrates a **Stack Overflow MCP (Model Context Protocol) Server** built with Gradio for a hackathon. It provides both a beautiful web interface and an MCP server that AI assistants like Claude can use to programmatically search and analyze Stack Overflow content.
## ๐ Key Features
### ๐ **Multiple Search Methods**
- **General Search**: Query-based search with tag filtering
- **Error Search**: Specialized search for error messages and debugging
- **Question Retrieval**: Get specific questions by ID
- **Stack Trace Analysis**: Analyze stack traces to find solutions
- **Advanced Search**: Comprehensive filtering with multiple criteria
### ๐จ **Beautiful Web Interface**
- Clean, modern Gradio interface
- Multiple tabs for different search types
- Quick example buttons for easy testing
- Real-time search results with formatted output
- Support for both Markdown and JSON output formats
### ๐ค **MCP Server Integration**
- Full MCP compatibility for AI assistants
- SSE (Server-Sent Events) endpoint for real-time communication
- 5 available MCP tools for different search scenarios
- Easy integration with Claude Desktop and other MCP clients
## ๐ Live Demo
**๐ Web Interface**: [https://c44b366466c774a9d5.gradio.live](https://c44b366466c774a9d5.gradio.live)
**๐ MCP Server Endpoint**: `https://c44b366466c774a9d5.gradio.live/gradio_api/mcp/sse`
## ๐ ๏ธ Available MCP Tools
| Tool | Description | Use Case |
|------|-------------|----------|
| `search_by_query_sync` | General Stack Overflow search | Find solutions by keywords and tags |
| `search_by_error_sync` | Error-specific search | Debug specific error messages |
| `get_question_sync` | Retrieve specific question by ID | Get detailed question information |
| `analyze_stack_trace_sync` | Analyze stack traces | Find solutions for runtime errors |
| `advanced_search_sync` | Advanced search with filters | Complex queries with multiple criteria |
## ๐ Demo Scenarios
### 1. **General Programming Search**
```
Query: "Django pagination best practices"
Tags: python,django
Filters: Minimum score 5, Must have accepted answer
```
### 2. **Error Debugging**
```
Error: "TypeError: 'NoneType' object has no attribute 'length'"
Language: Python
Technologies: flask,sqlalchemy
```
### 3. **Stack Trace Analysis**
```
Stack Trace: "ReferenceError: useState is not defined"
Language: JavaScript
```
### 4. **Advanced Search**
```
Query: "memory optimization"
Include Tags: c++,performance
Exclude Tags: beginner
Min Score: 50
Sort By: votes
```
## ๐ง Technical Architecture
### Frontend (Gradio)
- **Framework**: Gradio 5.33.1 with MCP support
- **Interface**: Multi-tab design with intuitive controls
- **Features**: Real-time search, example buttons, format selection
### Backend (Stack Overflow MCP Server)
- **API Integration**: Stack Exchange API with rate limiting
- **MCP Protocol**: Full MCP compatibility with SSE transport
- **Search Engine**: Multiple search strategies and filtering options
- **Response Formatting**: Markdown and JSON output formats
### Infrastructure
- **Package Manager**: UV for fast dependency management
- **Deployment**: Gradio sharing with public URLs
- **MCP Server**: Integrated MCP server with Gradio
## ๐ฎ How to Test
### Web Interface Testing
1. Visit the [live demo](https://a6f742bf182e4bae9b.gradio.live)
2. Try the different tabs:
- **General Search**: Use example buttons or enter custom queries
- **Error Search**: Test with common error messages
- **Get Question**: Try question ID `11227809`
- **Stack Trace Analysis**: Use the pre-filled JavaScript example
- **Advanced Search**: Experiment with complex filters
### MCP Client Testing
Configure your MCP client (like Claude Desktop) with:
```json
{
"mcpServers": {
"stackoverflow": {
"url": "https://c44b366466c774a9d5.gradio.live/gradio_api/mcp/sse"
}
}
}
```
## ๐๏ธ Local Development
```bash
# Clone and setup
git clone <repository>
cd gradio_stack_overflow_client
# Install dependencies
uv add "gradio[mcp]"
# Set your Stack Exchange API key
export STACK_EXCHANGE_API_KEY="your_api_key_here"
# Run the application
uv run python gradio_app.py
```
## ๐ฏ Hackathon Highlights
### Innovation
- **Dual Interface**: Both web UI and MCP server in one application
- **Smart Search**: Multiple specialized search strategies
- **User Experience**: Intuitive interface with quick examples
### Technical Excellence
- **Modern Stack**: UV, Gradio 5.33+, FastMCP integration
- **Robust API**: Rate limiting, error handling, async operations
- **MCP Compliance**: Full protocol implementation with SSE transport
### Practical Value
- **Real-world Utility**: Solves actual developer problems
- **AI Integration**: Ready for AI assistant workflows
- **Extensible**: Easy to add new search methods and filters
## ๐ Future Enhancements
- **Authentication**: User-specific search history
- **Caching**: Redis caching for faster responses
- **Analytics**: Search pattern analysis and recommendations
- **Multi-platform**: GitHub, GitLab, and other developer platforms
- **AI Features**: Semantic search and intelligent filtering
---
**Built with โค๏ธ for the MCP Hackathon**
*Demonstrating the power of combining beautiful web interfaces with powerful MCP server capabilities*
|