search_image
Find and retrieve images by keyword with customizable filters for size, sorting, and pagination. Integrated with Naver Search MCP Server for structured, AI-optimized image search results.
Instructions
Searches for images using the given keyword. The page parameter allows for page navigation and sort='sim'/'date', filter='all'/'large'/'medium'/'small' is supported.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| display | No | ||
| filter | No | all | |
| page | No | ||
| query | Yes | ||
| sort | No | sim |
Implementation Reference
- server.py:572-587 (handler)The handler function implementing the core logic for the 'search_image' tool. It prepares API parameters including pagination, sorting, and filter, then delegates to the shared _make_api_call helper using the 'image.json' endpoint and ImageResult schema.async def search_image(query: str, display: int = 10, page: int = 1, sort: str = "sim", filter: str = "all") -> str: """ Searches for images using the given keyword. The page parameter allows for page navigation and sort='sim'/'date', filter='all'/'large'/'medium'/'small' 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). filter (str, optional): The image size filter. Default is "all" (all sizes). """ start = calculate_start(page, display) display = min(display, 100) params = {"query": query, "display": display, "start": start, "sort": sort, "filter": filter} return await _make_api_call("image.json", params, ImageResult, "Image")
- server.py:568-571 (registration)MCP tool registration decorator specifying the name 'search_image' and its description.@mcp.tool( name="search_image", description="Searches for images using the given keyword. The page parameter allows for page navigation and sort='sim'/'date', filter='all'/'large'/'medium'/'small' is supported." )
- server.py:92-96 (schema)Pydantic model defining the structure of individual image items in search results, including thumbnail URL and dimensions.class ImageItem(BaseItem): thumbnail: Optional[str] = None sizeheight: Optional[str] = None sizewidth: Optional[str] = None
- server.py:131-131 (schema)Pydantic model for the complete image search response, inheriting from SearchResultBase and containing a list of ImageItem objects.class ImageResult(SearchResultBase): items: List[ImageItem]
- server.py:348-354 (helper)Helper function used by search_image (and other tools) to compute the 'start' pagination parameter for Naver API calls.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)