list_k8s_resources
Filter and list Kubernetes resources by namespace, resource types, or cluster using pagination for organized results in RAD Security's environment.
Instructions
List Kubernetes resources with optional filtering by namespace, resource types, and cluster
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cluster_id | No | Cluster ID to filter resources | |
| kinds | No | List of kinds to filter. Example: ['Deployment', 'ServiceAccount', 'Pod'] | |
| namespace | No | Namespace 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 main handler function that implements the list_k8s_resources tool. It constructs query parameters from inputs and calls the RAD Security client 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 and validation 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:214-217 (registration)Tool registration in the ListTools response, providing name, description, and input schema for list_k8s_resources.name: "list_k8s_resources", description: "List Kubernetes resources with optional filtering by namespace, resource types, and cluster", inputSchema: zodToJsonSchema(kubeobject.ListKubernetesResourcesSchema), },
- src/index.ts:569-581 (registration)Dispatch case in the CallTool handler that routes list_k8s_resources calls to the implementation function after parsing arguments.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) }], };