Skip to content

Commit 2acc2eb

Browse files
authored
Merge pull request #35 from UiPath/fix/samples
fix: gracefully handle subprocess init failure
2 parents 6adcc50 + a841ad1 commit 2acc2eb

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "uipath-mcp"
3-
version = "0.0.31"
3+
version = "0.0.32"
44
description = "UiPath MCP SDK"
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.10"

src/uipath_mcp/_cli/_runtime/_runtime.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ async def execute(self) -> Optional[UiPathRuntimeResult]:
6262
with tracer.start_as_current_span(self.server.name) as root_span:
6363
root_span.set_attribute("session_id", self.server.session_id)
6464
root_span.set_attribute("command", self.server.command)
65-
root_span.set_attribute("env", self.server.env)
6665
root_span.set_attribute("args", self.server.args)
6766
self.signalr_client = SignalRClient(
6867
signalr_url,
@@ -222,7 +221,6 @@ async def _register(self) -> None:
222221
async with stdio_client(server_params) as (read, write):
223222
async with ClientSession(read, write) as session:
224223
logger.info("Initializing client session...")
225-
226224
# Try to initialize with timeout
227225
try:
228226
await asyncio.wait_for(
@@ -242,14 +240,17 @@ async def _register(self) -> None:
242240
# We don't continue with registration here - we'll do it after the context managers
243241

244242
except Exception as e:
245-
# Handle any other exceptions that occur
246-
logger.error(f"Error during server initialization: {e}")
247-
raise UiPathMcpRuntimeError(
248-
"SERVER_ERROR",
249-
"Server initialization failed",
250-
str(e),
251-
UiPathErrorCategory.DEPLOYMENT,
252-
) from e
243+
# Just log the exception during cleanup - it's expected
244+
if "ProcessLookupError" in str(e) or "ExceptionGroup" in str(e):
245+
logger.info("Process already terminated during cleanup - this is expected")
246+
else:
247+
logger.error(f"Error during server initialization: {e}")
248+
raise UiPathMcpRuntimeError(
249+
"SERVER_ERROR",
250+
"Server initialization failed",
251+
str(e),
252+
UiPathErrorCategory.DEPLOYMENT,
253+
) from e
253254

254255
# Now that we're outside the context managers, check if initialization succeeded
255256
if not initialization_successful:

src/uipath_mcp/_cli/_runtime/_session.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,8 @@ async def _run_server(self, server_params: StdioServerParameters) -> None:
7676
# Process incoming messages from the server
7777
try:
7878
while True:
79-
print("Waiting for messages...")
79+
logger.info("Waiting for messages...")
8080
message = await self.read_stream.receive()
81-
json_str = message.model_dump_json()
82-
print(f"Received message from local server: {json_str}")
8381
await self.send_outgoing_message(message)
8482
finally:
8583
# Cancel the consumer when we exit the loop

0 commit comments

Comments
 (0)