fix(mcp): tool output join with new line (#686)

Carlos Alexandro Becker created

* fix(mcp): tool output join with new line

refs #604
refs #658

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* fix: make

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

---------

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

Change summary

internal/llm/agent/mcp-tools.go | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

Detailed changes

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) {