From f05731b55f2305cabf99a0dab80fff8485332c98 Mon Sep 17 00:00:00 2001 From: Luca Beurer-Kellner Date: Fri, 16 May 2025 14:05:23 +0200 Subject: [PATCH] append trace even if not pushing --- gateway/mcp/mcp.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gateway/mcp/mcp.py b/gateway/mcp/mcp.py index f812af0..52764c5 100644 --- a/gateway/mcp/mcp.py +++ b/gateway/mcp/mcp.py @@ -305,7 +305,6 @@ async def hook_tool_call(ctx: McpContext, request: dict) -> tuple[dict, bool]: and check_if_new_errors(ctx, guardrailing_result) ): if ctx.push_explorer: - await append_and_push_trace(ctx, message, guardrailing_result) return json_rpc_error_response( @@ -356,6 +355,8 @@ async def hook_tool_result(ctx: McpContext, result: dict) -> dict: if ctx.push_explorer: await append_and_push_trace(ctx, message, guardrailing_result) + else: + ctx.trace.append(message) return result elif method == MCP_LIST_TOOLS: @@ -392,6 +393,8 @@ async def hook_tool_result(ctx: McpContext, result: dict) -> dict: # add it to the session trace (and run logging guardrails) if ctx.push_explorer: await append_and_push_trace(ctx, message, guardrailing_result) + else: + ctx.trace.append(message) return result else: