Skip to main content
Glama

list_api_resources

Discover available Kubernetes API resources in your cluster to understand what operations you can perform. Filter by API group, namespaced status, or supported verbs to find specific resources for managing deployments, pods, and services.

Instructions

List the API resources available in the cluster

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
apiGroupNoAPI group to filter by
namespacedNoIf true, only show namespaced resources
contextNoKubeconfig Context to use for the command (optional - defaults to null)
verbsNoList of verbs to filter by
outputNoOutput format (wide, name, or no-headers)wide

Implementation Reference

  • The main handler function that constructs and executes the 'kubectl api-resources' command based on input parameters and returns the formatted output as MCP content.
    export async function listApiResources( params: ListApiResourcesParams ): Promise<{ content: { type: string; text: string }[] }> { try { const command = "kubectl"; const args = ["api-resources"]; if (params.apiGroup) { args.push(`--api-group=${params.apiGroup}`); } if (params.namespaced !== undefined) { args.push(`--namespaced=${params.namespaced}`); } if (params.verbs && params.verbs.length > 0) { args.push(`--verbs=${params.verbs.join(",")}`); } if (params.output) { args.push(`-o`, params.output); } if (params.context) { args.push("--context", params.context); } const result = executeKubectlCommand(command, args); return { content: [ { type: "text", text: result, }, ], }; } catch (error: any) { throw new Error(`Failed to list API resources: ${error.message}`); } }
  • The MCP tool schema defining the name, description, annotations, and input schema for the list_api_resources tool.
    export const listApiResourcesSchema = { name: "list_api_resources", description: "List the API resources available in the cluster", annotations: { readOnlyHint: true, }, inputSchema: { type: "object", properties: { apiGroup: { type: "string", description: "API group to filter by", }, namespaced: { type: "boolean", description: "If true, only show namespaced resources", }, context: { type: "string", description: "Kubeconfig Context to use for the command (optional - defaults to null)", default: "", }, verbs: { type: "array", items: { type: "string", }, description: "List of verbs to filter by", }, output: { type: "string", description: "Output format (wide, name, or no-headers)", enum: ["wide", "name", "no-headers"], default: "wide", }, }, }, };
  • src/index.ts:468-478 (registration)
    The dispatch case in the CallToolRequestSchema handler that invokes the listApiResources handler function.
    case "list_api_resources": { return await listApiResources( input as { apiGroup?: string; namespaced?: boolean; verbs?: string[]; output?: "wide" | "name" | "no-headers"; context?: string; } ); }
  • TypeScript interface defining the parameters for the listApiResources function.
    export interface ListApiResourcesParams { apiGroup?: string; namespaced?: boolean; verbs?: string[]; output?: "wide" | "name" | "no-headers"; context?: string; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Flux159/mcp-server-kubernetes'

If you have feedback or need assistance with the MCP directory API, please join our Discord server