-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_connection.py
More file actions
41 lines (31 loc) · 1.26 KB
/
Copy pathtest_connection.py
File metadata and controls
41 lines (31 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python3
"""Test script to verify UISP API connection."""
import asyncio
import os
from dotenv import load_dotenv
from uisp_api_mcp.client import UISPClient
from uisp_api_mcp.settings import settings
# Load environment variables
load_dotenv()
async def test_connection():
"""Test basic connection to UISP API."""
print(f"Testing connection to: {settings.uisp_base_url}")
print(f"API Base URL: {settings.api_base_url}")
print(f"API token configured: {'Yes' if settings.uisp_api_token else 'No'}")
try:
async with UISPClient() as client:
# Try to get server status
print("\nTesting /server/status endpoint...")
result = await client.get("server/status")
print(f"✅ Success! Server version: {result.get('version', 'Unknown')}")
# Try to get current user
print("\nTesting /user endpoint...")
user = await client.get("user")
print(f"✅ Success! Logged in as: {user.get('username', 'Unknown')}")
except Exception as e:
print(f"❌ Error: {type(e).__name__}: {e}")
return False
return True
if __name__ == "__main__":
success = asyncio.run(test_connection())
exit(0 if success else 1)