platformmode

package
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package platformmode is the single source of truth for the MCP Runtime platform-mode selector (tenant/org/public) and the catalog namespace rules derived from it. The CLI, the API service, and the UI service all consume these helpers so they agree on environment-variable precedence and on which namespaces are considered the active shared catalog.

Index

Constants

View Source
const (
	// DefaultOrgCatalogNamespace is the default namespace for ModeOrg.
	DefaultOrgCatalogNamespace = "mcp-servers-org"
	// DefaultPublicCatalogNamespace is the default namespace for ModePublic.
	DefaultPublicCatalogNamespace = "mcp-servers-public"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Mode

type Mode string

Mode is the canonical lower-case representation of a platform mode.

const (
	// ModeTenant scopes signed-in users to their own user/team namespaces.
	// No shared catalog is exposed; anonymous browsing is disabled.
	ModeTenant Mode = "tenant"
	// ModeOrg exposes a shared organization catalog that signed-in users may
	// publish into. Tenant namespaces remain reachable to their owners.
	ModeOrg Mode = "org"
	// ModePublic exposes a public catalog readable by anonymous clients and
	// writable by signed-in users. Tenant namespaces remain reachable to
	// their owners.
	ModePublic Mode = "public"
)

func FromEnv

func FromEnv() Mode

FromEnv reads the current platform mode from PLATFORM_MODE, falling back to MCP_PLATFORM_MODE. Unknown values resolve to ModeTenant.

func Normalize

func Normalize(raw string) (Mode, bool)

Normalize returns the canonical mode for raw. The second return value is true when raw was empty or matched a known mode; unknown values fall back to ModeTenant and return false.

func (Mode) CatalogNamespaces

func (m Mode) CatalogNamespaces() []string

CatalogNamespaces returns the ordered list of catalog namespaces for the active mode. The first element is the namespace returned by DefaultCatalogNamespace; additional entries come from PLATFORM_CATALOG_NAMESPACES (with PLATFORM_PUBLIC_NAMESPACES as a public-mode-only fallback).

Extra-namespace precedence is the same in every caller — the CLI, API, and UI all share this logic to avoid drift.

func (Mode) DefaultCatalogNamespace

func (m Mode) DefaultCatalogNamespace() string

DefaultCatalogNamespace returns the primary catalog namespace for the active mode. ModeTenant returns "" because there is no shared catalog.

Override precedence (first non-empty wins):

  1. PLATFORM_CATALOG_NAMESPACE
  2. MCP_PLATFORM_CATALOG_NAMESPACE
  3. mode-specific override (PLATFORM_ORG_NAMESPACE / PLATFORM_PUBLIC_NAMESPACE)
  4. built-in default (DefaultOrgCatalogNamespace / DefaultPublicCatalogNamespace)

func (Mode) IsCatalogNamespace

func (m Mode) IsCatalogNamespace(namespace string) bool

IsCatalogNamespace reports whether namespace is one of the active mode's catalog namespaces.

func (Mode) PublicCatalogEnabled

func (m Mode) PublicCatalogEnabled() bool

PublicCatalogEnabled reports whether anonymous clients may browse the catalog (true only for ModePublic).

func (Mode) SharedCatalogWritable

func (m Mode) SharedCatalogWritable() bool

SharedCatalogWritable reports whether signed-in users may publish into the active catalog namespace (true for ModeOrg and ModePublic).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL