get_mesh
Retrieve specific geographic mesh data from Japan's MLIT Data Platform by providing dataset, data, mesh IDs, and mesh code to access detailed location-based information.
Instructions
メッシュに含まれるデータを取得する。
使い方:
- 事前に `search` API で対象データを特定し、レスポンスの `dataset_id`(=dataSetID)、`id`(=dataID)、
および `meshes[].id`(=meshID)を取得します。その上で、本APIに `meshCode`(メッシュコード)を指定して該当メッシュのオブジェクトを取得します。
- `meshCode` は任意の次元(例: 250m など)のメッシュコードを指定可能。該当がなければ `null` が返ります。
例:
- 人口5次メッシュ(250m)の一枚を取得:
dataset_id="dpf_population_data",
data_id="8fb65cb6-a7e3-4b15-bf17-1c71be572a9f",
mesh_id="national_sensus_250m_r2",
mesh_code="5339452932"
- 事前に `search` で必要パラメータを取得:
term="人口及び世帯" → 結果の `dataset_id`, `id`, `meshes[].id` を本APIに転用
注意:
- GraphQL定義は `mesh(dataSetID:String!, dataID:String!, meshID:String!, meshCode:String!): JSONObject`。
返却はJSONオブジェクトで、メッシュコードや指標(例: 総人口 等)が含まれます。該当しない場合は `null`。:contentReference[oaicite:1]{index=1}
- `meshCode` の粒度は自由ですが、データ側に該当レコードが存在しないと取得できません(空振り時は `null`)。:contentReference[oaicite:2]{index=2}
- 必要な `meshID` は `search` レスポンスの `meshes` 配列から選びます(例: "national_sensus_250m_r2")。:contentReference[oaicite:3]{index=3}
- 利用にはMLIT DPFのGraphQLエンドポイントとAPIキーが必要です。:contentReference[oaicite:4]{index=4}Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dataset_id | Yes | データセットID | |
| data_id | Yes | データID | |
| mesh_id | Yes | メッシュID | |
| mesh_code | Yes | メッシュコード(標準地域メッシュコード) |
Implementation Reference
- src/server.py:1434-1441 (handler)The MCP tool 'get_mesh' handler logic in 'src/server.py' which parses input arguments and calls the 'MLITClient' method.
elif name == "get_mesh": p = MeshParams.model_validate(arguments) data = await client.get_mesh( dataset_id=p.dataset_id, data_id=p.data_id, mesh_id=p.mesh_id, mesh_code=p.mesh_code, ) - src/client.py:1027-1029 (handler)The implementation of the 'get_mesh' tool logic in the 'MLITClient' class which constructs and executes the GraphQL query.
async def get_mesh(self, *, dataset_id: str, data_id: str, mesh_id: str, mesh_code: str) -> Dict[str, Any]: q = self.build_mesh(dataset_id=dataset_id, data_id=data_id, mesh_id=mesh_id, mesh_code=mesh_code) return await self.post_query(q)