Skip to main content
Glama
mcp-open-data-hk

Hong Kong Open Data MCP Server

Official

get_datasets_by_format

Find Hong Kong government datasets available in specific file formats like CSV, JSON, or GeoJSON to access open data resources that match your technical requirements.

Instructions

Get datasets that have resources in a specific file format.

Args: file_format: The file format to filter by (e.g., "CSV", "JSON", "GeoJSON") limit: Maximum number of datasets to return language: Language code (en, tc, sc)

Returns: A dictionary containing: - count: Total number of matching datasets - results: List of matching datasets

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_formatYes
languageNoen
limitNo

Implementation Reference

  • The handler function for the 'get_datasets_by_format' tool. It uses the data.gov.hk package_search API with a 'res_format' filter to find datasets matching the specified file format. The @mcp.tool decorator registers this function as an MCP tool.
    @mcp.tool async def get_datasets_by_format( file_format: str, limit: int = 10, language: str = "en" ) -> Dict[str, Any]: """ Get datasets that have resources in a specific file format. Args: file_format: The file format to filter by (e.g., "CSV", "JSON", "GeoJSON") limit: Maximum number of datasets to return language: Language code (en, tc, sc) Returns: A dictionary containing: - count: Total number of matching datasets - results: List of matching datasets """ # Using package_search API with format filter base_url = BASE_URLS.get(language, BASE_URLS["en"]) url = f"{base_url}/package_search" # Create a query that filters by format query = f"res_format:{file_format}" params = {"q": query, "rows": min(limit, 1000), "start": 0} result = await make_api_request(url, params) if result.get("success"): search_result = result["result"] return { "count": search_result.get("count", 0), "results": search_result.get("results", []), } else: raise Exception(f"API Error: {result.get('error', 'Unknown error')}")

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mcp-open-data-hk/mcp-open-data-hk'

If you have feedback or need assistance with the MCP directory API, please join our Discord server