geocode
Convert addresses into precise location data using Naver Maps. Ideal for finding accurate geocoordinates in Korea, supporting both Korean and English languages.
Instructions
Searches for address information related to the entered address.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| address | Yes | address to search for | |
| language | No | language used in response | kor |
Implementation Reference
- src/mcp_naver_maps/server.py:30-42 (handler)MCP tool handler and registration for the 'geocode' tool. Defines input schema with Pydantic Fields and delegates execution to NaverMapsClient.@mcp.tool(description="Searches for address information related to the entered address.") async def geocode( address: str = Field(description="address to search for", min_length=1), language: Literal["kor", "eng"] = Field("kor", description="language used in response"), ) -> GeocodeResponse | Dict: """ Returns: GeocodeResponse: An object containing metadata and a list of matching addresses """ try: return await naver_maps_client.geocode(address, language) except Exception as ex: return {"success": False, "error": str(ex)}
- src/mcp_naver_maps/models.py:20-24 (schema)Pydantic model defining the output schema for the geocode tool response.class GeocodeResponse(BaseModel): status: str = Field(description="Status of the request") meta: Meta = Field(description="Metadata of the response") addresses: List[Address] = Field(description="List of matching addresses") errorMessage: str = Field(description="Error message (only present for HTTP 500 errors)")
- Helper function in NaverMapsClient that performs the actual HTTP request to Naver's geocoding API and parses the response.async def geocode( self, query: str, language: str, page: int = 1, count: int = 10, ) -> GeocodeResponse: """ https://api.ncloud-docs.com/docs/application-maps-geocoding """ path = f"{self.MAP_BASE_URL}/map-geocode/v2/geocode" params = { "query": query, "language": language, "page": page, "count": count, } response_json = await self._get(path, self.naver_maps_headers, params) return GeocodeResponse(**response_json)