Skip to content

Commit 93a7c4a

Browse files
authored
Merge pull request #41 from UiPath/fix/samples
fix: traces input
2 parents 09c015e + 97aeb5b commit 93a7c4a

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
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.37"
3+
version = "0.0.38"
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ async def execute(self) -> Optional[UiPathRuntimeResult]:
6464
root_span.set_attribute("session_id", self.server.session_id)
6565
root_span.set_attribute("command", self.server.command)
6666
root_span.set_attribute("args", self.server.args)
67-
root_span.set_attribute("span_type", "server")
67+
root_span.set_attribute("span_type", "MCP Server")
6868
self.signalr_client = SignalRClient(
6969
signalr_url,
7070
headers={

src/uipath_mcp/_cli/_runtime/_tracer.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,20 @@ def create_span_for_message(self, message: types.JSONRPCMessage, **context) -> S
5151
if isinstance(root_value, types.JSONRPCResponse):
5252
span = self.tracer.start_span("response", context=span_context)
5353
span.set_attribute("type", "response")
54-
span.set_attribute("span_type", "response")
54+
span.set_attribute("span_type", "MCP response")
5555
span.set_attribute("id", str(root_value.id))
5656
if isinstance(root_value.result, dict):
5757
parent_span.set_attribute("output", json.dumps(root_value.result))
5858
self._add_response_attributes(span, root_value)
59+
parent_span.add_event(
60+
"response",
61+
{"output": json.dumps(root_value.result)}
62+
)
63+
parent_span.end()
5964
else: # JSONRPCError
6065
span = self.tracer.start_span("error", context=span_context)
6166
span.set_attribute("type", "error")
62-
span.set_attribute("span_type", "error")
67+
span.set_attribute("span_type", "MCP error")
6368
span.set_attribute("id", str(root_value.id))
6469
span.set_attribute("error_code", root_value.error.code)
6570
span.set_attribute("error_message", root_value.error.message)
@@ -71,7 +76,7 @@ def create_span_for_message(self, message: types.JSONRPCMessage, **context) -> S
7176
if isinstance(root_value, types.JSONRPCRequest):
7277
span = self.tracer.start_span(f"{root_value.method}")
7378
span.set_attribute("type", "request")
74-
span.set_attribute("span_type", "request")
79+
span.set_attribute("span_type", "MCP request")
7580
span.set_attribute("id", str(root_value.id))
7681
span.set_attribute("method", root_value.method)
7782
self._add_request_attributes(span, root_value)
@@ -82,21 +87,21 @@ def create_span_for_message(self, message: types.JSONRPCMessage, **context) -> S
8287
elif isinstance(root_value, types.JSONRPCNotification):
8388
span = self.tracer.start_span(root_value.method)
8489
span.set_attribute("type", "notification")
85-
span.set_attribute("span_type", "notification")
90+
span.set_attribute("span_type", "MCP notification")
8691
span.set_attribute("method", root_value.method)
8792
self._add_notification_attributes(span, root_value)
8893

8994
elif isinstance(root_value, types.JSONRPCResponse):
9095
span = self.tracer.start_span("response")
9196
span.set_attribute("type", "response")
92-
span.set_attribute("span_type", "response")
97+
span.set_attribute("span_type", "MCP response")
9398
span.set_attribute("id", str(root_value.id))
9499
self._add_response_attributes(span, root_value)
95100

96101
elif isinstance(root_value, types.JSONRPCError):
97102
span = self.tracer.start_span("error")
98103
span.set_attribute("type", "error")
99-
span.set_attribute("span_type", "error")
104+
span.set_attribute("span_type", "MCP error")
100105
span.set_attribute("id", str(root_value.id))
101106
span.set_attribute("error_code", root_value.error.code)
102107
span.set_attribute("error_message", root_value.error.message)
@@ -118,22 +123,19 @@ def _add_request_attributes(
118123
if request.params:
119124
# Add basic param information
120125
if isinstance(request.params, dict):
121-
span.set_attribute("params", json.dumps(request.params))
126+
span.set_attribute("input", json.dumps(request.params))
122127

123128
# Handle specific request types based on method
124129
if request.method == "tools/call" and isinstance(request.params, dict):
125130
if "name" in request.params:
126-
span.set_attribute("tool_name", request.params["name"])
131+
span.set_attribute("name", request.params["name"])
127132
span.update_name(f"{request.method}/{request.params['name']}")
128133
if "arguments" in request.params and isinstance(
129134
request.params["arguments"], dict
130135
):
131136
span.set_attribute(
132137
"input", json.dumps(request.params["arguments"])
133138
)
134-
span.set_attribute(
135-
"tool_args", json.dumps(request.params["arguments"])
136-
)
137139

138140
# Handle specific tracing for other method types
139141
elif request.method == "resources/read" and isinstance(

0 commit comments

Comments
 (0)