Skip to content

Commit ae3b3d7

Browse files
authored
fix(mcp): append to output instead of replacing (#658)
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
1 parent 42a346c commit ae3b3d7

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

internal/llm/agent/mcp-tools.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

137138
func (b *McpTool) Run(ctx context.Context, params tools.ToolCall) (tools.ToolResponse, error) {

0 commit comments

Comments
 (0)