get-contexts
List all available kubectl contexts to manage Kubernetes clusters through natural language commands.
Instructions
List all kubectl contexts
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": "get-contexts"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- server.js:1804-1810 (handler)The handler function for the 'get-contexts' tool that runs the kubectl command to list all contexts and returns the stdout as text content.
case "get-contexts": { const cmd = `kubectl config get-contexts`; const { stdout } = await execAsync(cmd); return { content: [{ type: "text", text: stdout || "No contexts found" }] }; } - server.js:646-652 (schema)The tool definition including name, description, and input schema (empty object, no parameters required). This is part of the tools array returned by ListTools.
name: "get-contexts", description: "List all kubectl contexts", inputSchema: { type: "object", properties: {} } }, - server.js:1392-1394 (registration)The request handler for listing tools, which returns the full tools array containing the 'get-contexts' tool definition.
server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });