Skip to content

Commit 8f538c6

Browse files
committed
debug logging
1 parent 2cfebf3 commit 8f538c6

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

src/uipath_mcp/_cli/_runtime/_factory.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""Factory for creating MCP runtime instances."""
22

3+
import json
34
import logging
5+
import os
46
import uuid
57
from typing import Any
68

@@ -51,6 +53,27 @@ def discover_entrypoints(self) -> list[str]:
5153
return []
5254
return mcp_config.get_server_names()
5355

56+
def _debug(self) -> None:
57+
"""Log environment variables and uipath.json config for debugging."""
58+
logger.info("==== DEBUG: Environment Variables ====")
59+
for key, value in sorted(os.environ.items()):
60+
logger.info(" %s=%s", key, value)
61+
62+
logger.info("==== DEBUG: UiPath Config ====")
63+
config_path = os.environ.get("UIPATH_CONFIG_PATH", "uipath.json")
64+
logger.info(" Config path: %s", config_path)
65+
if os.path.exists(config_path):
66+
try:
67+
with open(config_path) as f:
68+
config = json.load(f)
69+
for line in json.dumps(config, indent=2).splitlines():
70+
logger.info(" %s", line)
71+
except Exception as e:
72+
logger.info(" Failed to read config: %s", e)
73+
else:
74+
logger.info(" Config file not found")
75+
logger.info("==== END DEBUG ====")
76+
5477
async def new_runtime(
5578
self, entrypoint: str, runtime_id: str, **kwargs: Any
5679
) -> UiPathRuntimeProtocol:
@@ -66,6 +89,7 @@ async def new_runtime(
6689
Raises:
6790
UiPathMcpRuntimeError: If configuration is invalid or server not found.
6891
"""
92+
self._debug()
6993
mcp_config = self._load_mcp_config()
7094

7195
if not mcp_config.exists:
@@ -100,7 +124,9 @@ async def new_runtime(
100124
)
101125
runtime_id = new_id
102126

103-
server_slug = self.context.mcp_server_slug # if running on different slug, it will be loaded from the context
127+
server_slug = (
128+
self.context.mcp_server_slug
129+
) # if running on different slug, it will be loaded from the context
104130
if server_slug is None:
105131
logger.info("Loading server slug from entrypoint '%s'", entrypoint)
106132
server_slug = entrypoint

0 commit comments

Comments
 (0)