Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: mcpservers.clerum.io
annotations:
clerum.io/secret-reference-contract: |-
{
"version": 1,
"plural": "mcpservers",
"fields": [
{
"path": "spec.auth.secretRef",
"namespaceBinding": "resource"
},
{
"path": "spec.envSecret",
"namespaceBinding": "resource"
},
{
"path": "spec.imagePullSecrets",
"namespaceBinding": "resource"
},
{
"path": "spec.oauth.clientIdRef",
"namespaceBinding": "resource"
},
{
"path": "spec.oauth.clientSecretRef",
"namespaceBinding": "resource"
}
]
}
labels:
app.kubernetes.io/name: mcpserver
app.kubernetes.io/part-of: clerum
spec:
group: clerum.io
names:
kind: McpServer
listKind: McpServerList
plural: mcpservers
singular: mcpserver
shortNames:
- mcp
scope: Namespaced
versions:
- name: v1alpha1
served: true
storage: true
schema:
openAPIV3Schema:
type: object
description: >-
McpServer defines an MCP (Model Context Protocol) server that provides
tools to the LLM. The context-mapper watches these CRDs and automatically
manages deployments, services, and secret validation.
properties:
spec:
type: object
required:
- contextRef
- transport
- image
properties:
contextRef:
type: string
description: Reference to the context this server belongs to.
description:
type: string
description: Human-readable description of what this MCP server does.
image:
type: string
description: Docker image for the MCP server container (e.g. mongodb/mongodb-mcp-server:latest).
imagePullPolicy:
type: string
enum:
- Always
- IfNotPresent
- Never
description: Image pull policy. If omitted, HCC uses CONTEXT_MAPPER_MCPSERVER_IMAGE_PULL_POLICY (default IfNotPresent).
command:
type: array
items:
type: string
description: >-
Override the container entrypoint (Docker ENTRYPOINT).
Use when the image default entrypoint does not start the
server in the desired mode.
args:
type: array
items:
type: string
description: >-
Arguments passed to the container entrypoint (Docker CMD).
transport:
type: object
description: Transport configuration for connecting to the MCP server.
properties:
type:
type: string
enum:
- sse
- streamableHttp
- stdio
description: >-
Transport type. sse for Server-Sent Events, streamableHttp for HTTP streaming,
stdio for stdin/stdout (requires stdio-bridge sidecar).
url:
type: string
description: >-
Client-facing URL endpoint of the MCP server.
Required for sse and streamableHttp transports.
Auto-generated for stdio transport (stdio-bridge sidecar provides the HTTP endpoint).
port:
type: integer
default: 3000
description: Port the MCP server listens on (used for container port and Service).
required:
- type
auth:
type: object
description: Authentication configuration for the mcp-host connecting to this server.
properties:
type:
type: string
enum:
- none
- bearer
- basic
- apiKey
- oauth
description: >-
Authentication type. `oauth` selects the control-api OAuth
broker (per-user or shared identity); it requires spec.oauth
and forbids a static secretRef/secretKey.
secretRef:
type: string
description: Name of the Kubernetes Secret containing auth credentials.
secretKey:
type: string
description: Key within the secret to use (default depends on auth type).
oauth:
type: object
description: >-
OAuth 2.1 broker configuration for this mcp-server. Present iff
spec.auth.type == 'oauth'. The control-api OAuth subsystem owns
the authorize/token/refresh flow; tokens are resolved per
connection just-in-time and NEVER mounted into the pod. Shape
mirrors WorkflowRecipe spec.oauthClients[] (a single client per
server).
properties:
id:
type: string
maxLength: 512
description: >-
Stable OAuth client identifier for this server. Surfaced as
the `clientId` on clerum:oauth URLs and the callback path
segment. Immutable once set. Baked carril (source absent) is
re-narrowed to ^[a-z0-9-]{1,63}$ by CEL; remote carril carries
an AS-assigned client_id (arbitrary charset).
provider:
type: string
# Known-shape adapters baked into control-api
# (src/oauth/providers.ts). Adding a provider is a control-api
# change — servers cannot speak OAuth to arbitrary endpoints.
# U2 adds: monday, clickup, vercel (monday + vercel use PKCE).
enum:
- salesforce
- slack
- notion
- microsoft-graph
- google
- monday
- clickup
- vercel
description: >-
Known-shape adapter. control-api owns the authorize/token
URLs and response-shape parsing per provider. Immutable.
clientIdRef:
type: object
required: [name, key]
description: >-
Reference to a Secret in the mcp-servers namespace holding
the OAuth client_id.
properties:
name:
type: string
maxLength: 253
key:
type: string
maxLength: 253
clientSecretRef:
type: object
required: [name, key]
description: >-
Reference to a Secret in the mcp-servers namespace holding
the OAuth client_secret.
properties:
name:
type: string
maxLength: 253
key:
type: string
maxLength: 253
scopes:
type: array
maxItems: 128
items:
type: string
maxLength: 512
description: >-
OAuth scopes to request. Provider-specific syntax. Include
the provider's offline/refresh scope when backgroundAccess
is true.
backgroundAccess:
type: boolean
description: >-
When true, this grant may be used by a workload without a
live human session (subject to the control-api background
gate). Requires scopes to include the provider's
offline/refresh scope.
grantScope:
type: string
enum:
- user
- context
default: user
description: >-
Whose OAuth identity is exercised. `user` (default): each
user authorizes their own grant, keyed by (server, user).
`context`: one shared identity per Context — a member
bootstraps it and the rest inherit it, keyed by
(server, context). Immutable once set: flipping it would
change in place which identity is exercised.
source:
type: string
enum: [remote, generic]
description: >-
Carril discriminator. ABSENT = baked (a known-shape adapter
via spec.oauth.provider). 'remote' = a discovery-configured
client (control-api remote-MCP install) whose pinned endpoints
below replace the baked provider. 'generic' = self-hosted
knob-configured client (operator-pinned endpoints + wire knobs;
client_id IS spec.oauth.id unless clientIdRef is set). Immutable;
the carril cannot flip.
clientMode:
type: string
enum: [public, confidential]
description: >-
REMOTE only. 'public' (CIMD/PKCE, no client secret) or
'confidential' (secret via clientIdRef/clientSecretRef, or the
encrypted dynamic_clients store for DCR). Immutable.
authorizationEndpoint:
type: string
maxLength: 2048
description: REMOTE and GENERIC. Pinned discovery authorize URL. Immutable.
tokenEndpoint:
type: string
maxLength: 2048
description: REMOTE and GENERIC. Pinned discovery token URL. Immutable.
registrationEndpoint:
type: string
maxLength: 2048
description: REMOTE only, optional. Pinned DCR registration URL. Immutable.
issuer:
type: string
maxLength: 2048
description: REMOTE only. Pinned AS issuer. Immutable.
resource:
type: string
maxLength: 2048
description: REMOTE and GENERIC. RFC 8707 resource sent on authorize+token. Immutable.
issForCallback:
type: string
maxLength: 2048
description: >-
REMOTE only, optional. RFC 9207 iss to validate the callback
against (present only when advertised). Immutable.
bearerInBody:
type: boolean
description: >-
REMOTE only (D-8). Whether the AS wants the token in the request
body instead of the Authorization header. Must be false: the
runtime only sends the header (enforced by CEL). No default
(required-by-CEL for remote). Immutable (pinned at install).
supportsRefresh:
type: boolean
description: >-
REMOTE and GENERIC (D-8), fail-closed. false ⇒ never attempt refresh.
No default (required-by-CEL for remote). Immutable (pinned at
install; runtime never re-derives).
asProfile:
type: string
maxLength: 32
enum: [entra-v2]
description: >-
REMOTE only, optional. Closed authorization-server profile recognised at
install from the pinned issuer. entra-v2 (Microsoft Entra ID v2, tenant
authority): RFC 8707 resource is not sent, offline_access is always
requested and the scopes are sent on refresh. Requires a Microsoft Entra
tenant issuer. Immutable.
tokenRequestFormat:
type: string
enum: [form, json]
description: "GENERIC only. Token/refresh POST body encoding."
tokenAuthMethod:
type: string
enum: [body, basic]
description: "GENERIC only. client_secret placement: form body vs HTTP Basic."
scopeSeparator:
type: string
enum: [space, comma]
description: "GENERIC only. Separator joining scopes on the authorize URL."
sendScope:
type: boolean
description: "GENERIC only. Whether to emit the scope parameter at all."
usePkce:
type: boolean
description: "GENERIC only. PKCE S256 on authorize + code_verifier on exchange."
includeResponseType:
type: boolean
description: "GENERIC only. Emit response_type=code on the authorize URL."
refreshEndpoint:
type: string
maxLength: 2048
description: "GENERIC only, optional. Defaults to tokenEndpoint when absent. Immutable."
extraAuthorizeParams:
type: object
maxProperties: 16
additionalProperties:
type: string
maxLength: 1024
description: "GENERIC only, optional. Static extra query params appended to the authorize URL. Immutable."
serverConfig:
type: object
description: Operational configuration for the MCP server runtime.
properties:
readOnly:
type: boolean
default: true
description: Whether the MCP server operates in read-only mode.
loggers:
type: string
default: "stderr"
description: Comma-separated list of logger outputs (e.g. stderr, disk, mcp).
telemetry:
type: string
enum:
- enabled
- disabled
default: "disabled"
description: Whether telemetry collection is enabled.
envMapping:
type: object
description: >-
Maps CRD fields to environment variable names specific to
this MCP server image. The context-mapper reads the structured
CRD fields and sets the named env vars automatically.
properties:
transport:
type: string
description: 'Env var for transport mode (value derived: sse/streamableHttp → "http").'
httpHost:
type: string
description: 'Env var for HTTP bind host (value: always "0.0.0.0").'
httpPort:
type: string
description: Env var for HTTP port (value from spec.transport.port).
healthCheckHost:
type: string
description: 'Env var for health check bind host (value: always "0.0.0.0").'
healthCheckPort:
type: string
description: Env var for health check port (value from spec.healthCheck.port).
readOnly:
type: string
description: Env var for read-only mode (value from spec.serverConfig.readOnly).
loggers:
type: string
description: Env var for loggers (value from spec.serverConfig.loggers).
telemetry:
type: string
description: Env var for telemetry (value from spec.serverConfig.telemetry).
env:
type: array
description: >-
Additional environment variables for the MCP server container.
Use this for server-specific settings not covered by
serverConfig + envMapping.
items:
type: object
required:
- name
- value
properties:
name:
type: string
description: Environment variable name.
value:
type: string
description: Environment variable value.
envSecret:
type: object
description: >-
Secret-backed environment variables. The context-mapper validates
that the secret and all referenced keys exist before creating
the deployment. The secret itself must be created separately.
required:
- name
- keys
properties:
name:
type: string
description: Name of the Kubernetes Secret in the same namespace.
keys:
type: array
description: Mapping of secret keys to environment variable names.
items:
type: object
required:
- secretKey
- envVar
properties:
secretKey:
type: string
description: Key within the Kubernetes Secret.
envVar:
type: string
description: Environment variable name to expose the secret value as.
healthCheck:
type: object
description: Health check endpoint configuration for Kubernetes probes.
properties:
port:
type: integer
default: 3001
description: Port for the health check endpoint (separate from the main transport port).
resources:
type: object
description: Resource requests and limits for the MCP server container.
properties:
requests:
type: object
properties:
memory:
type: string
cpu:
type: string
limits:
type: object
properties:
memory:
type: string
cpu:
type: string
enabled:
type: boolean
default: true
description: Whether this MCP server is enabled. Disabled servers will have their deployments removed.
managed:
type: boolean
default: true
description: >-
Runtime ownership for this MCP server. When true (default),
host-context-controller owns the runtime and creates/manages
Deployment, Service, NetworkPolicy, and remote proxy resources.
When false, workflow-recipes owns the runtime; HCC only exposes
discovery/status and must not create or delete the WRC-owned
runtime.
remote:
type: object
description: >-
Remote MCP server configuration. When present, the Context Mapper
creates an nginx-based egress proxy Pod instead of deploying the
vendor image directly. The proxy forwards requests to the external
baseUrl, injecting auth headers from envSecret.
properties:
baseUrl:
type: string
pattern: "^https://[a-zA-Z0-9._-]+(:[0-9]+)?(/[^\\n\\r; ]*)?$"
description: >-
External MCP server endpoint URL (must be HTTPS, e.g. https://mcp.sentry.io/sse).
The egress proxy will forward all requests to this URL.
authHeaders:
type: array
maxItems: 20
description: |
Optional HTTP headers to inject when proxying to the remote MCP server.
Rendered by host-context-controller into nginx proxy_set_header directives.
Values are envsubst-expanded at pod start from Secret-mounted env vars.
items:
type: object
required:
- header
- valueTemplate
properties:
header:
type: string
minLength: 1
maxLength: 128
pattern: '^[A-Za-z0-9-]+$'
description: "HTTP header name. Alphanumeric and hyphens only."
valueTemplate:
type: string
minLength: 1
maxLength: 2048
description: |
Header value template. May contain ${VAR} placeholders that
nginx envsubst resolves at startup from mounted env vars.
required:
- baseUrl
x-kubernetes-validations:
- rule: "self.baseUrl.startsWith('https://')"
message: "remote.baseUrl must use HTTPS"
- rule: "!self.baseUrl.contains('svc.cluster.local')"
message: "remote.baseUrl must not reference internal cluster services"
imagePullSecrets:
type: array
description: Image pull secrets for the container.
items:
type: object
properties:
name:
type: string
security:
type: object
description: Security context overrides for the MCP server pod.
properties:
runAsUser:
type: integer
minimum: 1
runAsGroup:
type: integer
fsGroup:
type: integer
addCapabilities:
type: array
items:
type: string
enum:
- CHOWN
- FOWNER
- DAC_OVERRIDE
- NET_BIND_SERVICE
egressBindings:
type: array
maxItems: 20
description: >-
External egress bindings allowing this MCP server to reach external
APIs. exact-host bindings generate NetworkPolicies to resolved public
IPs or explicit public CIDRs. public-web is an explicit opt-in that
allows public TCP 80/443 while blocking private, metadata, link-local,
service, documentation, multicast, and reserved IPv4 ranges.
items:
type: object
properties:
egressClass:
type: string
enum:
- exact-host
- public-web
default: exact-host
description: >-
exact-host allows a single dns or cidr destination plus port.
public-web allows public TCP 80/443 and must not declare dns,
cidr, port, or protocol.
dns:
type: string
minLength: 1
maxLength: 128
pattern: "^[a-z0-9][a-z0-9.-]*\\.[a-z0-9][a-z0-9.-]*[a-z0-9]$"
description: DNS hostname to resolve (e.g. api.openai.com). Mutually exclusive with cidr.
cidr:
type: string
minLength: 3
maxLength: 43
description: Public IPv4 CIDR range (for example 203.0.114.10/32). Mutually exclusive with dns. Must not overlap private, metadata, link-local, documentation, multicast, or reserved IPv4 ranges.
port:
type: integer
description: Destination port number.
protocol:
type: string
enum:
- TCP
- UDP
description: Network protocol.
x-kubernetes-validations:
- rule: "((has(self.egressClass) && self.egressClass == 'public-web') && !has(self.dns) && !has(self.cidr) && !has(self.port) && !has(self.protocol)) || ((!has(self.egressClass) || self.egressClass == 'exact-host') && has(self.port) && has(self.dns) != has(self.cidr))"
message: "exact-host requires port and exactly one of dns or cidr; public-web must not declare dns, cidr, port, or protocol"
- rule: "!has(self.dns) || !self.dns.contains('/')"
message: "dns must not use CIDR notation"
- rule: "!has(self.dns) || !self.dns.contains(':')"
message: "dns must not include a port or URL scheme"
- rule: "!has(self.dns) || (self.dns != '*' && !self.dns.startsWith('*.'))"
message: "wildcard dns values are not allowed"
- rule: "!has(self.dns) || (self.dns != 'localhost' && self.dns != 'metadata.goog' && self.dns != 'kubernetes.default' && !self.dns.endsWith('.localhost') && !self.dns.endsWith('.local') && !self.dns.endsWith('.internal') && !self.dns.endsWith('.svc') && !self.dns.endsWith('.cluster.local'))"
message: "dns must not target localhost, metadata, Kubernetes, service, or internal hostnames"
- rule: "!has(self.cidr) || isCIDR(self.cidr)"
message: "cidr must be valid CIDR notation"
- rule: "!has(self.cidr) || !isCIDR(self.cidr) || cidr(self.cidr) == cidr(self.cidr).masked()"
message: "cidr must use canonical network CIDR notation"
- rule: "!has(self.cidr) || !self.cidr.contains(':')"
message: "IPv6 CIDR ranges are not supported for external egress"
- rule: "!has(self.cidr) || !isCIDR(self.cidr) || !['0.0.0.0/8','10.0.0.0/8','100.64.0.0/10','127.0.0.0/8','169.254.0.0/16','172.16.0.0/12','192.0.0.0/24','192.0.2.0/24','192.31.196.0/24','192.52.193.0/24','192.88.99.0/24','192.168.0.0/16','192.175.48.0/24','198.18.0.0/15','198.51.100.0/24','203.0.113.0/24','224.0.0.0/4','240.0.0.0/4'].exists(blocked, cidr(self.cidr).containsCIDR(cidr(blocked)) || cidr(blocked).containsCIDR(cidr(self.cidr)))"
message: "CIDR must not overlap private, metadata, link-local, documentation, multicast, or reserved IPv4 ranges"
x-kubernetes-validations:
- rule: "self.managed == oldSelf.managed"
message: "spec.managed is immutable; delete and recreate the McpServer to change ownership"
- rule: "self.managed == true || (has(self.transport) && has(self.contextRef))"
message: "WRC-owned servers (managed: false) still require transport and contextRef"
- rule: "(has(self.managed) ? self.managed : true) == (has(oldSelf.managed) ? oldSelf.managed : true)"
message: "spec.managed is immutable; delete and recreate the McpServer to change runtime ownership"
- rule: "!has(self.remote) || (has(self.egressBindings) && size(self.egressBindings) > 0)"
message: "Remote servers must declare at least one egressBinding for egress NetworkPolicy"
# OAuth coupling: auth.type=='oauth' iff spec.oauth is present.
# grantScope ⇒ oauth is structural (grantScope nests under oauth).
- rule: "((has(self.auth) && has(self.auth.type) && self.auth.type == 'oauth') == has(self.oauth))"
message: "spec.auth.type 'oauth' requires spec.oauth, and spec.oauth requires auth.type 'oauth'"
# OAuth servers must not also carry a static credential.
- rule: "!has(self.oauth) || !has(self.auth) || (!has(self.auth.secretRef) && !has(self.auth.secretKey))"
message: "OAuth mcp-servers must not declare a static auth.secretRef/secretKey"
# Immutability via has()-guard (patrón `managed`): these are
# transition rules (they reference oldSelf), so they are SKIPPED on
# CREATE and only enforced on UPDATE. Guarding on has(oldSelf.oauth)
# means create-time grantScope:'context' is allowed, and a
# none→oauth UPDATE is allowed, while any change to a grantScope /
# id / provider that ALREADY existed is rejected.
- rule: "!has(oldSelf.oauth) || !has(self.oauth) || oldSelf.oauth.grantScope == self.oauth.grantScope"
message: "spec.oauth.grantScope is immutable; delete and recreate the McpServer to change which identity is exercised"
# id/provider value immutability (IMM-2/IMM-4) is has()-guarded on
# BOTH the coordinate presence and the oauth presence: a remote-carril
# UPDATE has no id/provider, so an unguarded dereference would
# CEL-ERROR. The presence of id (IMM-3) and of the carril (IMM-5) are
# pinned separately below, so guarding the value comparison is safe.
- rule: "!has(oldSelf.oauth) || !has(self.oauth) || !has(oldSelf.oauth.id) || !has(self.oauth.id) || oldSelf.oauth.id == self.oauth.id"
message: "spec.oauth.id is immutable"
- rule: "!has(oldSelf.oauth) || !has(self.oauth) || !has(oldSelf.oauth.provider) || !has(self.oauth.provider) || oldSelf.oauth.provider == self.oauth.provider"
message: "spec.oauth.provider is immutable"
# R1-L1: close the two-step immutability bypass. The rules above
# short-circuit on !has(self.oauth), so an UPDATE could (1) drop
# spec.oauth, then a second UPDATE (2) re-add it with a different
# grantScope/id/provider — oldSelf.oauth now absent, immutability
# skipped. Forbidding removal once set blocks step (1), so the
# coordinate is truly immutable. Removing OAuth from a server thus
# requires delete+recreate — consistent with the `managed` rule.
- rule: "!has(oldSelf.oauth) || has(self.oauth)"
message: "spec.oauth cannot be removed once set; delete and recreate the McpServer to change or remove the OAuth identity"
# M1 (@alfredolopez80, PR #317): spec.contextRef is the
# AUTHORITATIVE shared-identity coordinate for a
# grantScope:'context' oauth server — control-api keys the
# shared grant by server.spec.contextRef (mcpOauth.ts), NEVER
# the request body. Without this rule an actor with `update`
# RBAC on the McpServer CR could repoint contextRef ctxA→ctxB
# in place and redirect the shared token, defeating the
# grantScope/id/provider immutability above. oauth-GUARDED
# (!has(oldSelf.oauth) short-circuit) on purpose: contextRef is
# required on ALL servers (visibility/allowlisting too), and a
# WRC delegation reconcile legitimately re-writes it when an
# operator edits the owning WorkflowRecipe.spec.contextRef —
# global immutability would wedge that non-oauth flow. The
# shared-token threat is oauth-only, so we pin contextRef only
# once oauth exists. No two-step drop-oauth bypass: the rule
# above forbids removing oauth once set. contextRef is required
# → on UPDATE oldSelf/self.contextRef always exist. Transition
# rule (oldSelf) → skipped on CREATE.
- rule: "!has(oldSelf.oauth) || !has(self.oauth) || self.contextRef == oldSelf.contextRef"
message: "spec.contextRef is immutable; delete and recreate the McpServer to re-parent it to a different Context"
# C3 remote×oauth carril. spec.oauth.source discriminates the carril:
# ABSENT = baked (a known-shape provider adapter), 'remote' = a
# discovery-configured client with pinned endpoints. The block-level
# `required` is gone; requiredness is carril-specific and enforced
# here so each carril rejects the other's shape.
#
# Baked+generic slug re-narrow: the structural `pattern` moved to CEL so
# the remote carril can carry an AS-assigned client_id (arbitrary
# charset). Exempts ONLY remote (source == 'remote' short-circuits);
# baked (source absent) AND generic get the slug narrow, since a
# generic client_id IS spec.oauth.id and must be a callback-path-safe slug.
# 'remote' is reserved: baked/generic callbacks route by /oauth-callback/<id>,
# and /oauth-callback/remote is the shared redirect of remote clients whose
# AS advertises RFC 9207 (the others register /oauth-callback/remote/<name>[/<installId>]),
# so a baked/generic server with that id would share it.
- rule: "!has(self.oauth) || (has(self.oauth.source) && self.oauth.source == 'remote') || !has(self.oauth.id) || (self.oauth.id.matches('^[a-z0-9-]{1,63}$') && self.oauth.id != 'remote')"
message: "baked/generic spec.oauth.id must match ^[a-z0-9-]{1,63}$ and must not be 'remote' (reserved for the remote OAuth callback)"
# BAKED-REQ: baked (no source) requires the classic adapter quartet.
- rule: "!has(self.oauth) || has(self.oauth.source) || (has(self.oauth.id) && has(self.oauth.provider) && has(self.oauth.clientIdRef) && has(self.oauth.clientSecretRef))"
message: "baked spec.oauth (no source) requires id, provider, clientIdRef and clientSecretRef"
# REMOTE-REQ: remote requires the pinned discovery client shape.
# Re-gated on source == 'remote' (via source != 'remote' short-circuit)
# so the generic carril does not fall into the remote required set.
- rule: "!has(self.oauth) || !has(self.oauth.source) || self.oauth.source != 'remote' || (has(self.oauth.clientMode) && has(self.oauth.authorizationEndpoint) && has(self.oauth.tokenEndpoint) && has(self.oauth.issuer) && has(self.oauth.resource) && has(self.oauth.bearerInBody) && has(self.oauth.supportsRefresh))"
message: "remote spec.oauth requires clientMode, authorizationEndpoint, tokenEndpoint, issuer, resource, bearerInBody and supportsRefresh"
# REMOTE-FORBID-PROVIDER: source 'remote' replaces the baked adapter.
- rule: "!has(self.oauth) || !has(self.oauth.source) || !has(self.oauth.provider)"
message: "remote spec.oauth must not set provider; source 'remote' replaces the baked adapter"
# BAKED-FORBID-REMOTE-FIELDS: baked must not carry remote-only fields.
# The forbidden set is extended with the generic knobs + refreshEndpoint
# so baked (source absent) rejects both remote-only and generic-only shape.
- rule: "!has(self.oauth) || has(self.oauth.source) || (!has(self.oauth.clientMode) && !has(self.oauth.authorizationEndpoint) && !has(self.oauth.tokenEndpoint) && !has(self.oauth.registrationEndpoint) && !has(self.oauth.issuer) && !has(self.oauth.resource) && !has(self.oauth.issForCallback) && !has(self.oauth.bearerInBody) && !has(self.oauth.supportsRefresh) && !has(self.oauth.asProfile) && !has(self.oauth.tokenRequestFormat) && !has(self.oauth.tokenAuthMethod) && !has(self.oauth.scopeSeparator) && !has(self.oauth.sendScope) && !has(self.oauth.usePkce) && !has(self.oauth.includeResponseType) && !has(self.oauth.refreshEndpoint) && !has(self.oauth.extraAuthorizeParams))"
message: "baked spec.oauth (no source) must not set remote-only fields"
# IMM-3: id presence is immutable — closes the drop/re-add two-step
# that would otherwise let an UPDATE add or remove id under a
# value-only immutability guard.
- rule: "!has(oldSelf.oauth) || !has(self.oauth) || has(oldSelf.oauth.id) == has(self.oauth.id)"
message: "spec.oauth.id presence is immutable; delete and recreate to add or remove it"
# IMM-5: the carril (source presence) is immutable — baked cannot flip
# to remote or vice versa in place.
- rule: "!has(oldSelf.oauth) || !has(self.oauth) || has(oldSelf.oauth.source) == has(self.oauth.source)"
message: "spec.oauth carril (source) is immutable; delete and recreate to change it"
# IMM-6: remote pinned endpoints + clientMode + registration +
# issForCallback + the discovery-derived quirks (bearerInBody,
# supportsRefresh) are immutable. These are all pinned at install from
# AS metadata and the runtime never re-derives them (D-4/D-8), so an
# update-RBAC actor must not flip them in place — e.g. supportsRefresh
# false→true would re-enable refresh against the pinned token endpoint,
# defeating the D-8 fail-closed decision. Double-source-guarded so it
# only dereferences remote-only fields when BOTH revisions are remote;
# REMOTE-REQ then guarantees clientMode/endpoints/issuer/resource/
# bearerInBody/supportsRefresh are present, so those accesses cannot
# CEL-error. registrationEndpoint/issForCallback are optional even on
# remote → presence-pinned + guarded value-equality. asProfile is
# optional → presence-pinned + guarded value-equality, like issForCallback.
# Double-source-VALUE-guarded (source != 'remote' short-circuits on
# BOTH revisions) so the remote value-block only dereferences remote-only
# fields when BOTH revisions are remote; a generic→generic UPDATE
# short-circuits before touching clientMode/issuer/... and cannot CEL-ERROR.
- rule: "!has(oldSelf.oauth) || !has(self.oauth) || !has(oldSelf.oauth.source) || oldSelf.oauth.source != 'remote' || !has(self.oauth.source) || self.oauth.source != 'remote' || (oldSelf.oauth.clientMode == self.oauth.clientMode && oldSelf.oauth.authorizationEndpoint == self.oauth.authorizationEndpoint && oldSelf.oauth.tokenEndpoint == self.oauth.tokenEndpoint && oldSelf.oauth.issuer == self.oauth.issuer && oldSelf.oauth.resource == self.oauth.resource && oldSelf.oauth.bearerInBody == self.oauth.bearerInBody && oldSelf.oauth.supportsRefresh == self.oauth.supportsRefresh && (has(oldSelf.oauth.registrationEndpoint) == has(self.oauth.registrationEndpoint)) && (!has(oldSelf.oauth.registrationEndpoint) || oldSelf.oauth.registrationEndpoint == self.oauth.registrationEndpoint) && (has(oldSelf.oauth.issForCallback) == has(self.oauth.issForCallback)) && (!has(oldSelf.oauth.issForCallback) || oldSelf.oauth.issForCallback == self.oauth.issForCallback) && (has(oldSelf.oauth.asProfile) == has(self.oauth.asProfile)) && (!has(oldSelf.oauth.asProfile) || oldSelf.oauth.asProfile == self.oauth.asProfile))"
message: "remote spec.oauth pinned endpoints/clientMode/quirks/asProfile are immutable; delete and recreate to change them"
# GENERIC-REQ: generic requires id (its client_id), both endpoints and
# the required wire knobs. usePkce/includeResponseType/sendScope/
# supportsRefresh are booleans → required-by-CEL (has() presence), the
# install path writes each explicitly (no CRD default).
- rule: "!has(self.oauth) || !has(self.oauth.source) || self.oauth.source != 'generic' || (has(self.oauth.id) && has(self.oauth.authorizationEndpoint) && has(self.oauth.tokenEndpoint) && has(self.oauth.tokenRequestFormat) && has(self.oauth.tokenAuthMethod) && has(self.oauth.scopeSeparator) && has(self.oauth.sendScope) && has(self.oauth.supportsRefresh) && has(self.oauth.usePkce) && has(self.oauth.includeResponseType))"
message: "generic spec.oauth requires id, authorizationEndpoint, tokenEndpoint, tokenRequestFormat, tokenAuthMethod, scopeSeparator, sendScope, supportsRefresh, usePkce and includeResponseType"
# GENERIC-FORBID-REMOTE-FIELDS: generic reuses endpoints/resource/
# supportsRefresh but must not carry the remote-only discovery fields.
- rule: "!has(self.oauth) || !has(self.oauth.source) || self.oauth.source != 'generic' || (!has(self.oauth.clientMode) && !has(self.oauth.issuer) && !has(self.oauth.registrationEndpoint) && !has(self.oauth.issForCallback) && !has(self.oauth.bearerInBody) && !has(self.oauth.asProfile))"
message: "generic spec.oauth must not set remote-only fields (clientMode, issuer, registrationEndpoint, issForCallback, bearerInBody, asProfile)"
# REMOTE-FORBID-GENERIC-KNOBS: remote must not carry the generic wire knobs.
- rule: "!has(self.oauth) || !has(self.oauth.source) || self.oauth.source != 'remote' || (!has(self.oauth.tokenRequestFormat) && !has(self.oauth.tokenAuthMethod) && !has(self.oauth.scopeSeparator) && !has(self.oauth.sendScope) && !has(self.oauth.usePkce) && !has(self.oauth.includeResponseType) && !has(self.oauth.refreshEndpoint) && !has(self.oauth.extraAuthorizeParams))"
message: "remote spec.oauth must not set generic-only knobs"
# GENERIC-SECRET-PAIRING: public = neither ref (client_id IS spec.oauth.id,
# no secret); confidential = both refs. Mixed pairing is rejected.
- rule: "!has(self.oauth) || !has(self.oauth.source) || self.oauth.source != 'generic' || (has(self.oauth.clientIdRef) == has(self.oauth.clientSecretRef))"
message: "generic spec.oauth must set clientIdRef and clientSecretRef together (confidential) or neither (public)"
# REMOTE-SECRET-PAIRING: the three valid remote shapes are public (no refs),
# DCR-confidential (no refs — the secret lives in the encrypted
# dynamic_clients store) and pre-registered-confidential (both refs). So
# refs are both-or-neither, and public additionally forbids them: a public
# client has no secret, and the runtime cannot honor refs declared on one.
# Confidential stays legal WITH or WITHOUT refs, so presence of refs must
# not be required by clientMode (that would break DCR-confidential).
- rule: "!has(self.oauth) || !has(self.oauth.source) || self.oauth.source != 'remote' || ((has(self.oauth.clientIdRef) == has(self.oauth.clientSecretRef)) && (!has(self.oauth.clientMode) || self.oauth.clientMode != 'public' || !has(self.oauth.clientIdRef)))"
message: "remote spec.oauth must set clientIdRef and clientSecretRef together or neither, and neither when clientMode is public"
# REMOTE-BEARER-HEADER: mcp-host always sends the access token in the
# Authorization header, so a remote server that needs it in the request
# body cannot be served. The field stays required (REMOTE-REQ) but only
# false is admissible.
- rule: "!has(self.oauth) || !has(self.oauth.source) || self.oauth.source != 'remote' || !has(self.oauth.bearerInBody) || self.oauth.bearerInBody == false"
message: "remote spec.oauth.bearerInBody must be false; the access token is only sent in the Authorization header"
# AS-PROFILE-ISSUER: a profile changes the wire (no RFC 8707 resource), so it is
# only legal on the issuer it was recognised from — a Microsoft Entra ID tenant
# authority. [.] instead of \. keeps the pattern free of YAML/CEL escapes.
- rule: "!has(self.oauth) || !has(self.oauth.asProfile) || (has(self.oauth.issuer) && self.oauth.issuer.matches('^https://login[.]microsoftonline[.]com/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/v2[.]0$'))"
message: "spec.oauth.asProfile entra-v2 requires spec.oauth.issuer to be a Microsoft Entra ID tenant authority"
# SOURCE-VALUE-IMM: IMM-5 pins source PRESENCE; this pins the VALUE so a
# generic⇄remote flip in place is rejected even though both keep source set.
- rule: "!has(oldSelf.oauth) || !has(self.oauth) || !has(oldSelf.oauth.source) || !has(self.oauth.source) || oldSelf.oauth.source == self.oauth.source"
message: "spec.oauth.source value is immutable; delete and recreate to change the carril"
# GENERIC-IMM: pin generic endpoints + knobs. Double-source-VALUE-guarded
# (source != 'generic' short-circuits on BOTH revisions) so it only
# dereferences generic fields when BOTH revisions are generic; GENERIC-REQ
# then guarantees the required knobs are present. resource/refreshEndpoint/
# extraAuthorizeParams are optional → presence-pinned + guarded value-equality.
- rule: "!has(oldSelf.oauth) || !has(self.oauth) || !has(oldSelf.oauth.source) || oldSelf.oauth.source != 'generic' || !has(self.oauth.source) || self.oauth.source != 'generic' || (oldSelf.oauth.authorizationEndpoint == self.oauth.authorizationEndpoint && oldSelf.oauth.tokenEndpoint == self.oauth.tokenEndpoint && oldSelf.oauth.tokenRequestFormat == self.oauth.tokenRequestFormat && oldSelf.oauth.tokenAuthMethod == self.oauth.tokenAuthMethod && oldSelf.oauth.scopeSeparator == self.oauth.scopeSeparator && oldSelf.oauth.sendScope == self.oauth.sendScope && oldSelf.oauth.supportsRefresh == self.oauth.supportsRefresh && oldSelf.oauth.usePkce == self.oauth.usePkce && oldSelf.oauth.includeResponseType == self.oauth.includeResponseType && (has(oldSelf.oauth.resource) == has(self.oauth.resource)) && (!has(oldSelf.oauth.resource) || oldSelf.oauth.resource == self.oauth.resource) && (has(oldSelf.oauth.refreshEndpoint) == has(self.oauth.refreshEndpoint)) && (!has(oldSelf.oauth.refreshEndpoint) || oldSelf.oauth.refreshEndpoint == self.oauth.refreshEndpoint) && (has(oldSelf.oauth.extraAuthorizeParams) == has(self.oauth.extraAuthorizeParams)) && (!has(oldSelf.oauth.extraAuthorizeParams) || oldSelf.oauth.extraAuthorizeParams == self.oauth.extraAuthorizeParams))"
message: "generic spec.oauth pinned endpoints/knobs are immutable; delete and recreate to change them"
# GENERIC-SECRET-IMM: generic has no clientMode; its public/confidential
# posture is encoded by ref PRESENCE (GENERIC-SECRET-PAIRING pins that
# within a revision, but not across UPDATE). Without this, an update-RBAC
# actor could drop both refs (confidential→public, silently removing
# client_secret from the token exchange), add them (public→confidential),
# or repoint them at another Secret. Pin presence AND value of both refs on
# generic — the transition analogue of clientMode's IMM-6 pin on remote.
# Double-source-VALUE-guarded so it only dereferences generic refs when BOTH
# revisions are generic; each value read is presence-guarded (a matching
# presence-equality conjunct short-circuits before any absent deref).
- rule: "!has(oldSelf.oauth) || !has(self.oauth) || !has(oldSelf.oauth.source) || oldSelf.oauth.source != 'generic' || !has(self.oauth.source) || self.oauth.source != 'generic' || ((has(oldSelf.oauth.clientIdRef) == has(self.oauth.clientIdRef)) && (has(oldSelf.oauth.clientSecretRef) == has(self.oauth.clientSecretRef)) && (!has(oldSelf.oauth.clientIdRef) || (oldSelf.oauth.clientIdRef.name == self.oauth.clientIdRef.name && oldSelf.oauth.clientIdRef.key == self.oauth.clientIdRef.key)) && (!has(oldSelf.oauth.clientSecretRef) || (oldSelf.oauth.clientSecretRef.name == self.oauth.clientSecretRef.name && oldSelf.oauth.clientSecretRef.key == self.oauth.clientSecretRef.key)))"
message: "generic spec.oauth clientIdRef/clientSecretRef (secret posture) are immutable; delete and recreate to change them"
# REMOTE-SECRET-IMM: pin PRESENCE AND VALUE of both remote refs across
# UPDATE. IMM-6 pins clientMode/endpoints/quirks but NOT the refs, so
# without this an update-RBAC actor could add refs (public/DCR-confidential
# → pre-registered, moving the secret source from the encrypted store to a
# K8s Secret), drop them (pre-registered → store), or repoint them at another
# Secret — silently changing which credential the token exchange uses. The
# remote analogue of GENERIC-SECRET-IMM. Double-source-VALUE-guarded so it
# only dereferences remote refs when BOTH revisions are remote; each value
# read is presence-guarded (a matching presence-equality conjunct
# short-circuits before any absent deref).
- rule: "!has(oldSelf.oauth) || !has(self.oauth) || !has(oldSelf.oauth.source) || oldSelf.oauth.source != 'remote' || !has(self.oauth.source) || self.oauth.source != 'remote' || ((has(oldSelf.oauth.clientIdRef) == has(self.oauth.clientIdRef)) && (has(oldSelf.oauth.clientSecretRef) == has(self.oauth.clientSecretRef)) && (!has(oldSelf.oauth.clientIdRef) || (oldSelf.oauth.clientIdRef.name == self.oauth.clientIdRef.name && oldSelf.oauth.clientIdRef.key == self.oauth.clientIdRef.key)) && (!has(oldSelf.oauth.clientSecretRef) || (oldSelf.oauth.clientSecretRef.name == self.oauth.clientSecretRef.name && oldSelf.oauth.clientSecretRef.key == self.oauth.clientSecretRef.key)))"
message: "remote spec.oauth clientIdRef/clientSecretRef (secret posture) are immutable; delete and recreate to change them"
status:
type: object
properties:
resolvedEgressIPs:
type: array
description: Resolved IPs for DNS-based egress bindings (for auditability).
items:
type: object
properties:
dns:
type: string
ips:
type: array
items:
type: string
resolvedAt:
type: string
format: date-time
conditions:
type: array
description: Standard K8s conditions reflecting reconciliation state.
items:
type: object
required: [type, status]
properties:
type:
type: string
description: Condition type (e.g. SecretResolved, Ready).
status:
type: string
enum: ["True", "False", "Unknown"]
reason:
type: string
description: Machine-readable reason (e.g. SecretNotFound, SecretFound).
message:
type: string
description: Human-readable explanation.
lastTransitionTime:
type: string
format: date-time
observedGeneration:
type: integer
format: int64
description: McpServer metadata.generation observed by the controller when writing this condition.
additionalPrinterColumns:
- name: Context
type: string
jsonPath: .spec.contextRef
- name: Image
type: string
jsonPath: .spec.image
- name: Transport
type: string
jsonPath: .spec.transport.type
- name: URL
type: string
jsonPath: .spec.transport.url
- name: Enabled
type: boolean
jsonPath: .spec.enabled
- name: Managed
type: boolean
jsonPath: .spec.managed
- name: Ready
type: string
jsonPath: .status.conditions[?(@.type=="Ready")].status
subresources:
status: {}