search_encyclopedia
Retrieve detailed encyclopedia entries from Naver using specific keywords, with options to control display results, pagination, and sorting for precise information access.
Instructions
Searches for encyclopedia information on Naver using the given keyword. The page parameter allows for page navigation.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| display | No | ||
| page | No | ||
| query | Yes | ||
| sort | No | sim |
Implementation Reference
- server.py:438-451 (handler)Main handler function executing the tool logic: computes start index for pagination, caps display at 100, prepares API parameters, and invokes the shared _make_api_call for Naver encyclopedia search.async def search_encyclopedia(query: str, display: int = 10, page: int = 1, sort: str = "sim") -> str: """ Searches for encyclopedia information on Naver using the given keyword. The page parameter allows for page navigation. 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("encyc.json", params, EncycResult, "Encyclopedia")
- server.py:434-437 (registration)Registration of the tool using @mcp.tool decorator with name and description.@mcp.tool( name="search_encyclopedia", description="Searches for encyclopedia information on Naver using the given keyword. The page parameter allows for page navigation." )
- server.py:106-109 (schema)Pydantic schema for individual encyclopedia item: extends BaseItem with thumbnail and description fields.class EncycItem(BaseItem): thumbnail: Optional[str] = None description: Optional[str] = None
- server.py:133-133 (schema)Pydantic schema for encyclopedia search results: inherits SearchResultBase with items as list of EncycItem.class EncycResult(SearchResultBase): items: List[EncycItem]
- server.py:348-355 (helper)Helper function to calculate the 'start' parameter for paginated Naver API calls, clamping to max 1000.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)