From 073d130b756615c799274187fc1ceb67509edcb7 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 13 Aug 2025 15:58:48 -0300 Subject: [PATCH] fix(mcp): tool output join with new line (#686) * fix(mcp): tool output join with new line refs #604 refs #658 Signed-off-by: Carlos Alexandro Becker * fix: make Signed-off-by: Carlos Alexandro Becker --------- Signed-off-by: Carlos Alexandro Becker --- internal/llm/agent/mcp-tools.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/internal/llm/agent/mcp-tools.go b/internal/llm/agent/mcp-tools.go index 0d130d04f84daa5b407097d837ef6e05c8204422..e5cc769bdd2e1855557eb1c4ea326df68ccc5cf0 100644 --- a/internal/llm/agent/mcp-tools.go +++ b/internal/llm/agent/mcp-tools.go @@ -123,16 +123,15 @@ func runTool(ctx context.Context, name, toolName string, input string) (tools.To return tools.NewTextErrorResponse(err.Error()), nil } - var output strings.Builder + output := make([]string, 0, len(result.Content)) for _, v := range result.Content { if v, ok := v.(mcp.TextContent); ok { - output.WriteString(v.Text) + output = append(output, v.Text) } else { - _, _ = fmt.Fprintf(&output, "%v: ", v) + output = append(output, fmt.Sprintf("%v", v)) } } - - return tools.NewTextResponse(output.String()), nil + return tools.NewTextResponse(strings.Join(output, "\n")), nil } func (b *McpTool) Run(ctx context.Context, params tools.ToolCall) (tools.ToolResponse, error) {