Fix extraneous blank lines in mcp logs output

Skip empty lines from the scanner that result from double newlines
(application slog trailing newline + container runtime newline).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-28 18:22:38 -07:00
parent 14b978861f
commit 4c847e6de9

View File

@@ -63,8 +63,12 @@ func (a *Agent) Logs(req *mcpv1.LogsRequest, stream mcpv1.McpAgentService_LogsSe
scanner := bufio.NewScanner(pr) scanner := bufio.NewScanner(pr)
for scanner.Scan() { for scanner.Scan() {
line := scanner.Bytes()
if len(line) == 0 {
continue
}
if err := stream.Send(&mcpv1.LogsResponse{ if err := stream.Send(&mcpv1.LogsResponse{
Data: append(scanner.Bytes(), '\n'), Data: append(line, '\n'),
}); err != nil { }); err != nil {
_ = cmd.Process.Kill() _ = cmd.Process.Kill()
return err return err