-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
bugSomething isn't workingSomething isn't workingphase: 2-implementationPhase 2 - Implementation workPhase 2 - Implementation workpriority: highHigh priority workHigh priority work
Description
🐛 Bug Report
Problem Description
The analyze_health_topic tool times out when using "comprehensive" depth setting through MCP clients. The timeout occurs due to MCP clients' 10-second default timeout, while comprehensive analysis takes >10 seconds to process 43,373 documents.
Current Behavior
- Error: MCP error -32001: Request timed out
- Occurs when: Using
depth="comprehensive"parameter - Processing time: >10 seconds for comprehensive analysis
- MCP client timeout: 10 seconds (hard limit in most clients)
Root Cause
- Large dataset: Processing 43,373 documents in vector database
- Complex operations: Multiple vector searches, result aggregation, AI synthesis
- MCP timeout: 10-second client timeout is shorter than processing time
🎯 Proposed Solution: Streaming Progressive Responses
Implementation Plan
Phase 1: Streaming Response Architecture (High Priority)
Implement SSE-based progressive response streaming to keep connections alive:
async def analyze_health_topic_streaming(topic: str, depth: str):
# Send initial acknowledgment (< 1 second)
yield {"type": "progress", "status": "started", "progress": 0}
# Stream search results (2-4 seconds)
search_results = await vector_search(topic)
yield {"type": "progress", "progress": 25, "partial_results": search_results[:5]}
# Stream categorization (4-6 seconds)
categories = await categorize_results(search_results)
yield {"type": "progress", "progress": 50, "categories": list(categories.keys())}
# Stream AI synthesis (6-9 seconds)
for category, analysis in process_categories_async(categories):
yield {"type": "progress", "progress": 75, "partial_analysis": {category: analysis}}
# Final result (< 10 seconds total)
yield {"type": "complete", "progress": 100, "result": comprehensive_analysis}Phase 2: Optimization (Medium Priority)
- Parallel Processing: Run searches concurrently
- Smart Caching: Cache common topics with 1-hour TTL
- Result Truncation: Limit to 30 documents for comprehensive
Phase 3: Background Processing (Low Priority)
Implement job queue for truly comprehensive analysis with polling.
Quick Fix (Immediate)
if depth == "comprehensive" and len(results) > 25:
results = results[:25] # Temporary fix to stay under 10 secondsSuccess Metrics
- Comprehensive analysis completes in <10 seconds
- No timeout errors in MCP Inspector
- Progressive updates visible to user
- Claude.ai integration works smoothly
References
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingphase: 2-implementationPhase 2 - Implementation workPhase 2 - Implementation workpriority: highHigh priority workHigh priority work