get_dataset_details
Retrieve comprehensive metadata and tracking information for specific datasets from Hong Kong's official open data portal using dataset ID and language preferences.
Instructions
Get detailed information about a specific dataset
Args: dataset_id: The ID or name of the dataset to retrieve language: Language code (en, tc, sc) include_tracking: Add tracking information to dataset and resources
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dataset_id | Yes | ||
| language | No | en | |
| include_tracking | No |
Implementation Reference
- src/mcp_open_data_hk/server.py:60-85 (handler)The core handler function for the 'get_dataset_details' tool, registered via @mcp.tool decorator. Fetches dataset details from data.gov.hk using the package_show API endpoint, with optional language and tracking parameters.@mcp.tool async def get_dataset_details( dataset_id: str, language: str = "en", include_tracking: bool = False ) -> Dict[str, Any]: """ Get detailed information about a specific dataset Args: dataset_id: The ID or name of the dataset to retrieve language: Language code (en, tc, sc) include_tracking: Add tracking information to dataset and resources """ base_url = BASE_URLS.get(language, BASE_URLS["en"]) url = f"{base_url}/package_show" params = {"id": dataset_id} if include_tracking: params["include_tracking"] = "true" result = await make_api_request(url, params) if result.get("success"): return result["result"] else: raise Exception(f"API Error: {result.get('error', 'Unknown error')}")
- src/mcp_open_data_hk/server.py:19-30 (helper)Helper utility function used by get_dataset_details (and other tools) to make asynchronous HTTP GET requests to the data.gov.hk API, handling errors and returning JSON.async def make_api_request( url: str, params: Optional[Dict[str, Any]] = None ) -> Dict[str, Any]: """Make an API request to data.gov.hk""" async with httpx.AsyncClient() as client: # Print the request for debugging print(f"Making request to {url} with params {params}") response = await client.get(url, params=params) print(f"Response status: {response.status_code}") response.raise_for_status() return response.json()