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 filters for language and pagination.

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
limitNo
offsetNo
languageNoen

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the 'list_datasets' tool. It makes an API request to the data.gov.hk package_list endpoint to retrieve a paginated list of dataset IDs. The @mcp.tool decorator registers this function as an MCP tool.
    @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 make HTTP requests to the data.gov.hk API.
    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 defining the base API URLs for different languages used by the list_datasets tool.
    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",
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the source ('data.gov.hk') but doesn't describe rate limits, authentication needs, pagination behavior, error conditions, or what the output contains beyond 'dataset IDs'. This leaves significant gaps for a tool that interacts with an external API.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured with a clear purpose statement followed by parameter explanations. Every sentence adds value, though the parameter explanations could be slightly more detailed given the lack of schema descriptions.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has an output schema (which handles return values), 3 parameters with 0% schema coverage, and no annotations, the description does an adequate job explaining parameters but lacks behavioral context about API interactions, error handling, and usage guidelines relative to siblings. It's minimally viable but has clear gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds meaningful context for all three parameters beyond the schema (which has 0% description coverage). It explains that 'limit' controls maximum results with a default, 'offset' provides pagination starting point, and 'language' accepts specific codes. This adequately compensates for the schema's lack of descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Get') and resource ('list of dataset IDs from data.gov.hk'), making the purpose specific and understandable. However, it doesn't explicitly differentiate from sibling tools like 'list_categories' or 'search_datasets', which would require a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'search_datasets' or 'get_datasets_by_format'. It simply describes what the tool does without context about appropriate use cases or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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