Skip to content

Commit e9f6dc3

Browse files
committed
refactor: decouple config and api call from server
1 parent 15005fb commit e9f6dc3

File tree

3 files changed

+181
-150
lines changed

3 files changed

+181
-150
lines changed

src/mcp_server_uyuni/config.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import os
2+
3+
REQUIRED_VARS = [
4+
"UYUNI_SERVER",
5+
"UYUNI_USER",
6+
"UYUNI_PASS",
7+
]
8+
9+
missing_vars = [key for key in REQUIRED_VARS if key not in os.environ]
10+
if missing_vars:
11+
raise ImportError(
12+
f"Failed to import config: Missing required environment variables: {', '.join(missing_vars)}"
13+
)
14+
15+
UYUNI_SERVER = 'https://' + os.environ["UYUNI_SERVER"]
16+
UYUNI_USER = os.environ["UYUNI_USER"]
17+
UYUNI_PASS = os.environ["UYUNI_PASS"]
18+
19+
UYUNI_MCP_HOST = os.environ.get("UYUNI_MCP_HOST", "127.0.0.1")
20+
UYUNI_MCP_PORT = int(os.environ.get("UYUNI_MCP_PORT", "8000"))
21+
UYUNI_AUTH_SERVER = os.environ.get("UYUNI_AUTH_SERVER")
22+
23+
UYUNI_MCP_SSL_VERIFY = (
24+
os.environ.get("UYUNI_MCP_SSL_VERIFY", "true").lower()
25+
not in ("false", "0", "no")
26+
)
27+
UYUNI_MCP_WRITE_TOOLS_ENABLED = os.environ.get('UYUNI_MCP_WRITE_TOOLS_ENABLED', 'false').lower() in ('true', '1', 'yes')
28+
UYUNI_MCP_TRANSPORT = os.environ.get('UYUNI_MCP_TRANSPORT', 'stdio')
29+
UYUNI_MCP_LOG_FILE_PATH = os.environ.get('UYUNI_MCP_LOG_FILE_PATH')
30+
31+
32+
CONFIG = {
33+
"UYUNI_SERVER": UYUNI_SERVER,
34+
"UYUNI_USER": UYUNI_USER,
35+
"UYUNI_PASS": UYUNI_PASS,
36+
"UYUNI_MCP_SSL_VERIFY": UYUNI_MCP_SSL_VERIFY,
37+
"UYUNI_MCP_WRITE_TOOLS_ENABLED": UYUNI_MCP_WRITE_TOOLS_ENABLED,
38+
"UYUNI_MCP_TRANSPORT": UYUNI_MCP_TRANSPORT,
39+
"UYUNI_MCP_LOG_FILE_PATH": UYUNI_MCP_LOG_FILE_PATH,
40+
"UYUNI_MCP_HOST": UYUNI_MCP_HOST,
41+
"UYUNI_MCP_PORT": UYUNI_MCP_PORT,
42+
"AUTH_SERVER": UYUNI_AUTH_SERVER
43+
}

0 commit comments

Comments
 (0)