Skip to main content
Glama

MCP Learning Project

by BerdTan
test_server.pyโ€ข2.1 kB
#!/usr/bin/env python3 """ Simple test script for the MCP Testing Harness """ import asyncio import logging import sys from pathlib import Path # Add src to path sys.path.insert(0, str(Path(__file__).parent / "src")) from core.server import MCPServer from core.testing import MCPServerTester # Set up logging logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) async def test_basic_server(): """Test the basic MCP server functionality.""" print("๐Ÿš€ Testing MCP Server") print("=" * 30) # Create server server = MCPServer(host="localhost", port=8000, debug=True) # Create tester tester = MCPServerTester() print("๐Ÿ“ก Starting server...") # Start server in background server_task = asyncio.create_task(server.start()) # Wait for server to start await asyncio.sleep(2) print("โœ… Server started!") try: # Test connection print("\n๐Ÿ”ง Testing connection...") result = await tester.test_server_connection("localhost", 8000) print(f"Connection test: {'โœ… PASS' if result.success else 'โŒ FAIL'}") if not result.success: print(f"Error: {result.error_message}") # Test tools print("\n๐Ÿ”ง Testing tools...") tools_result = await tester.test_server_tools("localhost", 8000) print(f"Tools test: {'โœ… PASS' if tools_result.success else 'โŒ FAIL'}") if tools_result.success: print(f"Found {tools_result.details.get('tools_count', 0)} tools") except Exception as e: print(f"โŒ Error: {e}") finally: # Stop server print("\n๐Ÿ›‘ Stopping server...") await server.stop() server_task.cancel() try: await server_task except asyncio.CancelledError: pass print("\nโœ… Test completed!") if __name__ == "__main__": asyncio.run(test_basic_server())

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/BerdTan/mcpharness'

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