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

Hong Kong Open Data MCP Server

Official

list_datasets

Retrieve dataset IDs from Hong Kong's official open data portal to explore available public data resources with customizable language and pagination options.

Instructions

Get a list of dataset IDs from data.gov.hk

Args: limit: Maximum number of datasets to return (default: 1000) offset: Offset of the first dataset to return language: Language code (en, tc, sc)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
languageNoen
limitNo
offsetNo

Implementation Reference

  • Handler function for list_datasets tool. Decorated with @mcp.tool which registers it with the FastMCP server. Retrieves list of dataset IDs from data.gov.hk API using package_list endpoint, supporting limit, offset, and language parameters.
    @mcp.tool async def list_datasets( limit: Optional[int] = None, offset: Optional[int] = None, language: str = "en" ) -> List[str]: """ Get a list of dataset IDs from data.gov.hk Args: limit: Maximum number of datasets to return (default: 1000) offset: Offset of the first dataset to return language: Language code (en, tc, sc) """ base_url = BASE_URLS.get(language, BASE_URLS["en"]) url = f"{base_url}/package_list" params = {} if limit is not None: params["limit"] = limit if offset is not None: params["offset"] = offset 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')}")
  • Helper function used by list_datasets (and other tools) to perform HTTP GET requests to the data.gov.hk API endpoints.
    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()
  • Constant mapping language codes to data.gov.hk API base URLs, used by list_datasets to construct the correct API endpoint.
    # Base URLs for the data.gov.hk API BASE_URLS = { "en": "https://data.gov.hk/en-data/api/3/action", "tc": "https://data.gov.hk/tc-data/api/3/action", "sc": "https://data.gov.hk/sc-data/api/3/action", }

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