Skip to main content
Glama
abhijeetka
by abhijeetka

list_contexts

Lists all available Kubernetes contexts to help users identify and switch between different cluster configurations for managing containerized applications.

Instructions

List all available Kubernetes contexts

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'list_contexts' MCP tool. It executes 'kubectl config get-contexts -o name' to list all available Kubernetes contexts and returns them as a list in a dict.
    @mcp.tool()
    async def list_contexts() -> dict:
        """List all available Kubernetes contexts"""
        try:
            cmd = ["kubectl", "config", "get-contexts", "-o", "name"]
            result = subprocess.run(cmd, capture_output=True, text=True, check=True)
            contexts = result.stdout.strip().split('\n')
            return {"contexts": contexts}
        except subprocess.CalledProcessError as e:
            return {"error": f"Failed to list contexts: {str(e)}"}
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states what the tool does but doesn't describe how it behaves: no information about output format (e.g., list of context names with metadata), whether it requires cluster access permissions, if it's read-only (implied but not stated), or potential errors. For a tool with zero annotation coverage, this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence that efficiently communicates the core functionality. Every word earns its place: 'List' (action), 'all available' (scope), 'Kubernetes contexts' (resource). There's no redundancy, unnecessary elaboration, or structural issues. It's front-loaded with the essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (zero parameters, no output schema, no annotations), the description is adequate but minimal. It states what the tool does but doesn't provide context about typical use cases, relationship to other context operations, or what the output looks like. For a read-only listing tool in a Kubernetes environment, more guidance about when and why to use it would improve completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has zero parameters (schema coverage 100%), so there are no parameters to document. The description appropriately doesn't discuss parameters, focusing instead on the tool's purpose. With no parameters to explain, the description meets the baseline expectation for parameter semantics without needing to compensate for schema gaps.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('List') and resource ('all available Kubernetes contexts'), making the purpose immediately understandable. It doesn't explicitly differentiate from sibling tools like 'get_current_context', but the scope ('all available') provides some implicit distinction. The description avoids tautology by specifying what is being listed rather than just restating the tool name.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'get_current_context' (which retrieves only the active context) or 'use_context' (which switches contexts). There's no mention of prerequisites, typical use cases, or when this tool would be preferred over other context-related operations. The agent must infer usage from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/abhijeetka/mcp-k8s-server'

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