Skip to main content
Glama
kkawailab

MLIT Data Platform MCP Server

by kkawailab

get_municipality_data

Retrieve Japanese municipality data including names and codes, with filtering by prefecture or specific municipality codes and customizable field selection.

Instructions

市区町村名・市区町村コード一覧を取得する。

            使い方:
            - フィルタなし(既定): 全国すべての市区町村を返します(大量件数)。
            - 都道府県で絞り込み: pref_codes=["13"] のように都道府県コードを指定(複数可)。
            - 市区町村コードで絞り込み: muni_codes=["13101","13102"] のように6桁コードを指定(複数可)。
            - 取得フィールドを最小化: fields=["code_as_string","name"] のように必要フィールドだけ指定(クライアント最適化)。

            例:
            - 全国の市区町村(コード/名称のみ):
            pref_codes=[], muni_codes=[], fields=["code_as_string","name"]

            - 東京都の市区町村一覧:
            pref_codes=["13"], fields=["code_as_string","prefecture_code","name","katakana"]

            - 特定の市区町村コードを直接取得:
            muni_codes=["13101","13102"], fields=["code_as_string","name","romaji"]

            注意:
            - GraphQL仕様: `municipalities(muniCodes:[Any], prefCodes:[Any]): [MunicipalityClass]`。
            パラメータ未指定時は**全件**を返します(大量になるため fields での軽量化推奨)。:contentReference[oaicite:1]{index=1}
            - コードは数値/文字列どちらでも指定可能ですが、アプリ側で扱いやすいのは **6桁の文字列** `code_as_string` です(例: "13101")。:contentReference[oaicite:2]{index=2}
            - 返却クラス `MunicipalityClass` には、`name`(郡名/市区町村名/政令市区名を組み合わせた正式名称)、`katakana`、`romaji`、`prefecture_code`、および有効期間(`used_from`/`used_until`)等が含まれます。:contentReference[oaicite:3]{index=3}
            - 政令指定都市の区は**独立したエントリ**として返ります(例: 札幌市中央区 など)。:contentReference[oaicite:4]{index=4}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pref_codesNo都道府県コードの配列 (例: ['13', '27'])
muni_codesNo市区町村コードの配列 (例: ['13101', '13102'])
fieldsNo取得するフィールド名の配列。デフォルト: ['code_as_string', 'prefecture_code', 'name']
pref_codeNo単一都道府県コード(後方互換性用)。pref_codesの使用を推奨

Implementation Reference

  • The 'get_municipality_data' tool handler, which validates input using Pydantic and then calls the client's 'get_municipalities' method.
    elif name == "get_municipality_data":
        p = GetMunicipalitiesParams.model_validate(arguments)
        data = await client.get_municipalities(
            pref_codes=p.pref_codes,
            muni_codes=p.muni_codes,
            fields=p.fields,
        )
  • The client implementation of 'get_municipalities', which constructs and posts the GraphQL query to retrieve municipality data.
    async def get_municipalities(
        self,
        pref_codes: Optional[List[str]] = None,
        muni_codes: Optional[List[str]] = None,
        *,
        fields: Optional[List[str]] = None,
    ) -> Dict[str, Any]:
        if not pref_codes and not muni_codes:
            raise ValueError("Either pref_codes or muni_codes must be provided")
    
        def q(s: str) -> str:
            return '"' + s.replace('"', '\\"') + '"'
    
        args: List[str] = []
        if pref_codes:
            pref = "[" + ", ".join(q(c) for c in pref_codes) + "]"
            args.append(f"prefCodes: {pref}")
        if muni_codes:
            muni = "[" + ", ".join(q(c) for c in muni_codes) + "]"
            args.append(f"muniCodes: {muni}")
    
        default_fields = ["code_as_string", "prefecture_code", "name"]
        out_fields = " ".join(fields if fields else default_fields)
    
        ql = f"""
        query {{
          municipalities({", ".join(args)}) {{
            {out_fields}
          }}
        }}
        """.strip()
        return await self.post_query(ql)
Behavior4/5

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

No annotations provided, but description carries full burden effectively. Warns about large result sets (大量件数) when unfiltered, specifies GraphQL specification details, explains that wards (区) are independent entries, and documents return class structure (MunicipalityClass fields) despite absence of output schema.

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?

Well-structured with clear visual hierarchy: purpose → usage patterns → concrete examples → important notes. Despite length, every section serves distinct purpose. Front-loaded with core function, followed by progressively specific implementation details. No redundant repetition of schema types.

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

Completeness4/5

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

For a 4-parameter query tool with 0 required parameters, description adequately warns about unfiltered usage returning massive datasets. Documents return structure (MunicipalityClass fields including validity periods) compensating for missing output schema. Would benefit from pagination or rate limit notes for perfect score.

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?

Schema coverage is 100% (baseline 3), but description adds significant semantic value: explains pref_codes accepts multiple prefecture codes, recommends 6-digit string format for muni_codes, documents fields parameter for client-side optimization, and clarifies via examples that empty arrays return all data.

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

Purpose5/5

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

Opening line '市区町村名・市区町村コード一覧を取得する' provides specific verb (取得する/get) and resource (市区町村名・コード一覧). Clearly distinguishes from sibling get_prefecture_data by specifying municipality-level (市区町村) rather than prefecture-level (都道府県) data.

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

Usage Guidelines4/5

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

Extensive '使い方' section explains exactly when to use each parameter pattern (no filter for national data, pref_codes for prefecture filtering, muni_codes for specific municipalities). Provides concrete examples for each scenario. Lacks explicit comparison to sibling tools like get_prefecture_data, but parameter-level guidance is exemplary.

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

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