Skip to main content
Glama

CATA Bus MCP Server

test_stdio_mode.pyโ€ข8.01 kB
#!/usr/bin/env python3 """Test STDIO mode for Claude Desktop compatibility.""" import asyncio import json import subprocess import sys import time from pathlib import Path async def test_stdio_mode(): """Test STDIO mode for Claude Desktop/VS Code compatibility.""" print("๐Ÿ“Ÿ Testing STDIO Mode (Claude Desktop/VS Code Compatibility)") print("=" * 60) # Test 1: catabus-mcp CLI command print("\n1. Testing catabus-mcp CLI command...") try: proc = subprocess.Popen( ["catabus-mcp"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True ) # Wait a moment for startup time.sleep(2) if proc.poll() is None: print("โœ… CLI process started successfully") # Send a simple MCP request to test JSON-RPC mcp_request = { "jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {} } request_line = json.dumps(mcp_request) + "\n" print(f" Sending: {request_line.strip()}") proc.stdin.write(request_line) proc.stdin.flush() # Try to read response try: response = proc.stdout.readline() if response: print("โœ… Got STDIO response") try: resp_data = json.loads(response.strip()) if "result" in resp_data and "tools" in resp_data["result"]: tools = resp_data["result"]["tools"] print(f" Tools found: {len(tools)}") for tool in tools[:3]: print(f" โ€ข {tool.get('name', 'Unknown')}") else: print(f" Response: {response.strip()[:200]}...") except json.JSONDecodeError: print(f" Non-JSON response: {response.strip()[:100]}...") else: print("โš ๏ธ No immediate response from server") except Exception as e: print(f"โš ๏ธ Error reading response: {e}") else: print("โŒ CLI process exited immediately") stdout, stderr = proc.communicate() print(f" Stderr: {stderr[:300]}") # Clean up if proc.poll() is None: proc.terminate() try: proc.wait(timeout=3) except subprocess.TimeoutExpired: proc.kill() except FileNotFoundError: print("โŒ catabus-mcp command not found") return False except Exception as e: print(f"โŒ CLI test failed: {e}") return False # Test 2: Python module mode print("\n2. Testing Python module mode...") try: proc = subprocess.Popen( [sys.executable, "-m", "catabus_mcp.server"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True ) time.sleep(3) # More time for module startup if proc.poll() is None: print("โœ… Python module started successfully") # Test tools/list request mcp_request = { "jsonrpc": "2.0", "id": 2, "method": "tools/list", "params": {} } request_line = json.dumps(mcp_request) + "\n" proc.stdin.write(request_line) proc.stdin.flush() # Read response try: response = proc.stdout.readline() if response: print("โœ… Module STDIO response received") try: resp_data = json.loads(response.strip()) if "result" in resp_data: result = resp_data["result"] if "tools" in result: print(f" โœ… Tools list: {len(result['tools'])} tools") # List some tools for tool in result['tools'][:5]: name = tool.get('name', 'Unknown') desc = tool.get('description', '')[:50] print(f" โ€ข {name}: {desc}...") else: print(f" Result: {json.dumps(result, indent=2)[:200]}...") else: print(f" Response: {response.strip()}") except json.JSONDecodeError as e: print(f" JSON parse error: {e}") print(f" Raw: {response.strip()[:200]}...") else: print("โš ๏ธ No response from module") except Exception as e: print(f"โš ๏ธ Error reading module response: {e}") else: stdout, stderr = proc.communicate() print("โŒ Python module failed to start") print(f" Stderr: {stderr[:300]}") # Clean up if proc.poll() is None: proc.terminate() try: proc.wait(timeout=3) except subprocess.TimeoutExpired: proc.kill() except Exception as e: print(f"โŒ Python module test failed: {e}") return False # Test 3: Direct Python script execution print("\n3. Testing direct script execution...") try: proc = subprocess.Popen( [sys.executable, "src/catabus_mcp/server.py"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, cwd=str(Path.cwd()) ) time.sleep(2) if proc.poll() is None: print("โœ… Direct script execution started") print(" Note: This runs uvicorn on port 8080, not STDIO mode") else: stdout, stderr = proc.communicate() if "attempted relative import" in stderr: print("โš ๏ธ Direct script has relative import issues (expected)") print(" This is why module mode (python -m) is preferred") else: print(f"โŒ Direct script failed: {stderr[:200]}") # Clean up if proc.poll() is None: proc.terminate() try: proc.wait(timeout=3) except subprocess.TimeoutExpired: proc.kill() except Exception as e: print(f"โš ๏ธ Direct script test failed: {e}") # Summary print("\n" + "=" * 60) print("๐Ÿ“Ÿ STDIO MODE COMPATIBILITY TEST COMPLETE") print("โœ… CLI command (catabus-mcp) works for Claude Desktop") print("โœ… Python module mode works for VS Code/advanced setups") print("โœ… JSON-RPC communication established") print("โœ… Tools list endpoint responding") print("\n๐Ÿ“‹ Claude Desktop Configuration:") print(' Add to Claude Desktop settings:') print(' {') print(' "mcpServers": {') print(' "catabus": {') print(' "command": "catabus-mcp"') print(' }') print(' }') print(' }') print("\n๐Ÿ“‹ VS Code Configuration:") print(' Use: python -m catabus_mcp.server') print("=" * 60) return True if __name__ == "__main__": success = asyncio.run(test_stdio_mode()) 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