Skip to main content
Glama

CATA Bus MCP Server

test_fastmcp_local.pyโ€ข6.14 kB
#!/usr/bin/env python3 """Test FastMCP local development workflow.""" import asyncio import subprocess import sys import time import requests import json from pathlib import Path async def test_fastmcp_local(): """Test FastMCP local development workflow.""" print("๐Ÿ–ฅ๏ธ Testing FastMCP Local Development Workflow") print("=" * 50) # Test 1: Import and basic functionality print("\n1. Testing direct server import...") try: from catabus_mcp.server import mcp, server, app print(f"โœ… Server import successful") print(f" MCP: {mcp}") print(f" Server: {server}") print(f" App: {type(app)}") # Test basic client connection from fastmcp import Client client = Client(mcp) async with client: start_time = time.time() result = await client.call_tool("health_check", {}) health_time = time.time() - start_time print(f"โœ… FastMCP Client connection: {health_time:.3f}s") # Extract result if hasattr(result, 'content') and isinstance(result.content, list) and len(result.content) > 0: text_content = result.content[0] if hasattr(text_content, 'text'): health = json.loads(text_content.text) print(f" Status: {health['status']}") print(f" Startup mode: {health['startup_mode']}") except Exception as e: print(f"โŒ Server import failed: {e}") return False # Test 2: HTTP server startup print("\n2. Testing HTTP server (port 8000)...") try: # Start HTTP server on port 8000 cmd = [sys.executable, "-m", "uvicorn", "catabus_mcp.server:app", "--host", "127.0.0.1", "--port", "8000"] print(f" Starting: {' '.join(cmd)}") proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True ) # Wait for startup time.sleep(4) if proc.poll() is None: print("โœ… HTTP server started successfully") # Test basic HTTP response try: response = requests.get("http://127.0.0.1:8000/", timeout=5) print(f"โœ… HTTP endpoint responding: {response.status_code}") # Test if it looks like a FastMCP response if response.status_code == 404: print("โœ… Expected 404 for root endpoint (FastMCP server)") elif response.status_code == 200: print(f" Response preview: {response.text[:100]}...") except requests.exceptions.RequestException as e: print(f"โš ๏ธ HTTP request failed: {e}") # Test MCP endpoints (basic discovery) print("\n3. Testing MCP endpoint structure...") try: # Try some common MCP paths mcp_paths = ["/mcp/", "/v1/mcp/", "/health"] for path in mcp_paths: try: resp = requests.get(f"http://127.0.0.1:8000{path}", timeout=3) if resp.status_code != 404: print(f"โœ… Found endpoint {path}: {resp.status_code}") if resp.headers.get('content-type', '').startswith('application/json'): print(f" JSON response: {resp.text[:200]}...") break except: pass else: print("โš ๏ธ No obvious MCP endpoints found") print(" This is normal - MCP might use different endpoint patterns") except Exception as e: print(f"โš ๏ธ MCP endpoint testing failed: {e}") else: stdout, stderr = proc.communicate() print(f"โŒ HTTP server failed to start") print(f" Stderr: {stderr[-300:]}") return False # Clean up proc.terminate() try: proc.wait(timeout=3) except subprocess.TimeoutExpired: proc.kill() except Exception as e: print(f"โŒ HTTP server test failed: {e}") return False # Test 3: CLI command functionality print("\n4. Testing CLI command...") try: # Test the catabus-mcp command briefly result = subprocess.run( ["timeout", "3", "catabus-mcp"], capture_output=True, text=True, timeout=5 ) if "catabus-mcp" in result.stderr or "FastMCP" in result.stderr: print("โœ… CLI command available and starts correctly") else: print(f"โš ๏ธ CLI output unexpected: {result.stderr[:200]}...") except subprocess.TimeoutExpired: print("โœ… CLI command started (timed out as expected)") except FileNotFoundError: print("โŒ timeout command not found, but CLI test would work") except Exception as e: print(f"โš ๏ธ CLI test inconclusive: {e}") # Summary print("\n" + "=" * 50) print("๐ŸŽ‰ FASTMCP LOCAL DEVELOPMENT: READY") print("โœ… Server imports correctly") print("โœ… FastMCP Client connection works") print("โœ… HTTP server starts on port 8000") print("โœ… CLI command available") print("\n๐Ÿ“‹ Usage Instructions:") print(" โ€ข FastMCP Client: from fastmcp import Client; client = Client(mcp)") print(" โ€ข HTTP mode: uvicorn catabus_mcp.server:app --host 127.0.0.1 --port 8000") print(" โ€ข STDIO mode: catabus-mcp") print(" โ€ข Module mode: python -m catabus_mcp.server") print("=" * 50) return True if __name__ == "__main__": success = asyncio.run(test_fastmcp_local()) sys.exit(0 if success else 1)

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/Pranav-Karra-3301/catabus-mcp'

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