list_k8s_resources
List Kubernetes resources with optional filtering by namespace, resource types, and cluster to retrieve security insights and runtime data.
Instructions
List Kubernetes resources with optional filtering by namespace, resource types, and cluster
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| namespace | No | Namespace to filter resources | |
| kinds | No | List of kinds to filter. Example: ['Deployment', 'ServiceAccount', 'Pod'] | |
| cluster_id | No | Cluster ID to filter resources | |
| page | No | Page number for pagination | |
| page_size | No | Number of items per page |
Implementation Reference
- src/operations/kubeobject.ts:38-64 (handler)The handler function that executes the tool logic: constructs query parameters and calls the RAD Security API to list Kubernetes resources.export async function listKubernetesResources( client: RadSecurityClient, kinds: string[] | undefined, namespace?: string, clusterId?: string, page: number = 1, pageSize: number = 20 ): Promise<any> { const params: Record<string, any> = { page, page_size: pageSize, resource_types: kinds?.join(',') }; if (namespace) { params.namespace = namespace; } if (clusterId) { params.cluster_id = clusterId; } return client.makeRequest( `/accounts/${client.getAccountId()}/resources`, params ); }
- src/operations/kubeobject.ts:9-15 (schema)Zod schema defining the input parameters for the list_k8s_resources tool.export const ListKubernetesResourcesSchema = z.object({ namespace: z.string().optional().describe("Namespace to filter resources"), kinds: z.array(z.string()).optional().describe("List of kinds to filter. Example: ['Deployment', 'ServiceAccount', 'Pod']"), cluster_id: z.string().optional().describe("Cluster ID to filter resources"), page: z.number().optional().default(1).describe("Page number for pagination"), page_size: z.number().optional().default(20).describe("Number of items per page"), });
- src/index.ts:319-326 (registration)Tool metadata registration in the listTools handler, including name, description, and input schema.{ name: "list_k8s_resources", description: "List Kubernetes resources with optional filtering by namespace, resource types, and cluster", inputSchema: zodToJsonSchema( kubeobject.ListKubernetesResourcesSchema ), },
- src/index.ts:1073-1089 (registration)Dispatch handler in the CallToolRequest switch statement that parses args and invokes the listKubernetesResources function.case "list_k8s_resources": { const args = kubeobject.ListKubernetesResourcesSchema.parse( request.params.arguments ); const response = await kubeobject.listKubernetesResources( client, args.kinds, args.namespace, args.cluster_id, args.page, args.page_size ); return { content: [ { type: "text", text: JSON.stringify(response, null, 2) }, ], };