Skip to main content
Glama
kkawailab

MLIT Data Platform MCP Server

by kkawailab

get_suggest

Generate keyword suggestions for data searches on Japan's MLIT Data Platform by entering partial terms, with options to filter by location, catalog, or dataset.

Instructions

キーワード検索の候補を表示する。

            使い方:
            - 入力中の文字列(term)から、上位のキーワード候補を返します。候補は `name`(候補語)と `cnt`(該当件数)を含みます。
            - 完全一致寄りにしたい場合は phrase_match=True を指定します。
            - カタログ/データセット等で範囲を絞って候補を出すことも可能です(search と同様に attributeFilter 相当を利用)。

            例:
            - 単純サジェスト(全データ対象):
            term="川", phrase_match=True
            → 上位候補(例: "川河川", "河川", ...)が name/cnt で返る。

            - 特定データセット内でのサジェスト:
            term="川", phrase_match=True, dataset_id="cals_construction"

            - カタログ単位でのサジェスト:
            term="橋", catalog_id="dimaps"

            注意:
            - term は必須です(空文字は不可)。
            - 本APIは GraphQL `suggest(term, phraseMatch, attributeFilter?)` を使用します。属性での絞り込みは
            本ツールの引数(catalog_id / dataset_id / prefecture_code / municipality_code / address)を
            内部で attributeFilter にマッピングして行います。
            - 返却される候補は name と cnt を含む配列です(例は公式サンプル参照)。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
termYes検索キーワードの一部。例: 'バス' → 'バス停', 'バスロケ' などを提案
phrase_matchNoフレーズマッチモード
prefecture_codeNo都道府県コードで絞り込み
municipality_codeNo市区町村コードで絞り込み
addressNo住所で絞り込み
catalog_idNoカタログIDで絞り込み
dataset_idNoデータセットIDで絞り込み
location_rectangle_top_left_latNo矩形範囲の左上緯度
location_rectangle_top_left_lonNo矩形範囲の左上経度
location_rectangle_bottom_right_latNo矩形範囲の右下緯度
location_rectangle_bottom_right_lonNo矩形範囲の右下経度

Implementation Reference

  • The `get_suggest` tool handler in `src/server.py` processes the request, normalizes arguments using `_auto_normalize_region_args`, and calls `client.suggest(p)`.
    elif name == "get_suggest":
        arguments = await _auto_normalize_region_args(arguments, client)
        p = SuggestInput.model_validate(arguments)
        data = await client.suggest(p)
  • The `MLITClient.suggest` method in `src/client.py` constructs the suggest query using helper methods and sends it to the GraphQL API via `post_query`.
    async def suggest(self, params: SuggestInput) -> Dict[str, Any]:
        attr_filter = self.make_attribute_filter_for_countdata(
            prefecture_code=params.prefecture_code,
            municipality_code=params.municipality_code,
            address=params.address,
            catalog_id=params.catalog_id,
            dataset_id=params.dataset_id,
        )
    
        loc_filter = None
        if all(v is not None for v in [
            params.location_rectangle_top_left_lat,
            params.location_rectangle_top_left_lon,
            params.location_rectangle_bottom_right_lat,
            params.location_rectangle_bottom_right_lon
        ]):
            loc_filter = self.make_rectangle_filter(
                float(params.location_rectangle_top_left_lat),   # type: ignore
                float(params.location_rectangle_top_left_lon),   # type: ignore
                float(params.location_rectangle_bottom_right_lat),  # type: ignore
                float(params.location_rectangle_bottom_right_lon),  # type: ignore
            )
    
        q = self.build_suggest(
            term=params.term,
            phrase_match=params.phrase_match,
            attribute_filter=attr_filter,
            location_filter=loc_filter,
        )
        return await self.post_query(q)
  • The `MLITClient.build_suggest` method in `src/client.py` constructs the raw GraphQL query string for the suggest API.
    def build_suggest(
        self,
        *,
        term: str,
        phrase_match: Optional[bool] = None,
        attribute_filter: Optional[str] = None,
        location_filter: Optional[str] = None,
    ) -> str:
        parts: List[str] = []
    
        def q(s: str) -> str:
            return '"' + s.replace('"', '\\"') + '"'
    
        parts.append(f"term: {q(term)}")
        if phrase_match is not None:
            parts.append(f'phraseMatch: {"true" if phrase_match else "false"}')
        if location_filter:
            parts.append(f"locationFilter: {location_filter}")
        if attribute_filter:
            parts.append(f"attributeFilter: {attribute_filter}")
    
        return f"""
        query {{
          suggest({", ".join(parts)}) {{
            totalNumber
            suggestions {{
              name
              cnt
            }}
          }}
        }}
        """.strip()

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/kkawailab/kklab-mlit-dpf-mcp'

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