Skip to main content
Glama

clusterrole_create

Create a ClusterRole in Kubernetes to define permissions across all namespaces, specifying rules for resource access and operations.

Instructions

Create a ClusterRole in the cluster.

Args: context_name: The Kubernetes context name name: The ClusterRole name rules: List of policy rules

Returns: Status of the creation operation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
context_nameYes
nameYes
rulesYes

Implementation Reference

  • The handler function decorated with @mcp.tool() that creates a Kubernetes ClusterRole using the RBAC API. It takes context_name, name, and rules as input and returns the creation status.
    @mcp.tool()
    @use_current_context
    @check_readonly_permission
    def clusterrole_create(context_name: str, name: str, rules: list):
        """
        Create a ClusterRole in the cluster.
    
        Args:
            context_name: The Kubernetes context name
            name: The ClusterRole name
            rules: List of policy rules
    
        Returns:
            Status of the creation operation
        """
        rbac_v1: RbacAuthorizationV1Api = get_api_clients(context_name)["rbac"]
        clusterrole = V1ClusterRole(
            metadata=V1ObjectMeta(name=name),
            rules=[V1PolicyRule(**rule) for rule in rules]
        )
        created_clusterrole = rbac_v1.create_cluster_role(body=clusterrole)
        return {"name": created_clusterrole.metadata.name, "status": "Created"}
  • tools/role.py:112-112 (registration)
    The @mcp.tool() decorator registers the clusterrole_create function as an MCP tool.
    @mcp.tool()
  • Input schema defined by function parameters and docstring: context_name (str), name (str), rules (list).
    def clusterrole_create(context_name: str, name: str, rules: list):
        """
        Create a ClusterRole in the cluster.
    
        Args:
            context_name: The Kubernetes context name
            name: The ClusterRole name
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. While 'Create' implies a write/mutation operation, the description doesn't disclose important behavioral aspects: what permissions are required, whether this is idempotent, what happens if the ClusterRole already exists, or any rate limits. The 'Returns' statement is vague ('Status of the creation operation') without specifying format or possible outcomes.

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

Conciseness4/5

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

The description is appropriately concise with clear sections (purpose, Args, Returns). Each sentence serves a purpose, though the Args section could be more informative. The structure is front-loaded with the main purpose first, followed by parameter and return information.

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

Completeness2/5

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

For a Kubernetes ClusterRole creation tool with 3 parameters (including a complex 'rules' array), no annotations, and no output schema, the description is insufficient. It doesn't explain the Kubernetes-specific context, doesn't provide examples of policy rules, doesn't mention error conditions, and the return value description is too vague for practical use.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate but provides minimal parameter guidance. The Args section lists parameters but offers no semantic context: 'rules: List of policy rules' doesn't explain what policy rules are, their format, or examples. For a Kubernetes ClusterRole creation, the 'rules' parameter is complex and critical but receives only a generic description.

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 'Create a ClusterRole in the cluster' which is a specific verb+resource combination. It distinguishes from siblings like clusterrole_get, clusterrole_list, and clusterrole_delete by specifying the creation action. However, it doesn't explicitly differentiate from role_create (which creates Role objects instead of ClusterRole objects).

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. It doesn't mention when to use clusterrole_create versus role_create (for namespace-scoped roles), or when to use this versus modifying existing ClusterRoles. There's also no mention of prerequisites like required permissions or cluster context setup.

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/bourbonkk/k8s-pilot'

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