portainer-mcp/test_uvx.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

56 lines
1.6 KiB
Python

#!/usr/bin/env python3
"""
Test script to verify uvx functionality.
"""
import subprocess
import sys
import os
def test_uvx():
"""Test that uvx can run the application."""
print("🧪 Testing uvx functionality...")
# Set test environment variables
env = os.environ.copy()
env['PORTAINER_URL'] = 'https://demo.portainer.io'
env['PORTAINER_API_KEY'] = 'demo-key'
try:
# Test uvx --help first
result = subprocess.run([
'uvx', '--help'
], capture_output=True, text=True, timeout=10)
if result.returncode != 0:
print("❌ uvx not available")
return False
print("✅ uvx is available")
# Test that our package can be found
print("📦 Testing package discovery...")
result = subprocess.run([
'uvx', '--from', '.', 'portainer-core-mcp', '--help'
], capture_output=True, text=True, timeout=10, env=env)
if result.returncode != 0:
print(f"❌ Package test failed: {result.stderr}")
return False
print("✅ Package can be discovered by uvx")
return True
except subprocess.TimeoutExpired:
print("❌ uvx test timed out")
return False
except FileNotFoundError:
print("❌ uvx not found - install with: pip install uv")
return False
except Exception as e:
print(f"❌ uvx test failed: {e}")
return False
if __name__ == "__main__":
success = test_uvx()
sys.exit(0 if success else 1)