From 0135d5eb3f44e9fd7125eb690e7455271b47c55f Mon Sep 17 00:00:00 2001 From: umz Date: Fri, 14 Aug 2026 13:01:55 +0530 Subject: [PATCH 1/4] fix: return error when no accessible pipelines found in list tool The list_unstructured_data_pipelines_for_user MCP tool returned an empty array as a success response when no pipelines were accessible, causing the AI agent to silently report no results instead of flagging an error. Now returns IsError:true with a clear message so the client knows to check access permissions. --- internal/mcp/tools/list_pipelines.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/internal/mcp/tools/list_pipelines.go b/internal/mcp/tools/list_pipelines.go index fc46653b..f679dc70 100644 --- a/internal/mcp/tools/list_pipelines.go +++ b/internal/mcp/tools/list_pipelines.go @@ -102,6 +102,16 @@ If NONE match, tell the user. Do NOT try all pipelines.`, } } + if len(accessible) == 0 { + log.Info("no accessible pipelines found", "total_pipelines", len(pipelines)) + return &mcp.CallToolResult{ + Content: []mcp.Content{&mcp.TextContent{ + Text: "Error: no pipelines found that you have access to. Please verify your access permissions or check that pipelines are configured correctly.", + }}, + IsError: true, + }, nil, nil + } + jsonBytes, err := json.Marshal(accessible) if err != nil { log.Error("failed to marshal result", "error", err) From 214cd7d133049aa5b1e1b2c79a275f6b1336f9d4 Mon Sep 17 00:00:00 2001 From: umz Date: Fri, 14 Aug 2026 13:24:16 +0530 Subject: [PATCH 2/4] fix: return dedicated error when kubernetes client is nil --- internal/mcp/tools/list_pipelines.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/mcp/tools/list_pipelines.go b/internal/mcp/tools/list_pipelines.go index f679dc70..acc1327d 100644 --- a/internal/mcp/tools/list_pipelines.go +++ b/internal/mcp/tools/list_pipelines.go @@ -74,7 +74,13 @@ If NONE match, tell the user. Do NOT try all pipelines.`, } log.Info("listed pipelines from kubernetes", "count", len(pipelines)) } else { - log.Warn("kubernetes client is nil, skipping pipeline listing") + 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 } databases, err := snowflake.ShowDatabases(ctx, oauthToken) From d1244964e481bad3f5d81340c95621f3435d4c0a Mon Sep 17 00:00:00 2001 From: Umme Ayman Z Date: Mon, 17 Aug 2026 14:16:03 +0530 Subject: [PATCH 3/4] Update internal/mcp/tools/list_pipelines.go Accepted suggestion: split empty check to distinguish "no pipelines configured" vs "pipelines exist but no access" Co-authored-by: Puneet Punamiya --- internal/mcp/tools/list_pipelines.go | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/internal/mcp/tools/list_pipelines.go b/internal/mcp/tools/list_pipelines.go index acc1327d..f5d672f8 100644 --- a/internal/mcp/tools/list_pipelines.go +++ b/internal/mcp/tools/list_pipelines.go @@ -108,15 +108,24 @@ If NONE match, tell the user. Do NOT try all pipelines.`, } } - if len(accessible) == 0 { - log.Info("no accessible pipelines found", "total_pipelines", len(pipelines)) - return &mcp.CallToolResult{ - Content: []mcp.Content{&mcp.TextContent{ - Text: "Error: no pipelines found that you have access to. Please verify your access permissions or check that pipelines are configured correctly.", - }}, - IsError: true, - }, nil, nil - } + 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 { From 35f61cfef487199db239c49146ad9b758716248c Mon Sep 17 00:00:00 2001 From: umz Date: Fri, 21 Aug 2026 12:15:39 +0530 Subject: [PATCH 4/4] fix: resolve lint errors (ineffassign, early-return) --- internal/mcp/tools/list_pipelines.go | 63 +++++++++++++--------------- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/internal/mcp/tools/list_pipelines.go b/internal/mcp/tools/list_pipelines.go index f5d672f8..c69ecfcc 100644 --- a/internal/mcp/tools/list_pipelines.go +++ b/internal/mcp/tools/list_pipelines.go @@ -59,21 +59,7 @@ 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 { + if k8sClient == nil { log.Error("kubernetes client is not initialized") return &mcp.CallToolResult{ Content: []mcp.Content{&mcp.TextContent{ @@ -83,6 +69,18 @@ If NONE match, tell the user. Do NOT try all pipelines.`, }, 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 { log.Error("failed to list databases from snowflake", "error", err) @@ -108,24 +106,23 @@ 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 - } - + 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 {