Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 38 additions & 16 deletions internal/mcp/tools/list_pipelines.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,27 @@ If NONE match, tell the user. Do NOT try all pipelines.`,
}, nil, nil
}

pipelines := []k8sclient.PipelineInfo{}
if k8sClient != nil {
var err error
pipelines, err = k8sClient.ListPipelines(ctx)
if err != nil {
log.Error("failed to list pipelines from kubernetes", "error", err)
return &mcp.CallToolResult{
Content: []mcp.Content{&mcp.TextContent{
Text: fmt.Sprintf("Error listing pipelines: %v", err),
}},
IsError: true,
}, nil, nil
}
log.Info("listed pipelines from kubernetes", "count", len(pipelines))
} else {
log.Warn("kubernetes client is nil, skipping pipeline listing")
if k8sClient == nil {
log.Error("kubernetes client is not initialized")
return &mcp.CallToolResult{
Content: []mcp.Content{&mcp.TextContent{
Text: "Error: unable to connect to the cluster. Please contact your administrator.",
}},
IsError: true,
}, nil, nil
}

pipelines, err := k8sClient.ListPipelines(ctx)
if err != nil {
log.Error("failed to list pipelines from kubernetes", "error", err)
return &mcp.CallToolResult{
Content: []mcp.Content{&mcp.TextContent{
Text: fmt.Sprintf("Error listing pipelines: %v", err),
}},
IsError: true,
}, nil, nil
}
log.Info("listed pipelines from kubernetes", "count", len(pipelines))

databases, err := snowflake.ShowDatabases(ctx, oauthToken)
if err != nil {
Expand All @@ -102,6 +106,24 @@ If NONE match, tell the user. Do NOT try all pipelines.`,
}
}

if len(accessible) == 0 {
if len(pipelines) == 0 {
log.Info("no pipelines found in cluster")
return &mcp.CallToolResult{
Content: []mcp.Content{&mcp.TextContent{
Text: "No pipelines are configured in this cluster.",
}},
}, nil, nil
}
log.Info("no accessible pipelines found", "total_pipelines", len(pipelines))
return &mcp.CallToolResult{
Content: []mcp.Content{&mcp.TextContent{
Text: fmt.Sprintf("Found %d pipeline(s) but you do not have access to any of them. Please verify your access permissions.", len(pipelines)),
}},
IsError: true,
}, nil, nil
}

jsonBytes, err := json.Marshal(accessible)
if err != nil {
log.Error("failed to marshal result", "error", err)
Expand Down
Loading