Skip to main content
Glama

search_texts

Search the National Library of Norway's digital collection for texts in newspapers, books, or journals using query terms, date ranges, and media type filters.

Instructions

Search for texts in the National Library's digital collection.

Args: query: Search query string limit: Maximum number of results to return (default: 10) from_year: Start year for search period (optional) to_year: End year for search period (optional) media_type: Type of media to search. Options: 'digavis' (newspapers), 'digibok' (books), 'digitidsskrift' (journals). Default: 'digavis'

Returns: JSON string containing search results with metadata

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
limitNo
from_yearNo
to_yearNo
media_typeNodigavis

Implementation Reference

  • The search_texts tool handler, decorated with @mcp.tool() for registration. It searches texts using dhlab.Corpus based on query parameters and returns JSON results.
    @mcp.tool() def search_texts( query: str, limit: int = 10, from_year: int | None = None, to_year: int | None = None, media_type: str = "digavis", ) -> str: """Search for texts in the National Library's digital collection. Args: query: Search query string limit: Maximum number of results to return (default: 10) from_year: Start year for search period (optional) to_year: End year for search period (optional) media_type: Type of media to search. Options: 'digavis' (newspapers), 'digibok' (books), 'digitidsskrift' (journals). Default: 'digavis' Returns: JSON string containing search results with metadata """ try: # Build search parameters using correct Corpus API params = { "fulltext": query, "limit": limit, "doctype": media_type } if from_year: params["from_year"] = from_year if to_year: params["to_year"] = to_year # Perform search using dhlab corpus = dhlab.Corpus(**params) # Return corpus information if hasattr(corpus, 'corpus') and corpus.corpus is not None: return corpus.corpus.to_json(orient='records', force_ascii=False) return "No results found" except Exception as e: return f"Error searching texts: {str(e)}"

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/marksverdhei/dhlab-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server