search_cafe_article
Find relevant cafe articles on Naver by entering a keyword. Customize results with display count, page navigation, and sorting by relevance or date for targeted search.
Instructions
Searches for cafe articles on Naver using the given keyword. The page parameter allows for page navigation and sort='sim'/'date' is supported.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| display | No | ||
| page | No | ||
| query | Yes | ||
| sort | No | sim |
Implementation Reference
- server.py:458-472 (handler)The main handler function implementing the search_cafe_article tool. It handles pagination, parameter limits, and delegates to the shared _make_api_call helper to fetch and format Naver cafe article search results.async def search_cafe_article(query: str, display: int = 10, page: int = 1, sort: str = "sim") -> str: """ Searches for cafe articles on Naver using the given keyword. The page parameter allows for page navigation and sort='sim'/'date' is supported. Args: query (str): The keyword to search for display (int, optional): The number of results to display. Default is 10. page (int, optional): The starting page number. Default is 1. sort (str, optional): The sorting criteria. Default is "sim" (similarity). """ start = calculate_start(page, display) display = min(display, 100) params = {"query": query, "display": display, "start": start, "sort": sort} return await _make_api_call("cafearticle.json", params, CafeArticleResult, "Cafe Article")
- server.py:454-457 (registration)MCP tool registration decorator defining the tool name, description, and associating it with the handler function.@mcp.tool( name="search_cafe_article", description="Searches for cafe articles on Naver using the given keyword. The page parameter allows for page navigation and sort='sim'/'date' is supported." )
- server.py:58-61 (schema)Pydantic model defining the structure of individual cafe article items in search results, extending DescriptionItem with cafe-specific fields.class CafeArticleItem(DescriptionItem): cafename: Optional[str] = None cafeurl: Optional[str] = None
- server.py:125-125 (schema)Pydantic model for the overall cafe article search response, specifying items as a list of CafeArticleItem.class CafeArticleResult(SearchResultBase): items: List[CafeArticleItem]
- server.py:348-355 (helper)Helper function to compute the 'start' parameter for paginated Naver API calls, respecting API limits.def calculate_start(page: int, display: int) -> int: """Calculates the start value for the API call based on the page number and display count.""" if page < 1: page = 1 start = (page - 1) * display + 1 # 네이버 API의 start 최대값(1000) 제한 고려 return min(start, 1000)