Skip to content

Commit 35c5745

Browse files
committed
Ensure connector always passes meta placeholder
Pass `_meta=None` through connector call_tool even when no trace is set and keep FastMCP cast typed.
1 parent 99bf4c1 commit 35c5745

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

hud/clients/fastmcp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ async def _call_tool(self, tool_call: MCPToolCall) -> MCPToolResult:
148148
meta = {"_hud_trace_id": trace_id}
149149

150150
# FastMCP returns a different result type, convert it
151-
client = cast(Any, self._client)
151+
client = cast("Any", self._client)
152152
# Only pass _meta if we have trace context to avoid test/API issues
153153
if meta:
154154
try:

hud/environment/connection.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,17 +198,13 @@ async def call_tool(
198198

199199
args = dict(arguments or {})
200200
trace_id = get_current_trace_id()
201+
meta = {"_hud_trace_id": trace_id} if trace_id else None
201202

202203
client = cast("Any", self.client)
203-
# Only pass _meta if we have trace context
204-
if trace_id:
205-
meta = {"_hud_trace_id": trace_id}
206-
try:
207-
result = await client.call_tool(name=name, arguments=args, _meta=meta)
208-
except TypeError:
209-
# Fallback for clients that don't accept _meta
210-
result = await client.call_tool(name=name, arguments=args)
211-
else:
204+
try:
205+
result = await client.call_tool(name=name, arguments=args, _meta=meta)
206+
except TypeError:
207+
# Fallback for clients that don't accept _meta
212208
result = await client.call_tool(name=name, arguments=args)
213209

214210
# FastMCP and mcp-python use slightly different result shapes/types.

0 commit comments

Comments
 (0)