| |
| """ |
| Live Demo Test - Stack Overflow MCP Server |
| This script makes actual API calls to demonstrate the working functionality. |
| """ |
|
|
| import sys |
| import os |
| sys.path.append(os.path.dirname(os.path.abspath(__file__))) |
|
|
| from gradio_app import search_by_query_sync, search_by_error_sync, get_question_sync |
|
|
| def test_live_functionality(): |
| """Test the actual functionality of our Stack Overflow MCP server.""" |
| |
| print("π§ͺ LIVE FUNCTIONALITY TEST") |
| print("=" * 60) |
| |
| |
| print("\n1οΈβ£ Testing General Search...") |
| print("Query: 'python list comprehension'") |
| print("Tags: 'python'") |
| print("-" * 40) |
| |
| try: |
| result = search_by_query_sync( |
| query="python list comprehension", |
| tags="python", |
| min_score=10, |
| has_accepted_answer=True, |
| limit=2, |
| response_format="markdown" |
| ) |
| print("β
SUCCESS:") |
| print(result[:500] + "..." if len(result) > 500 else result) |
| except Exception as e: |
| print(f"β ERROR: {e}") |
| |
| print("\n" + "=" * 60) |
| |
| |
| print("\n2οΈβ£ Testing Error Search...") |
| print("Error: 'TypeError: NoneType'") |
| print("Language: 'python'") |
| print("-" * 40) |
| |
| try: |
| result = search_by_error_sync( |
| error_message="TypeError: NoneType object has no attribute", |
| language="python", |
| technologies="", |
| min_score=5, |
| has_accepted_answer=True, |
| limit=2, |
| response_format="markdown" |
| ) |
| print("β
SUCCESS:") |
| print(result[:500] + "..." if len(result) > 500 else result) |
| except Exception as e: |
| print(f"β ERROR: {e}") |
| |
| print("\n" + "=" * 60) |
| |
| |
| print("\n3οΈβ£ Testing Get Question...") |
| print("Question ID: 11227809 (Famous sorting question)") |
| print("-" * 40) |
| |
| try: |
| result = get_question_sync( |
| question_id="11227809", |
| include_comments=False, |
| response_format="markdown" |
| ) |
| print("β
SUCCESS:") |
| print(result[:500] + "..." if len(result) > 500 else result) |
| except Exception as e: |
| print(f"β ERROR: {e}") |
| |
| print("\n" + "=" * 60) |
| print("π― Live functionality test completed!") |
| print("π All functions are working and connected to Stack Overflow API") |
|
|
| if __name__ == "__main__": |
| test_live_functionality() |
|
|