list_k8s_resource_misconfigs
Identify Kubernetes resource misconfigurations using UID for enhanced security and compliance in cloud environments.
Instructions
Get manifest misconfigurations for a Kubernetes resource
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| resource_uid | Yes | Kubernetes resource UID to get misconfigurations for |
Implementation Reference
- src/operations/misconfigs.ts:17-45 (handler)The main handler function that executes the tool logic: queries the RAD Security API for misconfigurations on the given Kubernetes resource UID, deduplicates entries by policy human_id, and returns the processed list.export async function listKubernetesResourceMisconfigurations( client: RadSecurityClient, resourceUid: string ): Promise<any> { const misconfigs = await client.makeRequest( `/accounts/${client.getAccountId()}/misconfig`, { kubeobject_uids: resourceUid, page_size: 50 } ); // deduplicate the list based on field "guard_policy.human_id" const seenIds = new Set<string>(); const toReturn = []; for (const misconfig of misconfigs.entries) { const humanId = misconfig.guard_policy.human_id; if (!seenIds.has(humanId)) { seenIds.add(humanId); toReturn.push({ id: misconfig.id, cluster_id: misconfig.cluster_id, title: misconfig.guard_policy.title, human_id: misconfig.guard_policy.human_id, }); } } misconfigs.entries = toReturn; return misconfigs; }
- src/operations/misconfigs.ts:4-6 (schema)Zod schema defining the input parameters for the tool (resource_uid). Used in registration and validation.export const ListKubernetesResourceMisconfigurationsSchema = z.object({ resource_uid: z.string().describe("Kubernetes resource UID to get misconfigurations for"), });
- src/index.ts:221-225 (registration)Tool registration in the MCP server's listTools handler, defining name, description, and schema.{ name: "list_k8s_resource_misconfigs", description: "Get manifest misconfigurations for a Kubernetes resource", inputSchema: zodToJsonSchema(misconfigs.ListKubernetesResourceMisconfigurationsSchema), },
- src/index.ts:584-593 (registration)Dispatcher case in the MCP server's CallToolRequest handler that validates input, calls the tool handler, and formats the response.case "list_k8s_resource_misconfigs": { const args = misconfigs.ListKubernetesResourceMisconfigurationsSchema.parse(request.params.arguments); const response = await misconfigs.listKubernetesResourceMisconfigurations( client, args.resource_uid ); return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }], }; }