Skip to main content
Glama

MCP Learning Project

by BerdTan
quick_test_server.pyโ€ข2.73 kB
#!/usr/bin/env python3 """ Quick test to verify the MCP server is working properly """ import asyncio import json import sys from pathlib import Path # Add src to path sys.path.insert(0, str(Path(__file__).parent / "src")) async def quick_test(): """Quick test of the MCP server.""" print("๐Ÿงช Quick MCP Server Test") print("=" * 30) try: # Connect to server print("๐Ÿ“ก Connecting to localhost:8000...") reader, writer = await asyncio.open_connection("localhost", 8000) print("โœ… Connected!") # Send initialization init_request = { "jsonrpc": "2.0", "id": 1, "method": "initialize", "params": { "protocolVersion": "2024-11-05", "capabilities": {}, "clientInfo": {"name": "Test", "version": "1.0"} } } print("๐Ÿ“ค Sending initialization...") writer.write(json.dumps(init_request).encode()) await writer.drain() # Read response data = await reader.read(1024) response = json.loads(data.decode()) if "result" in response: print("โœ… Initialization successful!") # Test tools list tools_request = { "jsonrpc": "2.0", "id": 2, "method": "tools/list", "params": {} } print("๐Ÿ“ค Sending tools/list...") writer.write(json.dumps(tools_request).encode()) await writer.drain() # Read response data = await reader.read(1024) if data: response = json.loads(data.decode()) print("๐Ÿ“ฅ Tools response received!") if "result" in response and "tools" in response["result"]: tools = response["result"]["tools"] print(f"โœ… Found {len(tools)} tools:") for tool in tools: print(f" - {tool.get('name', 'unknown')}") else: print("โš ๏ธ No tools in response") else: print("โš ๏ธ No response from tools/list") else: print("โŒ Initialization failed!") # Close connection writer.close() await writer.wait_closed() print("โœ… Test completed!") except Exception as e: print(f"โŒ Error: {e}") if __name__ == "__main__": asyncio.run(quick_test())

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