portainer-mcp/scripts/run-with-uv.py
Adolfo Delorenzo be1e05c382 Simplify authentication to require URL and API key only
Major configuration and tooling updates:

Authentication Changes:
- Remove username/password authentication support
- Require PORTAINER_URL and PORTAINER_API_KEY (both mandatory)
- Simplify PortainerConfig class and validation logic
- Update all documentation to reflect API key requirement

Multiple Runtime Support:
- Add uvx support for running without installation
- Add uv support with dedicated wrapper script
- Add npx support with Node.js wrapper script
- Maintain backward compatibility with direct Python execution

Documentation Updates:
- Comprehensive README.md with all execution methods
- Detailed USAGE.md with step-by-step instructions
- Updated .env.example with clear required vs optional sections
- Enhanced docstrings in server.py and config.py

Tooling Support:
- package.json for npm/npx support with cross-platform wrapper
- scripts/run-with-uv.py for uv integration
- bin/portainer-core-mcp Node.js wrapper for npx
- test_uvx.py for uvx functionality testing

Configuration Improvements:
- Clear separation of required vs optional environment variables
- Better validation error messages
- Simplified authentication flow
- Enhanced project metadata in pyproject.toml

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-18 07:48:23 -06:00

64 lines
1.6 KiB
Python
Executable File

#!/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()