Skip to main content
Glama

role_create

Define and create Kubernetes roles in specified namespaces using policy rules with the k8s-pilot server. Simplify role management across multiple clusters.

Instructions

Create a Role in the specified namespace.

Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The Role name rules: List of policy rules

Returns: Status of the creation operation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
context_nameYes
nameYes
namespaceYes
rulesYes

Implementation Reference

  • The core handler function for the 'role_create' MCP tool. It uses the Kubernetes RBAC API to create a namespaced Role object with the provided name and rules. Registered directly via the @mcp.tool() decorator. Input schema is defined by type hints and the function docstring.
    @mcp.tool() @use_current_context @check_readonly_permission def role_create(context_name: str, namespace: str, name: str, rules: list): """ Create a Role in the specified namespace. Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The Role name rules: List of policy rules Returns: Status of the creation operation """ rbac_v1: RbacAuthorizationV1Api = get_api_clients(context_name)["rbac"] role = V1Role( metadata=V1ObjectMeta(name=name), rules=[V1PolicyRule(**rule) for rule in rules] ) created_role = rbac_v1.create_namespaced_role(namespace=namespace, body=role) return {"name": created_role.metadata.name, "status": "Created"}
  • tools/role.py:27-27 (registration)
    The @mcp.tool() decorator registers the role_create function as an MCP tool.
    @mcp.tool()
  • Input schema and documentation for the role_create tool, specifying parameters: context_name (str), namespace (str), name (str), rules (list). Returns creation status.
    def role_create(context_name: str, namespace: str, name: str, rules: list): """ Create a Role in the specified namespace. Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The Role name rules: List of policy rules Returns: Status of the creation operation """

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

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