2020from uipath ._cli ._runtime ._contracts import (
2121 UiPathBaseRuntime ,
2222 UiPathErrorCategory ,
23+ UiPathErrorCode ,
2324 UiPathRuntimeResult ,
2425)
2526from uipath .tracing import LlmOpsHttpExporter
2627
2728from .._utils ._config import McpServer
2829from ._context import UiPathMcpRuntimeContext , UiPathServerType
29- from ._exception import UiPathMcpRuntimeError
30+ from ._exception import McpErrorCode , UiPathMcpRuntimeError
3031from ._session import SessionServer
3132
3233logger = logging .getLogger (__name__ )
@@ -56,15 +57,15 @@ async def validate(self) -> None:
5657 """Validate runtime inputs and load MCP server configuration."""
5758 if self .context .config is None :
5859 raise UiPathMcpRuntimeError (
59- " CONFIGURATION_ERROR" ,
60+ McpErrorCode . CONFIGURATION_ERROR ,
6061 "Missing configuration" ,
6162 "Configuration is required." ,
6263 UiPathErrorCategory .SYSTEM ,
6364 )
6465
6566 if self .context .entrypoint is None :
6667 raise UiPathMcpRuntimeError (
67- " CONFIGURATION_ERROR" ,
68+ McpErrorCode . CONFIGURATION_ERROR ,
6869 "Missing entrypoint" ,
6970 "Entrypoint is required." ,
7071 UiPathErrorCategory .SYSTEM ,
@@ -73,7 +74,7 @@ async def validate(self) -> None:
7374 self ._server = self .context .config .get_server (self .context .entrypoint )
7475 if not self ._server :
7576 raise UiPathMcpRuntimeError (
76- " SERVER_NOT_FOUND" ,
77+ McpErrorCode . SERVER_NOT_FOUND ,
7778 "MCP server not found" ,
7879 f"Server '{ self .context .entrypoint } ' not found in configuration" ,
7980 UiPathErrorCategory .DEPLOYMENT ,
@@ -88,31 +89,31 @@ def _validate_auth(self) -> None:
8889 uipath_url = os .environ .get ("UIPATH_URL" )
8990 if not uipath_url :
9091 raise UiPathMcpRuntimeError (
91- " CONFIGURATION_ERROR" ,
92+ McpErrorCode . CONFIGURATION_ERROR ,
9293 "Missing UIPATH_URL environment variable" ,
9394 "Please run 'uipath auth'." ,
9495 UiPathErrorCategory .USER ,
9596 )
9697
9798 if not self .context .trace_context :
9899 raise UiPathMcpRuntimeError (
99- " CONFIGURATION_ERROR" ,
100+ McpErrorCode . CONFIGURATION_ERROR ,
100101 "Missing trace context" ,
101102 "Trace context is required for SignalR connection." ,
102103 UiPathErrorCategory .SYSTEM ,
103104 )
104105
105106 if not self .context .trace_context .tenant_id :
106107 raise UiPathMcpRuntimeError (
107- " CONFIGURATION_ERROR" ,
108+ McpErrorCode . CONFIGURATION_ERROR ,
108109 "Missing tenant ID" ,
109110 "Please run 'uipath auth'." ,
110111 UiPathErrorCategory .SYSTEM ,
111112 )
112113
113114 if not self .context .trace_context .org_id :
114115 raise UiPathMcpRuntimeError (
115- " CONFIGURATION_ERROR" ,
116+ McpErrorCode . CONFIGURATION_ERROR ,
116117 "Missing organization ID" ,
117118 "Please run 'uipath auth'." ,
118119 UiPathErrorCategory .SYSTEM ,
@@ -152,7 +153,7 @@ async def execute(self) -> Optional[UiPathRuntimeResult]:
152153 folder_path = os .environ .get ("UIPATH_FOLDER_PATH" )
153154 if not folder_path :
154155 raise UiPathMcpRuntimeError (
155- " REGISTRATION_ERROR" ,
156+ McpErrorCode . REGISTRATION_ERROR ,
156157 "No UIPATH_FOLDER_PATH or UIPATH_FOLDER_KEY environment variable set." ,
157158 "Please set the UIPATH_FOLDER_PATH or UIPATH_FOLDER_KEY environment variable." ,
158159 UiPathErrorCategory .USER ,
@@ -162,7 +163,7 @@ async def execute(self) -> Optional[UiPathRuntimeResult]:
162163 )
163164 if not self .context .folder_key :
164165 raise UiPathMcpRuntimeError (
165- " REGISTRATION_ERROR" ,
166+ McpErrorCode . REGISTRATION_ERROR ,
166167 "Folder NOT FOUND. Invalid UIPATH_FOLDER_PATH environment variable." ,
167168 "Please set the UIPATH_FOLDER_PATH or UIPATH_FOLDER_KEY environment variable." ,
168169 UiPathErrorCategory .USER ,
@@ -235,7 +236,7 @@ async def execute(self) -> Optional[UiPathRuntimeResult]:
235236 raise
236237 detail = f"Error: { str (e )} "
237238 raise UiPathMcpRuntimeError (
238- " EXECUTION_ERROR" ,
239+ UiPathErrorCode . EXECUTION_ERROR ,
239240 "MCP Runtime execution failed" ,
240241 detail ,
241242 UiPathErrorCategory .USER ,
@@ -421,7 +422,7 @@ async def _register(self) -> None:
421422 if server_stderr_output :
422423 error_message += f"\n Server error output:\n { server_stderr_output } "
423424 raise UiPathMcpRuntimeError (
424- " INITIALIZATION_ERROR" ,
425+ McpErrorCode . INITIALIZATION_ERROR ,
425426 "Server initialization failed" ,
426427 error_message ,
427428 UiPathErrorCategory .DEPLOYMENT ,
@@ -433,7 +434,7 @@ async def _register(self) -> None:
433434 try :
434435 if not tools_result :
435436 raise UiPathMcpRuntimeError (
436- " INITIALIZATION_ERROR" ,
437+ McpErrorCode . INITIALIZATION_ERROR ,
437438 "Server initialization failed" ,
438439 "Failed to get tools list from server" ,
439440 UiPathErrorCategory .DEPLOYMENT ,
@@ -478,7 +479,7 @@ async def _register(self) -> None:
478479 )
479480
480481 raise UiPathMcpRuntimeError (
481- " REGISTRATION_ERROR" ,
482+ McpErrorCode . REGISTRATION_ERROR ,
482483 "Failed to register MCP Server" ,
483484 str (e ),
484485 UiPathErrorCategory .SYSTEM ,
0 commit comments