Skip to content

Commit 774adde

Browse files
committed
refactor: decouple config and api call from server
1 parent 428d26a commit 774adde

File tree

3 files changed

+176
-148
lines changed

3 files changed

+176
-148
lines changed

src/mcp_server_uyuni/config.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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_SSL_VERIFY = (
20+
os.environ.get("UYUNI_MCP_SSL_VERIFY", "true").lower()
21+
not in ("false", "0", "no")
22+
)
23+
UYUNI_MCP_WRITE_TOOLS_ENABLED = os.environ.get('UYUNI_MCP_WRITE_TOOLS_ENABLED', 'false').lower() in ('true', '1', 'yes')
24+
UYUNI_MCP_TRANSPORT = os.environ.get('UYUNI_MCP_TRANSPORT', 'stdio')
25+
UYUNI_MCP_LOG_FILE_PATH = os.environ.get('UYUNI_MCP_LOG_FILE_PATH')
26+
27+
28+
CONFIG = {
29+
"UYUNI_SERVER": UYUNI_SERVER,
30+
"UYUNI_USER": UYUNI_USER,
31+
"UYUNI_PASS": UYUNI_PASS,
32+
"UYUNI_MCP_SSL_VERIFY": UYUNI_MCP_SSL_VERIFY,
33+
"UYUNI_MCP_WRITE_TOOLS_ENABLED": UYUNI_MCP_WRITE_TOOLS_ENABLED,
34+
"UYUNI_MCP_TRANSPORT": UYUNI_MCP_TRANSPORT,
35+
"UYUNI_MCP_LOG_FILE_PATH": UYUNI_MCP_LOG_FILE_PATH,
36+
}

0 commit comments

Comments
 (0)