Discover and interact with custom Kubernetes resources the agent has never seen before
Kubernetes clusters often have Custom Resource Definitions (CRDs) installed by operators, service meshes, and platform tools. These are APIs the agent has never seen in its training data. Through the kube proxy, it can discover them, read their schemas, and interact with them — no pre-built tools required.There are two ways to discover CRDs, each useful for different things.
Since Kubernetes 1.15+, CRDs with structural schemas are included in the cluster’s OpenAPI spec. The agent can fetch the full API surface — including custom resources — as proper OpenAPI paths:
Copy
async () => { const clusterId = "cls_abc123"; // resolved by the agent from conversation const kube = (path) => cnap.request({ method: "GET", path: `/v1/clusters/${clusterId}/kube/${path}`, }).then(r => r.body); // /openapi/v3 returns an index of all API group paths const index = await kube("openapi/v3"); // Each CRD group has its own path, e.g. "apis/cilium.io/v2" // Fetch a specific group to get full REST paths and schemas const cilium = await kube("openapi/v3/apis/cilium.io/v2"); return { available_groups: Object.keys(index.paths || {}), cilium_paths: Object.keys(cilium.paths || {}), };}
This gives the agent the actual REST endpoints (GET /apis/cilium.io/v2/namespaces/{ns}/ciliumnetworkpolicies) with full request/response schemas — the same format as the CNAP OpenAPI spec it already knows how to query with search.Best for: “How do I call this custom API?” — full REST paths, request bodies, and response schemas.
Use the CRD API for discovery (“what’s installed?”) and the OpenAPI spec for understanding (“how do I use it?”). An agent typically starts with the CRD API to find what’s interesting, then fetches the OpenAPI group for the full schema.
Traditional MCP servers need a pre-built tool for every API. When a cluster has CRDs from Cilium, cert-manager, Prometheus, Argo, or any other operator, those tools don’t exist. The agent is stuck.With Code Mode + the kube proxy, the agent is self-sufficient. It discovers what’s available, learns the schema, and interacts with custom resources — all at runtime, without any code changes to the MCP server. The API surface of the MCP grows automatically with whatever is installed in the cluster.