#!/usr/bin/env python3 """ UV runner script for Portainer Core MCP Server. This script provides a way to run the MCP server using uv for dependency management. """ import os import sys import subprocess from pathlib import Path def find_project_root(): """Find the project root directory.""" current = Path(__file__).parent while current != current.parent: if (current / "pyproject.toml").exists(): return current current = current.parent return Path(__file__).parent.parent def check_uv(): """Check if uv is installed.""" try: subprocess.run(["uv", "--version"], capture_output=True, check=True) return True except (subprocess.CalledProcessError, FileNotFoundError): return False def run_server(): """Run the server using uv.""" project_root = find_project_root() # Check if uv is available if not check_uv(): print("āŒ uv is not installed or not in PATH") print("šŸ’” Install uv: pip install uv") print("šŸ’” Or use: python run_server.py") sys.exit(1) print("šŸš€ Starting Portainer Core MCP Server with uv...") # Change to project root os.chdir(project_root) # Run the server with uv try: subprocess.run([ "uv", "run", "python", "run_server.py" ], check=True) except subprocess.CalledProcessError as e: print(f"āŒ Server failed with exit code {e.returncode}") sys.exit(e.returncode) except KeyboardInterrupt: print("\nšŸ‘‹ Server stopped by user") sys.exit(0) if __name__ == "__main__": run_server()