#!/usr/bin/env python # -*- coding: utf-8 -*- """ Check Maya MCP Server Binding Address This script checks the binding address of the Maya MCP server and attempts to connect to it. """ import socket import sys import time def check_server_binding(host="127.0.0.1", port=4550): """ Check server binding address Args: host (str): Server host port (int): Server port """ print("===================================") print("Maya MCP Server Binding Check") print("===================================") # Check 127.0.0.1 print(f"\nChecking connection to 127.0.0.1:{port}...") try: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(2) result = sock.connect_ex(("127.0.0.1", port)) if result == 0: print(f"✓ Successfully connected to 127.0.0.1:{port}") else: print(f"✗ Could not connect to 127.0.0.1:{port}") sock.close() except Exception as e: print(f"✗ Error connecting to 127.0.0.1:{port}: {e}") # Check 0.0.0.0 (via local IP) local_ip = socket.gethostbyname(socket.gethostname()) print(f"\nChecking connection to {local_ip}:{port}...") try: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(2) result = sock.connect_ex((local_ip, port)) if result == 0: print(f"✓ Successfully connected to {local_ip}:{port}") else: print(f"✗ Could not connect to {local_ip}:{port}") sock.close() except Exception as e: print(f"✗ Error connecting to {local_ip}:{port}: {e}") print("\n===================================") print("Binding Check Results") print("===================================") if result == 0: print("Server appears to be bound to 0.0.0.0 (all interfaces)") print("This means the server can be accessed from any IP address") else: print("Server appears to be bound to 127.0.0.1 (localhost only)") print("This means the server can only be accessed from the local machine") print("\n===================================") if __name__ == "__main__": # Get command line arguments port = 4550 # Parse command line arguments if len(sys.argv) > 1: port = int(sys.argv[1]) # Check server binding check_server_binding(port=port) print("Press any key to exit...") input()