diff --git a/mcpgateway/admin.py b/mcpgateway/admin.py index e7c778f4f..55469f08d 100644 --- a/mcpgateway/admin.py +++ b/mcpgateway/admin.py @@ -8784,18 +8784,12 @@ async def admin_metrics_partial_html( Raises: HTTPException: If entity_type is not one of the valid types """ - LOGGER.debug( - f"User {get_user_email(user)} requested metrics partial " - f"(entity_type={entity_type}, page={page}, per_page={per_page})" - ) + LOGGER.debug(f"User {get_user_email(user)} requested metrics partial " f"(entity_type={entity_type}, page={page}, per_page={per_page})") # Validate entity type valid_types = ["tools", "resources", "prompts", "servers"] if entity_type not in valid_types: - raise HTTPException( - status_code=400, - detail=f"Invalid entity_type. Must be one of: {', '.join(valid_types)}" - ) + raise HTTPException(status_code=400, detail=f"Invalid entity_type. Must be one of: {', '.join(valid_types)}") # Constrain parameters page = max(1, page) diff --git a/mcpgateway/auth.py b/mcpgateway/auth.py index 94b690a99..c538a7479 100644 --- a/mcpgateway/auth.py +++ b/mcpgateway/auth.py @@ -103,7 +103,10 @@ async def get_team_from_token(payload: Dict[str, Any], db: Session) -> Optional[ >>> del sys.modules["mcpgateway.services.team_management_service"] """ team_id = payload.get("teams")[0] if payload.get("teams") else None + if isinstance(team_id, dict): + team_id = team_id.get("id") user_email = payload.get("sub") + # If no team found in token, get user's personal team if not team_id: