Skip to main content
Glama
kaman05010

MCP Wikipedia Server

by kaman05010
quick_test.py4.53 kB
#!/usr/bin/env python3 """ Quick Test - Simple validation script for MCP Wikipedia Server. This script performs basic sanity checks to ensure the server is working correctly. It's designed to be fast and provide immediate feedback. """ import asyncio import sys import os import time # Add src to path for imports sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'src')) try: from mcp_server.mcp_server import WikipediaServer except ImportError: sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'src', 'mcp_server')) from mcp_server import WikipediaServer async def quick_test(): """Run quick validation tests.""" print("🚀 MCP Wikipedia Server - Quick Test") print("="*40) success_count = 0 total_tests = 4 try: # Test 1: Server instantiation print("\n1. Testing server instantiation...") server = WikipediaServer() print(" ✅ Server created successfully") success_count += 1 # Test 2: Basic search print("\n2. Testing Wikipedia search...") start_time = time.time() result = await server.fetch_wikipedia_info("Python programming") duration = time.time() - start_time if result.get("success"): title = result["data"]["title"] print(f" ✅ Search successful: '{title}' ({duration:.2f}s)") success_count += 1 else: print(f" ❌ Search failed: {result.get('error', 'Unknown error')}") # Test 3: Section listing print("\n3. Testing section listing...") start_time = time.time() sections_result = await server.list_wikipedia_sections("Machine Learning") duration = time.time() - start_time if sections_result.get("success"): section_count = len(sections_result["data"]["sections"]) print(f" ✅ Sections listed: {section_count} sections ({duration:.2f}s)") success_count += 1 else: print(f" ❌ Section listing failed: {sections_result.get('error', 'Unknown error')}") # Test 4: Content retrieval print("\n4. Testing content retrieval...") start_time = time.time() content_result = await server.get_section_content("Python", "History") duration = time.time() - start_time if content_result.get("success"): content_length = len(content_result["data"]["content"]) print(f" ✅ Content retrieved: {content_length} characters ({duration:.2f}s)") success_count += 1 else: print(f" ❌ Content retrieval failed: {content_result.get('error', 'Unknown error')}") except Exception as e: print(f"\n❌ Quick test failed with exception: {e}") import traceback traceback.print_exc() # Summary print("\n" + "="*40) print("📊 QUICK TEST SUMMARY") print("="*40) print(f"Tests Passed: {success_count}/{total_tests}") print(f"Success Rate: {success_count/total_tests:.1%}") if success_count == total_tests: print("\n🎉 All quick tests passed! Server is working correctly.") return True else: print(f"\n⚠️ {total_tests - success_count} tests failed. Check the details above.") return False def check_environment(): """Check if the environment is properly set up.""" print("🔍 Checking Environment...") # Check Python version python_version = sys.version_info if python_version >= (3, 11): print(f" ✅ Python {python_version.major}.{python_version.minor}.{python_version.micro}") else: print(f" ⚠️ Python {python_version.major}.{python_version.minor}.{python_version.micro} (3.11+ recommended)") # Check required modules required_modules = ['wikipedia', 'mcp', 'fastmcp', 'asyncio'] for module in required_modules: try: __import__(module) print(f" ✅ {module} module available") except ImportError: print(f" ❌ {module} module missing") return False return True async def main(): """Main function.""" if not check_environment(): print("\n❌ Environment check failed. Please install missing dependencies.") sys.exit(1) success = await quick_test() sys.exit(0 if success else 1) if __name__ == "__main__": asyncio.run(main())

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kaman05010/MCPClientServer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server