list-networkpolicies
List Kubernetes network policies to manage network traffic rules and security controls within a namespace.
Instructions
List Kubernetes network policies in a namespace
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "list-networkpolicies"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| namespace | No | The namespace to list network policies from (optional, defaults to current context namespace) |
Implementation Reference
- server.js:1970-1978 (handler)Handler function that executes the tool logic by running kubectl get networkpolicies command with optional namespace flag.
case "list-networkpolicies": { const { namespace } = args || {}; const nsArg = namespace ? `-n ${namespace}` : ""; const cmd = `kubectl get networkpolicies ${nsArg} -o wide`; const { stdout } = await execAsync(cmd); return { content: [{ type: "text", text: stdout || "No network policies found" }] }; } - server.js:888-898 (schema)Input schema definition for the list-networkpolicies tool, defining optional namespace parameter.
name: "list-networkpolicies", description: "List Kubernetes network policies in a namespace", inputSchema: { type: "object", properties: { namespace: { type: "string", description: "The namespace to list network policies from (optional, defaults to current context namespace)" } } } - server.js:1392-1394 (registration)Tool registration via the ListToolsRequestHandler that returns the tools array containing list-networkpolicies.
server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });