Skip to main content
Glama

MCP Learning Project

by BerdTan
simple_web.pyโ€ข6.99 kB
#!/usr/bin/env python3 """ Simple working web interface for MCP Testing Harness """ import http.server import socketserver import threading import time class MCPWebHandler(http.server.SimpleHTTPRequestHandler): def do_GET(self): if self.path == '/': self.send_response(200) self.send_header('Content-type', 'text/html; charset=utf-8') self.end_headers() html = """ <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>MCP Testing Harness</title> <style> body { font-family: Arial, sans-serif; margin: 20px; background: #f5f5f5; line-height: 1.6; } .container { max-width: 1200px; margin: 0 auto; background: white; padding: 30px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); } h1 { color: #333; text-align: center; margin-bottom: 30px; } .status { padding: 15px; margin: 20px 0; border-radius: 6px; font-weight: bold; } .status.running { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; } .card { background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 6px; padding: 20px; margin: 15px 0; } .tool { background: #e9ecef; padding: 10px; margin: 8px 0; border-radius: 4px; border-left: 4px solid #007bff; } .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; } pre { background: #f8f9fa; padding: 15px; border-radius: 4px; overflow-x: auto; border: 1px solid #dee2e6; } code { background: #f1f3f4; padding: 2px 6px; border-radius: 3px; font-family: 'Courier New', monospace; } .highlight { background: #fff3cd; border: 1px solid #ffeaa7; padding: 15px; border-radius: 6px; margin: 15px 0; } .emoji { font-size: 1.2em; margin-right: 5px; } </style> </head> <body> <div class="container"> <h1><span class="emoji">๐Ÿš€</span> MCP Testing Harness</h1> <div class="status running"> <span class="emoji">โœ…</span> MCP Server is running on localhost:8000 </div> <div class="highlight"> <strong><span class="emoji">๐ŸŽ‰</span> Congratulations!</strong> Your MCP Testing Harness is fully operational and ready to test any MCP server! </div> <div class="grid"> <div class="card"> <h3><span class="emoji">๐Ÿ”ง</span> Built-in Tools</h3> <div class="tool"> <strong>list_servers</strong><br> List all hosted MCP servers </div> <div class="tool"> <strong>register_server</strong><br> Register a new MCP server for testing </div> <div class="tool"> <strong>test_server</strong><br> Test an MCP server connection </div> </div> <div class="card"> <h3><span class="emoji">๐Ÿ“Š</span> Server Status</h3> <p><strong>Host:</strong> localhost</p> <p><strong>Port:</strong> 8000</p> <p><strong>Status:</strong> Running</p> <p><strong>Protocol:</strong> JSON-RPC 2.0</p> <p><strong>Version:</strong> 1.0.0</p> </div> </div> <div class="card"> <h3><span class="emoji">๐Ÿงช</span> How to Test Your Server</h3> <p>Your MCP server is ready for testing! You can:</p> <ul> <li><strong>Connect with Claude Desktop:</strong> Add <code>localhost:8000</code> as an MCP server</li> <li><strong>Use any MCP client:</strong> Connect to <code>localhost:8000</code></li> <li><strong>Test with our Python client:</strong> Run <code>py -3 test_client.py</code></li> <li><strong>Use any MCP-compatible AI client</strong></li> </ul> </div> <div class="card"> <h3><span class="emoji">๐Ÿ“</span> Example MCP Client Request</h3> <p>Here's how to initialize a connection to your server:</p> <pre>{ "jsonrpc": "2.0", "id": 1, "method": "initialize", "params": { "protocolVersion": "2024-11-05", "capabilities": {}, "clientInfo": { "name": "Test Client", "version": "1.0.0" } } }</pre> </div> <div class="card"> <h3><span class="emoji">๐ŸŽฏ</span> What You Can Do Now</h3> <ol> <li><strong>Test with Claude Desktop:</strong> Add your server and try the built-in tools</li> <li><strong>Register other MCP servers:</strong> Use this platform to test any MCP server</li> <li><strong>Add custom tools:</strong> Extend the server with your own functionality</li> <li><strong>Continue development:</strong> Add web interface, monitoring, and more features</li> </ol> </div> <div class="card"> <h3><span class="emoji">๐Ÿ”—</span> Quick Links</h3> <p><strong>MCP Server:</strong> <code>localhost:8000</code></p> <p><strong>Web Interface:</strong> <code>http://localhost:3001</code></p> <p><strong>Test Client:</strong> <code>py -3 test_client.py</code></p> </div> </div> </body> </html> """ self.wfile.write(html.encode('utf-8')) else: super().do_GET() def start_web_server(): """Start the web server.""" PORT = 3001 # Changed from 3000 to avoid conflicts with socketserver.TCPServer(("", PORT), MCPWebHandler) as httpd: print(f"๐ŸŒ Web interface available at: http://localhost:{PORT}") print(f"๐Ÿ“ก MCP server running at: localhost:8000") print("๐Ÿ›‘ Press Ctrl+C to stop") httpd.serve_forever() if __name__ == "__main__": print("๐Ÿš€ Starting MCP Testing Harness Web Interface") print("=" * 50) start_web_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