diff --git a/pkg/mcp/context.go b/pkg/mcp/context.go index 69d4678..e258bf3 100644 --- a/pkg/mcp/context.go +++ b/pkg/mcp/context.go @@ -27,7 +27,13 @@ func SetMcpContext(instance, cluster, organization string) { McpContextOrganization = &organization } +// GetMcpContext returns the currently configured StreamNative Cloud context. +// If the context has not been fully configured, it returns empty strings. func GetMcpContext() (string, string, string) { + if McpContextPulsarInstance == nil || McpContextPulsarCluster == nil || McpContextOrganization == nil { + return "", "", "" + } + return *McpContextPulsarInstance, *McpContextPulsarCluster, *McpContextOrganization } diff --git a/pkg/mcp/context_test.go b/pkg/mcp/context_test.go new file mode 100644 index 0000000..3bfeaef --- /dev/null +++ b/pkg/mcp/context_test.go @@ -0,0 +1,20 @@ +package mcp + +import "testing" + +func TestGetMcpContextUnset(t *testing.T) { + ResetMcpContext() + instance, cluster, org := GetMcpContext() + if instance != "" || cluster != "" || org != "" { + t.Fatalf("expected empty context when unset, got %q %q %q", instance, cluster, org) + } +} + +func TestGetMcpContextSet(t *testing.T) { + ResetMcpContext() + SetMcpContext("inst", "cluster", "org") + instance, cluster, org := GetMcpContext() + if instance != "inst" || cluster != "cluster" || org != "org" { + t.Fatalf("expected context to be returned, got %q %q %q", instance, cluster, org) + } +}