on main help sign in
fix(mcp): append to output instead of replacing (#658)

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

commitae3b3d746fa4539a6d276b903fb34854755eb12d authorCarlos Alexandro Becker <caarlos0@users.noreply.github.com> dateFri 8 Aug 2025, 16:18 (1 year ago) parent42a346c
1 file changed+5−4
internal/llm/agent/mcp-tools.go+5−4
internal/llm/agent/mcp-tools.go+5−4
@@ -6,6 +6,7 @@ import (
66 "fmt"
77 "log/slog"
88 "slices"
9+ "strings"
910 "sync"
1011 "time"
1112
@@ -122,16 +123,16 @@ func runTool(ctx context.Context, name, toolName string, input string) (tools.To
122123 return tools.NewTextErrorResponse(err.Error()), nil
123124 }
124125
125− output := ""
126+ var output strings.Builder
126127 for _, v := range result.Content {
127128 if v, ok := v.(mcp.TextContent); ok {
128− output = v.Text
129+ output.WriteString(v.Text)
129130 } else {
130− output = fmt.Sprintf("%v", v)
131+ _, _ = fmt.Fprintf(&output, "%v: ", v)
131132 }
132133 }
133134
134− return tools.NewTextResponse(output), nil
135+ return tools.NewTextResponse(output.String()), nil
135136}
136137
137138func (b *McpTool) Run(ctx context.Context, params tools.ToolCall) (tools.ToolResponse, error) {