Skip to content

Commit bc695e9

Browse files
Mukuwuldapr-bot
andauthored
mcpservers: skip cert-expiry check in self-hosted mode, validate --output (#1676)
dapr mcpservers ran kubernetes.CheckForCertExpiry unconditionally in PostRun, so a purely local resources-directory listing reached for kubeconfig and cluster access; guard it behind kubernetesMode like dapr list does. Also validate --output in PreRun, matching dapr list, instead of silently accepting unknown values. Fixes #1675 Signed-off-by: Mukul <nmukul32@gmail.com> Co-authored-by: Dapr Bot <56698301+dapr-bot@users.noreply.github.com>
1 parent 8ec5213 commit bc695e9

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

cmd/mcpservers.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ var (
3535
var MCPServersCmd = &cobra.Command{
3636
Use: "mcpservers",
3737
Short: "List all Dapr MCPServer resources. Supported platforms: Kubernetes and self-hosted",
38+
PreRun: func(cmd *cobra.Command, args []string) {
39+
if mcpServersOutputFormat != "list" && mcpServersOutputFormat != "json" && mcpServersOutputFormat != "yaml" {
40+
print.FailureStatusEvent(os.Stderr, "An invalid output format was specified. Valid values are: json, yaml, or list")
41+
os.Exit(1)
42+
}
43+
},
3844
Run: func(cmd *cobra.Command, args []string) {
3945
if kubernetesMode {
4046
if allNamespaces || resourceNamespace == "" {
@@ -59,7 +65,9 @@ var MCPServersCmd = &cobra.Command{
5965
}
6066
},
6167
PostRun: func(cmd *cobra.Command, args []string) {
62-
kubernetes.CheckForCertExpiry()
68+
if kubernetesMode {
69+
kubernetes.CheckForCertExpiry()
70+
}
6371
},
6472
Example: `
6573
# List all Dapr MCPServer resources in self-hosted mode (reads from ~/.dapr/components/ by default)

0 commit comments

Comments
 (0)