create_or_update_role
Define or modify user roles with specific permissions, enabling fine-grained access control for secure and tailored user management on the MCP Server for Coroot.
Instructions
Create or update a user role (admin only).
Defines custom roles with specific permissions for fine-grained access control.
Args: name: Role name permissions: List of permission strings description: Optional role description
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| description | No | ||
| name | Yes | ||
| permissions | Yes |
Implementation Reference
- src/mcp_coroot/server.py:2175-2191 (handler)The primary MCP tool handler function for 'create_or_update_role', registered via @mcp.tool() decorator. It receives parameters and delegates to the implementation helper.@mcp.tool() async def create_or_update_role( name: str, permissions: list[str], description: str | None = None ) -> dict[str, Any]: """ Create or update a user role (admin only). Defines custom roles with specific permissions for fine-grained access control. Args: name: Role name permissions: List of permission strings description: Optional role description """ return await create_or_update_role_impl(name, permissions, description)
- src/mcp_coroot/server.py:2154-2173 (helper)Helper implementation function that constructs the role_data dictionary from parameters, handles errors, and invokes the CorootClient method.async def create_or_update_role_impl( name: str, permissions: list[str], description: str | None = None ) -> dict[str, Any]: """Implementation for create_or_update_role tool.""" try: client = get_client() role_data = {"name": name, "permissions": permissions} if description: role_data["description"] = description result = await client.create_or_update_role(role_data) return { "success": True, "message": "Role created/updated successfully", "role": result, } except ValueError as e: return {"success": False, "error": str(e)} except Exception as e: return {"success": False, "error": f"Unexpected error: {str(e)}"}
- src/mcp_coroot/client.py:1616-1627 (helper)CorootClient class method that performs the HTTP POST request to the Coroot API endpoint '/api/roles' to create or update the role and parses the JSON response.async def create_or_update_role(self, role_data: dict[str, Any]) -> dict[str, Any]: """Create or update a role. Args: role_data: Role configuration Returns: Dict containing created/updated role """ response = await self._request("POST", "/api/roles", json=role_data) data: dict[str, Any] = response.json() return data