get_dashboard_items
Retrieve all items from a Metabase dashboard using its ID to access charts, cards, and visualizations for data analysis and reporting.
Instructions
Get all items in a dashboard.
Args: dashboard_id (int): ID of the dashboard.
Returns: Dict[str, Any]: All items in the dashboard.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dashboard_id | Yes |
Implementation Reference
- src/metabase_mcp_server.py:714-726 (handler)The get_dashboard_items tool implementation - an async function decorated with @mcp.tool() that takes a dashboard_id parameter and returns all items in the dashboard by making a GET request to the Metabase API endpoint /api/dashboard/{dashboard_id}/items
@mcp.tool() async def get_dashboard_items(dashboard_id: int) -> Dict[str, Any]: """ Get all items in a dashboard. Args: dashboard_id (int): ID of the dashboard. Returns: Dict[str, Any]: All items in the dashboard. """ logger.info(f"Getting items for dashboard {dashboard_id}") return await make_metabase_request(RequestMethod.GET, f"/api/dashboard/{dashboard_id}/items") - src/metabase_mcp_server.py:162-200 (helper)Helper function make_metabase_request that handles HTTP requests to the Metabase API, used by get_dashboard_items to fetch dashboard items
async def make_metabase_request( method: RequestMethod, endpoint: str, data: Optional[Dict[str, Any] | bytes] = None, params: Optional[Dict[str, Any]] = None, json: Any = None, headers: Optional[Dict[str, str]] = None, ) -> Dict[str, Any]: """ Make a request to the Metabase API. Args: method: HTTP method to use (GET, POST, PUT, DELETE) endpoint: API endpoint path data: Request data (for form data) params: URL parameters json: JSON request body headers: Additional headers Returns: Dict[str, Any]: Response data Raises: MetabaseConnectionError: When the Metabase server is unreachable MetabaseResponseError: When Metabase returns a non-2xx status code RuntimeError: For other errors """ if not METABASE_URL or not METABASE_API_KEY: raise RuntimeError("METABASE_URL or METABASE_API_KEY environment variable is not set. Metabase API requests will fail.") if session is None: raise RuntimeError("HTTP session is not initialized. Ensure app_lifespan was called.") try: request_headers = headers or {} logger.debug(f"Making {method.name} request to {METABASE_URL}{endpoint}")