geocode
Convert addresses into geographic coordinates using Naver Maps data for Korean locations, supporting both Korean and English language responses.
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)The MCP tool handler for 'geocode'. Decorated with @mcp.tool for registration. Defines input schema using Pydantic Field annotations on parameters. Implements tool logic by delegating to NaverMapsClient.geocode and handling exceptions with error dict.@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, including metadata, list of addresses, status, and error handling.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 class that executes the actual Naver Maps Geocode API call, including parameter construction, HTTP request via _get, and response parsing into GeocodeResponse model.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)