search_images
Search the National Library's digital collection for images using keywords and optional year filters to find historical or cultural visual materials.
Instructions
Search for images in the National Library's digital collection.
Args: query: Search query string limit: Maximum number of results (default: 10) from_year: Start year (optional) to_year: End year (optional)
Returns: JSON string containing image search results with URLs
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| limit | No | ||
| from_year | No | ||
| to_year | No |
Implementation Reference
- src/dhlab_mcp/server.py:242-271 (handler)The main handler function for the 'search_images' tool. It is decorated with @mcp.tool() for registration and implements the logic to search images using dhlab.images.nbpictures.find_urls, returning JSON results or error messages.@mcp.tool() def search_images( query: str, limit: int = 10, from_year: int | None = None, to_year: int | None = None, ) -> str: """Search for images in the National Library's digital collection. Args: query: Search query string limit: Maximum number of results (default: 10) from_year: Start year (optional) to_year: End year (optional) Returns: JSON string containing image search results with URLs """ try: from dhlab.images.nbpictures import find_urls # find_urls returns a list of URLs results = find_urls(term=query, number=limit, mediatype="bilder") if results is not None and len(results) > 0: import json return json.dumps(results, ensure_ascii=False) return "No images found" except Exception as e: return f"Error searching images: {str(e)}"