get_roles
Retrieve available user roles like Viewer, Editor, and Admin for assignment in the Coroot observability platform.
Instructions
Get available user roles.
Returns all available roles that can be assigned to users (e.g., Viewer, Editor, Admin).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/mcp_coroot/server.py:1669-1676 (handler)MCP tool registration and handler function for 'get_roles'. This is the entry point decorated with @mcp.tool() that executes the tool logic by calling the implementation.@mcp.tool() async def get_roles() -> dict[str, Any]: """Get available user roles. Returns all available roles that can be assigned to users (e.g., Viewer, Editor, Admin). """ return await get_roles_impl() # type: ignore[no-any-return]
- src/mcp_coroot/server.py:1660-1667 (helper)Helper implementation that wraps the client call to get_roles, adds success wrapper, and handles errors.async def get_roles_impl() -> dict[str, Any]: """Get available roles.""" roles = await get_client().get_roles() return { "success": True, "roles": roles, }
- src/mcp_coroot/client.py:1372-1380 (helper)CorootClient method that makes the actual API request to /api/roles to fetch the roles data. This is the core implementation called by the MCP tool chain.async def get_roles(self) -> dict[str, Any]: """Get available roles. Returns: List of available roles. """ response = await self._request("GET", "/api/roles") data: dict[str, Any] = response.json() return data
- src/mcp_coroot/server.py:93-113 (helper)Utility function to lazily initialize and retrieve the shared CorootClient instance used by all tools.def get_client() -> CorootClient: """Get or create the client instance. Raises: ValueError: If no credentials are configured. """ global _client if _client is None: try: _client = CorootClient() except ValueError as e: # Re-raise with more context raise ValueError( "Coroot credentials not configured. " "Please set COROOT_BASE_URL and either:\n" " - COROOT_USERNAME and COROOT_PASSWORD for automatic login\n" " - COROOT_SESSION_COOKIE for direct authentication\n" " - COROOT_API_KEY for data ingestion endpoints" ) from e return _client