get_app_sheet_objects
Retrieve objects from a Qlik Sense sheet by providing the application and sheet IDs to access object details including type and description for analysis.
Instructions
Get list of objects from specific sheet with object ID, type and description.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| app_id | Yes | Application GUID | |
| sheet_id | Yes | Sheet GUID |
Implementation Reference
- qlik_sense_mcp_server/server.py:892-931 (handler)Handler for the 'get_app_sheet_objects' tool call. Opens the app via Engine API, retrieves sheet objects using helper method, formats output with object ID, type, and description.elif name == "get_app_sheet_objects": app_id = arguments["app_id"] sheet_id = arguments["sheet_id"] def _get_sheet_objects(): try: self.engine_api.connect() app_result = self.engine_api.open_doc_safe(app_id, no_data=True) app_handle = app_result.get("qReturn", {}).get("qHandle", -1) if app_handle == -1: return {"error": "Failed to open app"} # Get detailed objects from the sheet objects = self.engine_api._get_sheet_objects_detailed(app_handle, sheet_id) or [] # Format objects according to requirements: id объекта, тип объекта, описание объекта formatted_objects = [] for obj in objects: if isinstance(obj, dict): obj_info = { "object_id": obj.get("object_id", ""), "object_type": obj.get("object_type", ""), "object_description": obj.get("object_title", "") } formatted_objects.append(obj_info) return { "app_id": app_id, "sheet_id": sheet_id, "total_objects": len(formatted_objects), "objects": formatted_objects } except Exception as e: return {"error": str(e), "details": f"Error getting objects for sheet {sheet_id} in app {app_id}"} finally: self.engine_api.disconnect() result = await asyncio.to_thread(_get_sheet_objects) return [TextContent(type="text", text=json.dumps(result, indent=2, ensure_ascii=False))]
- Schema definition and registration of the 'get_app_sheet_objects' tool in the list_tools handler.name="get_app_sheet_objects", description="Get list of objects from specific sheet with object ID, type and description.", inputSchema={ "type": "object", "properties": { "app_id": {"type": "string", "description": "Application GUID"}, "sheet_id": {"type": "string", "description": "Sheet GUID"} }, "required": ["app_id", "sheet_id"] } ),
- Core helper function that implements the logic to fetch detailed sheet objects using Qlik Engine API: GetObject for sheet, GetLayout to get children, then recursive GetObject/GetLayout for each object to extract type, title, and fields used.def _get_sheet_objects_detailed(self, app_handle: int, sheet_id: str) -> List[Dict[str, Any]]: """Get detailed information about objects on a sheet.""" try: sheet_result = self.send_request("GetObject", {"qId": sheet_id}, handle=app_handle) if "qReturn" not in sheet_result or "qHandle" not in sheet_result["qReturn"]: logger.warning(f"Failed to get sheet object {sheet_id}: {sheet_result}") return [] sheet_handle = sheet_result["qReturn"]["qHandle"] sheet_layout = self.send_request("GetLayout", [], handle=sheet_handle) if "qLayout" not in sheet_layout or "qChildList" not in sheet_layout["qLayout"]: logger.warning(f"No child objects in sheet {sheet_id}") return [] child_objects = sheet_layout["qLayout"]["qChildList"]["qItems"] detailed_objects = [] for child_obj in child_objects: obj_id = child_obj.get("qInfo", {}).get("qId", "") obj_type = child_obj.get("qInfo", {}).get("qType", "") if not obj_id: continue try: obj_result = self.send_request("GetObject", {"qId": obj_id}, handle=app_handle) if "qReturn" not in obj_result or "qHandle" not in obj_result["qReturn"]: continue obj_handle = obj_result["qReturn"]["qHandle"] obj_layout = self.send_request("GetLayout", [], handle=obj_handle) if "qLayout" not in obj_layout: continue fields_used = self._extract_fields_from_object(obj_layout["qLayout"]) detailed_obj = { "object_id": obj_id, "object_type": obj_type, "object_title": obj_layout["qLayout"].get("title", ""), "object_subtitle": obj_layout["qLayout"].get("subtitle", ""), "fields_used": fields_used, "basic_info": child_obj, "detailed_layout": obj_layout["qLayout"] } detailed_objects.append(detailed_obj) logger.info(f"Processed object {obj_id} ({obj_type}) with {len(fields_used)} fields") except Exception as obj_error: logger.warning(f"Error processing object {obj_id}: {obj_error}") continue return detailed_objects except Exception as e: logger.error(f"_get_sheet_objects_detailed error: {str(e)}") return []