Skip to content

Commit 9775565

Browse files
authored
Merge pull request #1426 from Pnkcaht/fix/mcp-init-eof-warning
fix(mcp): ignore EOF during MCP initialization
2 parents 8f53b06 + ae94212 commit 9775565

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pkg/tools/mcp/mcp.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"encoding/json"
77
"errors"
88
"fmt"
9+
"io"
910
"iter"
1011
"log/slog"
1112
"strings"
@@ -116,6 +117,17 @@ func (ts *Toolset) doStart(ctx context.Context) error {
116117
//
117118
// Only retry when initialization fails due to sending the initialized notification.
118119
if !isInitNotificationSendError(err) {
120+
121+
// EOF means the MCP server is unavailable or closed the connection.
122+
// This is not a fatal error and should not fail the agent execution.
123+
if errors.Is(err, io.EOF) {
124+
slog.Debug(
125+
"MCP client unavailable (EOF), skipping MCP toolset",
126+
"server", ts.logID,
127+
)
128+
return nil
129+
}
130+
119131
slog.Error("Failed to initialize MCP client", "error", err)
120132
return fmt.Errorf("failed to initialize MCP client: %w", err)
121133
}

0 commit comments

Comments
 (0)