From ae3b3d746fa4539a6d276b903fb34854755eb12d Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 8 Aug 2025 16:18:41 -0300 Subject: [PATCH] fix(mcp): append to output instead of replacing (#658) Signed-off-by: Carlos Alexandro Becker --- internal/llm/agent/mcp-tools.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/llm/agent/mcp-tools.go b/internal/llm/agent/mcp-tools.go index a4d68965c62fa6b9e328e6b0bb9fac790c574f02..3b35a0224645ef25e93504b64705f5166ca6f241 100644 --- a/internal/llm/agent/mcp-tools.go +++ b/internal/llm/agent/mcp-tools.go @@ -6,6 +6,7 @@ import ( "fmt" "log/slog" "slices" + "strings" "sync" "time" @@ -122,16 +123,16 @@ func runTool(ctx context.Context, name, toolName string, input string) (tools.To return tools.NewTextErrorResponse(err.Error()), nil } - output := "" + var output strings.Builder for _, v := range result.Content { if v, ok := v.(mcp.TextContent); ok { - output = v.Text + output.WriteString(v.Text) } else { - output = fmt.Sprintf("%v", v) + _, _ = fmt.Fprintf(&output, "%v: ", v) } } - return tools.NewTextResponse(output), nil + return tools.NewTextResponse(output.String()), nil } func (b *McpTool) Run(ctx context.Context, params tools.ToolCall) (tools.ToolResponse, error) {