Skip to content

Commit c243d74

Browse files
committed
feat: add --disable-multi-cluster flag
Signed-off-by: Calum Murray <[email protected]>
1 parent e05e3ac commit c243d74

File tree

1 file changed

+15
-0
lines changed
  • pkg/kubernetes-mcp-server/cmd

1 file changed

+15
-0
lines changed

pkg/kubernetes-mcp-server/cmd/root.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ kubernetes-mcp-server --port 8080
4747
4848
# start a SSE server on port 8443 with a public HTTPS host of example.com
4949
kubernetes-mcp-server --port 8443 --sse-base-url https://example.com:8443
50+
51+
# start a SSE server on port 8080 with multi-cluster tools disabled
52+
kubernetes-mcp-server --port 8080 --disable-multi-cluster
5053
`))
5154
)
5255

@@ -68,6 +71,7 @@ type MCPServerOptions struct {
6871
AuthorizationURL string
6972
CertificateAuthority string
7073
ServerURL string
74+
DisableMultiCluster bool
7175

7276
ConfigPath string
7377
StaticConfig *config.StaticConfig
@@ -130,6 +134,7 @@ func NewMCPServer(streams genericiooptions.IOStreams) *cobra.Command {
130134
_ = cmd.Flags().MarkHidden("server-url")
131135
cmd.Flags().StringVar(&o.CertificateAuthority, "certificate-authority", o.CertificateAuthority, "Certificate authority path to verify certificates. Optional. Only valid if require-oauth is enabled.")
132136
_ = cmd.Flags().MarkHidden("certificate-authority")
137+
cmd.Flags().BoolVar(&o.DisableMultiCluster, "disable-multi-cluster", o.DisableMultiCluster, "Disable multi cluster tools. Optional. If true, all tools will be run against the default cluster/context.")
133138

134139
return cmd
135140
}
@@ -202,6 +207,9 @@ func (m *MCPServerOptions) loadFlags(cmd *cobra.Command) {
202207
if cmd.Flag("certificate-authority").Changed {
203208
m.StaticConfig.CertificateAuthority = m.CertificateAuthority
204209
}
210+
if cmd.Flag("disable-multi-cluster").Changed && m.DisableMultiCluster {
211+
m.StaticConfig.ClusterProviderStrategy = config.ClusterProviderDisabled
212+
}
205213
}
206214

207215
func (m *MCPServerOptions) initializeLogging() {
@@ -258,6 +266,13 @@ func (m *MCPServerOptions) Run() error {
258266
klog.V(1).Infof(" - Read-only mode: %t", m.StaticConfig.ReadOnly)
259267
klog.V(1).Infof(" - Disable destructive tools: %t", m.StaticConfig.DisableDestructive)
260268

269+
strategy := m.StaticConfig.ClusterProviderStrategy
270+
if strategy == "" {
271+
strategy = "auto-detect (it is advisable to set this explicitly in your Config)"
272+
}
273+
274+
klog.V(1).Infof(" - ClusterProviderStrategy: %s", strategy)
275+
261276
if m.Version {
262277
_, _ = fmt.Fprintf(m.Out, "%s\n", version.Version)
263278
return nil

0 commit comments

Comments
 (0)