search_book
Find book information on Naver using specific keywords. Adjust results by display count, page navigation, and sorting preferences for efficient search.
Instructions
Searches for book 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:399-402 (registration)Registers the 'search_book' tool with the FastMCP server using the @mcp.tool decorator, specifying name and description.@mcp.tool( name="search_book", description="Searches for book information on Naver using the given keyword. The page parameter allows for page navigation." )
- server.py:403-417 (handler)The core handler function for the 'search_book' tool. It calculates pagination parameters using 'calculate_start', prepares API parameters, and calls the shared '_make_api_call' helper to query the Naver book search API ('book.json') and format the response.async def search_book(query: str, display: int = 10, page: int = 1, sort: str = "sim") -> str: """ Searches for book 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("book.json", params, BookResult, "Book")
- server.py:68-77 (schema)Pydantic model defining the structure of individual book items in the Naver search results, used for validation and parsing in '_make_api_call'.class BookItem(BaseItem): image: Optional[str] = None author: Optional[str] = None price: Optional[str] = None discount: Optional[str] = None publisher: Optional[str] = None pubdate: Optional[str] = None isbn: Optional[str] = None description: Optional[str] = None
- server.py:129-129 (schema)Pydantic model for the overall book search response, inheriting from SearchResultBase and specifying items as List[BookItem]. Used for validating the API response.class BookResult(SearchResultBase): items: List[BookItem]
- server.py:348-355 (helper)Helper function used by search_book (and other tools) to compute the 'start' parameter for Naver API pagination, respecting the max start=1000 limit.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)