Skip to content

Commit 0b718b7

Browse files
committed
fix: allow logs through if server is running but not healthy
1 parent 1f69607 commit 0b718b7

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

pkg/mcp/details.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package mcp
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"io"
78

@@ -24,6 +25,18 @@ func (sm *SessionManager) GetServerDetails(ctx context.Context, userID, mcpServe
2425
return sm.backend.getServerDetails(ctx, serverConfig.Scope)
2526
}
2627

28+
// shouldAttemptLogStreaming checks if the error is one that should still have logs
29+
// These are errors where the server might be running but not healthy
30+
func shouldAttemptLogStreaming(err error) bool {
31+
for unwrappedErr := err; unwrappedErr != nil; unwrappedErr = errors.Unwrap(unwrappedErr) {
32+
switch unwrappedErr {
33+
case ErrHealthCheckFailed, ErrHealthCheckTimeout, ErrPodConfigurationFailed:
34+
return true
35+
}
36+
}
37+
return false
38+
}
39+
2740
// StreamServerLogs will stream the logs of a specific MCP server based on its configuration, if the backend supports it.
2841
// If the server is remote, it will return an error as remote servers do not support this operation.
2942
// If the backend does not support the operation, it will return an [ErrNotSupportedByBackend] error.
@@ -34,7 +47,10 @@ func (sm *SessionManager) StreamServerLogs(ctx context.Context, userID, mcpServe
3447

3548
_, err := sm.ensureDeployment(ctx, serverConfig, userID, mcpServerDisplayName, mcpServerName)
3649
if err != nil {
37-
return nil, err
50+
// If error of deployment is not one that should still have logs, return the error
51+
if !shouldAttemptLogStreaming(err) {
52+
return nil, err
53+
}
3854
}
3955

4056
return sm.backend.streamServerLogs(ctx, serverConfig.Scope)

0 commit comments

Comments
 (0)