run.pyβ’6.66 kB
#!/usr/bin/env python3
"""
Odoo MCP Server Launcher
Interactive menu to choose transport mode
"""
import sys
import subprocess
from pathlib import Path
def print_banner():
"""Print ASCII art banner"""
banner = r"""
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β βββββββ βββββββ βββββββ βββββββ ββββ ββββ ββββββββββββββ β
β βββββββββββββββββββββββββββββββββββ βββββ βββββββββββββββββββββ β
β βββ ββββββ ββββββ ββββββ βββ ββββββββββββββ ββββββββ β
β βββ ββββββ ββββββ ββββββ βββ ββββββββββββββ βββββββ β
β βββββββββββββββββββββββββββββββββββ βββ βββ ββββββββββββββ β
β βββββββ βββββββ βββββββ βββββββ βββ βββ ββββββββββ β
β β
β Model Context Protocol Server β
β β
β Two tools. Infinite possibilities. Full API access. β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
v1.0.0-beta by AlanOgic | info@alanogic.com
"""
print(banner)
def print_menu():
"""Print transport selection menu"""
menu = """
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Select Transport Mode β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β [1] STDIO Transport (Claude Desktop) β
β β Process pipes (stdin/stdout) β
β β No network required β
β β Default for Claude Desktop integration β
β β
β [2] SSE Transport (Web Browsers) β
β β Server-Sent Events β
β β http://0.0.0.0:8009/sse β
β β Perfect for web-based clients β
β β
β [3] HTTP Transport (API Integrations) β
β β Streamable HTTP β
β β http://0.0.0.0:8008/mcp β
β β REST API compatible β
β β
β [0] Exit β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
"""
print(menu)
def run_server(choice: str) -> None:
"""Run the selected server"""
scripts = {
"1": ("STDIO", "run_server.py"),
"2": ("SSE", "run_server_sse.py"),
"3": ("HTTP", "run_server_http.py"),
}
if choice not in scripts:
print("\nβ Invalid choice!")
return
transport_name, script_name = scripts[choice]
script_path = Path(__file__).parent / script_name
if not script_path.exists():
print(f"\nβ Error: {script_name} not found!")
print(f" Expected location: {script_path}")
return
print(f"\nπ Starting {transport_name} Transport...")
print(f" Script: {script_name}")
if choice == "2":
print(f" URL: http://0.0.0.0:8009/sse")
print(f" Press Ctrl+C to stop")
elif choice == "3":
print(f" URL: http://0.0.0.0:8008/mcp")
print(f" Press Ctrl+C to stop")
print()
print("β" * 70)
print()
try:
# Run the server script
subprocess.run([sys.executable, str(script_path)], check=True)
except KeyboardInterrupt:
print("\n\nβ οΈ Server stopped by user")
except subprocess.CalledProcessError as e:
print(f"\nβ Server exited with error code {e.returncode}")
except Exception as e:
print(f"\nβ Error: {e}")
def main():
"""Main entry point"""
print_banner()
while True:
print_menu()
try:
choice = input(" Enter your choice [0-3]: ").strip()
except KeyboardInterrupt:
print("\n\nπ Goodbye!")
sys.exit(0)
except EOFError:
print("\n\nπ Goodbye!")
sys.exit(0)
if choice == "0":
print("\nπ Goodbye!")
sys.exit(0)
if choice in ["1", "2", "3"]:
run_server(choice)
print("\n" + "=" * 70)
print("Server stopped. Returning to menu...")
print("=" * 70 + "\n")
else:
print("\nβ Invalid choice! Please select 0-3.\n")
if __name__ == "__main__":
main()