search_by_category
Find nearby places by category within a specified radius from a central location using Kakao Local API. Filter results for restaurants, cafes, hospitals, schools, parking lots, and other location types in Korea.
Instructions
Searches for places with matching category group code
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category_group_code | Yes | category used to search for places (CategoryGroupCode resource) | |
| center_coordinate | Yes | longitude and latitude of a center | |
| radius_from_center | Yes | search radius from the center in meters | |
| page | No | page number of result |
Implementation Reference
- src/mcp_kakao_local/server.py:100-121 (handler)MCP tool handler and registration for 'search_by_category'. Includes input schema via Pydantic Fields (category_group_code, center_coordinate, radius_from_center, page) and executes by calling the client helper, with error handling.@mcp.tool(description="Searches for places with matching category group code") async def search_by_category( category_group_code: CategoryGroupCode = Field( description="category used to search for places (CategoryGroupCode resource)" ), center_coordinate: Coordinate = Field(description="longitude and latitude of a center"), radius_from_center: int = Field(description="search radius from the center in meters", gt=0), page: int = Field(1, description="page number of result", ge=1), ) -> LocationSearchResponse: """ Returns: LocationSearchResponse: An object containing metadata and a list of places. """ try: return await kakao_local_client.search_by_category( category_group_code, center_coordinate, radius_from_center, page=page, ) except Exception as ex: return {"success": False, "error": str(ex)}
- Core helper function in KakaoLocalClient that performs the actual API call to Kakao's /search/category endpoint using httpx, constructs parameters, and parses response into LocationSearchResponse model.async def search_by_category( self, category_group_code: CategoryGroupCode, center: Coordinate, radius: int, page: int = 1, size: int = 10, sort_option: LocationSortOption = LocationSortOption.ACCURACY, ) -> LocationSearchResponse: """https://developers.kakao.com/docs/latest/ko/local/dev-guide#search-by-category""" path = f"{self.BASE_URL}/search/category" params = { "category_group_code": category_group_code.name, "x": center.longitude, "y": center.latitude, "radius": radius, "page": page, "size": size, "sort": sort_option.value, } response_json = await self._get(path, params) return LocationSearchResponse(**response_json)