Skip to main content
Glama
yanmxa

Multi-Cluster MCP Server

by yanmxa

clusters

Retrieve a list of Kubernetes clusters managed by Multi-Cluster MCP Server for streamlined multi-cluster operations and Kubernetes resource management.

Instructions

Retrieves a list of Kubernetes clusters (also known as managed clusters or spoke clusters).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • TypeScript handler for the 'clusters' MCP tool. Lists managed Kubernetes clusters using Kubernetes client-node, formats output as a table with name, hub accepted, URL, joined, available, age.
    export async function listClusters({ }): Promise<CallToolResult> {
      const response = await client.list<k8s.KubernetesObject>("cluster.open-cluster-management.io/v1", "ManagedCluster")
      if (!response || response.items.length == 0) {
        console.warn("no managed clusters on the current cluster")
        return {
          content: [{
            type: "text",
            text: "no managed clusters available on the current cluster"
          }],
        }
      }
    
      clusterToServerAPIMap = new Map(
        response.items.map((item: any) => {
          const name: string = item.metadata?.name;
          const server: string = item.spec?.managedClusterClientConfigs?.[0]?.url;
          return [name, server];
        })
      );
    
      // Format table header
      let result = `NAME       HUB ACCEPTED   MANAGED CLUSTER URLS                                                            JOINED   AVAILABLE   AGE\n`;
    
      // Process each cluster and format the output
      response.items.forEach((item: any) => {
        const name: string = item.metadata?.name || "Unknown";
        const hubAccepted: string = item.spec?.hubAcceptsClient ? "true" : "false";
        const server: string = item.spec?.managedClusterClientConfigs?.[0]?.url || "N/A";
    
        // Extract conditions
        const joinedCondition = item.status?.conditions?.find((c: any) => c.type === "ManagedClusterJoined")?.status || "False";
        const availableCondition = item.status?.conditions?.find((c: any) => c.type === "ManagedClusterConditionAvailable")?.status || "False";
    
        // Calculate cluster age
        const creationTimestamp = item.metadata?.creationTimestamp;
        const age = creationTimestamp ? getClusterAge(creationTimestamp) : "N/A";
    
        // Append formatted row
        result += `${name.padEnd(10)} ${hubAccepted.padEnd(14)} ${server.padEnd(80)} ${joinedCondition.padEnd(8)} ${availableCondition.padEnd(10)} ${age}\n`;
      });
    
      return {
        content: [{
          type: "text",
          text: result
        }],
      }
    }
  • src/index.ts:24-28 (registration)
    Registers the 'clusters' tool in the TypeScript MCP server using McpServer.tool().
      "clusters",
      listClusterDesc,
      listClustersArgs, // should be a Zod schema, e.g., z.object({...})
      async (args, extra) => listClusters(args) // ensure listClusters matches (args, extra) => ...
    )
  • Description and empty Zod schema (no args) for the 'clusters' tool.
    export const listClusterDesc = "Retrieves a list of Kubernetes clusters (also known as managed clusters or spoke clusters)."
    export const listClustersArgs = {}
  • Python handler for the 'clusters' MCP tool, decorated with @mcp.tool. Uses kubernetes.dynamic to list managed clusters and formats as table.
    @mcp.tool(description="Retrieves a list of Kubernetes clusters (also known as managed clusters or spoke clusters).")
    def clusters() -> Annotated[str, Field(description="The managed clusters, also known as spoke clusters.")]:
        config.load_kube_config()
        dyn_client = DynamicClient(ApiClient())
    
        try:
            managed_cluster_res = dyn_client.resources.get(
                api_version="cluster.open-cluster-management.io/v1",
                kind="ManagedCluster"
            )
            response = managed_cluster_res.get()
            items = response.items
        except Exception as e:
            return f"Failed to list clusters: {e}"
    
        if not items:
            return "No managed clusters available on the current cluster"
    
        header = (
            f"{'NAME':<12} {'HUB ACCEPTED':<15} {'MANAGED CLUSTER URLS':<80} "
            f"{'JOINED':<8} {'AVAILABLE':<10} {'AGE'}"
        )
        result_lines = [header]
    
        for item in items:
            metadata = item.metadata
            spec = item.spec or {}
            status = item.status or {}
    
            name = metadata.name or "Unknown"
            hub_accepted = str(spec.get("hubAcceptsClient", False)).lower()
            server = spec.get("managedClusterClientConfigs", [{}])[0].get("url", "N/A")
    
            conditions = status.get("conditions", [])
            joined = next((c.get("status") for c in conditions if c.get("type") == "ManagedClusterJoined"), "False")
            available = next((c.get("status") for c in conditions if c.get("type") == "ManagedClusterConditionAvailable"), "False")
    
            creation_timestamp = metadata.creationTimestamp
            age = get_cluster_age(creation_timestamp) if creation_timestamp else "N/A"
    
            if generate_kubeconfig:
                try:
                      kubeconfig_path = setup_cluster_access(cluster=name)
                      cluster_kubeconfig_map[name] = kubeconfig_path
                except Exception as e:
                    logger.warning(f"Failed to setup access for cluster '{name}': {e}")
    
            result_lines.append(
                f"{name:<12} {hub_accepted:<15} {server:<80} {joined:<8} {available:<10} {age}"
            )
    
        return "\n".join(result_lines)
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states 'retrieves a list' which implies a read-only operation, but doesn't cover aspects like pagination, rate limits, authentication needs, or what happens if no clusters exist. This leaves significant gaps for an agent to understand how to interact with it.

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, efficient sentence that front-loads the core purpose ('retrieves a list of Kubernetes clusters') and adds clarifying context without redundancy. Every word earns its place, making it highly concise and well-structured.

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 (0 parameters, no output schema, no annotations), the description is adequate but incomplete. It explains what the tool does but lacks behavioral details (e.g., response format, error handling) that would help an agent use it effectively, especially with no output schema to clarify returns.

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 input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description doesn't add parameter details, which is appropriate here. Baseline is 4 for zero parameters, as the schema fully covers the absence of inputs.

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 ('retrieves') and resource ('list of Kubernetes clusters'), with additional clarifying synonyms ('managed clusters or spoke clusters'). It doesn't distinguish from sibling tools like 'connect_cluster' or 'kube_executor', but the purpose is unambiguous.

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?

No guidance is provided on when to use this tool versus alternatives like 'connect_cluster' or 'kube_executor'. The description implies a read-only listing operation but doesn't specify prerequisites, contexts, or exclusions for usage.

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

Related 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/yanmxa/multicluster-mcp-server'

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