Skip to main content
Glama
kb-newspapers-mcp

kb-newspapers-mcp

by tobbaz

KB Historical Newspapers MCP Server

A Model Context Protocol (MCP) server that provides AI assistants (such as Claude Desktop, Antigravity, Cursor, and other MCP-compliant clients) with direct programmatic access to the National Library of Sweden's (Kungliga biblioteket / KB) digitized historical newspapers from the 17th century up to 1876.

Built in Python using FastMCP and uv.


Dataset Scope & Limitations

IMPORTANT

API Coverage Ends at 1876:

  • Kungliga biblioteket's open data API (https://data.kb.se/search) currently indexes digitized historical newspapers from 1645 up to and including 1876 (~2.2 million pages).

  • Any search with date filters after 1876 (e.g. from_date="1880") will return 0 hits in this API.

  • For 1877–1906: While Swedish newspapers older than ~115 years are in the public domain and freely browsable on the web portal at tidningar.kb.se, the post-1876 collection has not yet been ingested into KB's open REST API.

  • Modern newspapers (post-1906): In copyright and restricted to library terminals.


Related MCP server: KB MCP Server

Key Features

  • 🔍 Full-Text Search (OCR): Search across more than 2.2 million historical newspaper pages (1645–1876) with highlighted text snippets (<em>...</em>) indicating matches.

  • 📅 Filtering & Sorting: Filter by year or date range (e.g. 1850 to 1875 or 1862-07-01), restrict searches to specific newspaper titles (e.g. Aftonbladet, Dagens Nyheter, Post- och Inrikes Tidningar, Göteborgsposten), and sort by relevance or publication date.

  • 📈 Timeline & Distribution: Aggregate occurrences of a word, name, or event over time (by year) or across different publications.

  • 🖼️ High-Resolution Images (IIIF): Construct direct image URLs for page previews and full-resolution scans using KB's IIIF Image API.

  • 🔗 Web Link Resolution: Bidirectional lookup between internal dataset package IDs and public article pages on tidningar.kb.se and digitalt.kb.se.

  • 🕊️ Fair-Usage & Resilience: Automated exponential backoff for HTTP 429/503 responses, friendly User-Agent headers, and sane pagination defaults.


Prerequisites

  • Python 3.10+

  • uv (recommended package manager)

To install uv on any platform, refer to the official uv installation guide, or run:

  • Linux / macOS:

    curl -LsSf https://astral.sh/uv/install.sh | sh
  • Windows (PowerShell):

    powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
  • Via Pip:

    pip install uv

Installation & Quickstart

  1. Clone the repository:

    git clone https://github.com/tobbaz/kb-newspapers-mcp.git
    cd kb-newspapers-mcp
  2. Run the server locally:

    uv run kb-newspapers-mcp
  3. Execute integration tests:

    uv run python test_server.py

Client Configuration

Claude Desktop

Add the server to your claude_desktop_config.json:

{
  "mcpServers": {
    "kb-newspapers": {
      "command": "uv",
      "args": [
        "run",
        "--directory",
        "<path-to-repo>/kb-newspapers-mcp",
        "kb-newspapers-mcp"
      ]
    }
  }
}

Antigravity / Gemini CLI (mcp_config.json)

{
  "mcpServers": {
    "kb-newspapers": {
      "command": "uv",
      "args": [
        "run",
        "--directory",
        "<path-to-repo>/kb-newspapers-mcp",
        "kb-newspapers-mcp"
      ]
    }
  }
}

(Replace <path-to-repo> with the absolute path to where you cloned this repository.)


Available Tools

1. search_newspapers

Searches OCR full text across digitized historical Swedish newspapers.

  • query (string, required): Keyword or phrase (e.g. "ångfartyg", "Carl von Linné", "August Strindberg").

  • from_date (optional): Start date ('YYYY-MM-DD' or year 'YYYY').

  • to_date (optional): End date ('YYYY-MM-DD' or year 'YYYY').

  • newspaper (optional): Filter by newspaper title (e.g. 'Aftonbladet', 'Dagens Nyheter').

  • sort_by (optional): 'relevance' (default), 'date_asc' (oldest first), or 'date_desc' (newest first).

  • limit (int, default 20, max 100): Number of hits to return.

  • offset (int, default 0): Pagination starting index.

  • max_snippets (int, default 5): Maximum text snippets to return per page.

2. get_newspaper_timeline

Retrieves aggregation statistics for a search term over time or across publications.

  • query (string, required): Search term (e.g. 'kolera').

  • field (optional): Aggregation target: 'datePublished' (by year) or 'isPartOf' (by publication title).

3. search_in_issue

Searches within an individual newspaper issue using IIIF Content Search to return exact quotes and bounding-box coordinates.

  • package_id (string, required): Issue package identifier (e.g. 'dark-37858').

  • query (string, required): Word or phrase to locate.

4. get_newspaper_page_image

Generates IIIF image URLs and web links for a given newspaper page.

  • image_service_id (optional): IIIF service URL returned from search_newspapers.

  • package_id (optional): Issue package identifier (e.g. 'dark-30466').

  • page_number (int, default 1): Page number within the issue.

  • width (int, default 1200): Desired pixel width for preview images.

5. lookup_newspaper_id

Converts bidirectionally between data.kb.se package IDs and public web URLs on tidningar.kb.se.

  • id_or_url (string, required): E.g. 'dark-37858' or 'https://tidningar.kb.se/dxqth86q2n2zwg9'.


Research Strategies & Best Practices for Historical OCR

Searching digitized newspapers from the 17th to early 20th century presents distinct challenges due to typography and historical spelling. Follow these general strategies for optimal results:

1. Gothic / Fraktur Script & OCR Glitches

Most Swedish newspapers before the late 19th century were printed in Fraktur (blackletter). OCR systems frequently misidentify character shapes:

  • Long 's' (ſ): Often transcribed as f, S, or l (e.g. Hilpershausen scanned as HilperShauftn).

  • Vowel mutations & Ligatures: Characters with umlauts or ligatures (ä, ö, æ, oe) may be parsed phonetically or stripped.

  • Similar letterforms: c vs e, rn vs m, v vs u.

2. Wildcards and Alternative Orthography

Swedish spelling was only standardized in the early 20th century. When searching names, places, or terms:

  • Wildcard search (*): Use stems (e.g. Hilp* or Söder*) to capture truncated OCR or spelling variants.

  • Boolean OR: Combine historical variations (e.g. Carlscrona OR Karlskrona, Gustaf OR Gustav, Capitain OR Kapten).

  1. Stage 1 (Discovery): Run search_newspapers with your query and date limits. Note the package_id, issue date, and page number of promising hits.

  2. Stage 2 (Deep Context): If the snippets returned in Stage 1 are truncated or lack key context (e.g. destination of a traveller, cause of death, or family connections), call search_in_issue(package_id="...", query="...") on the relevant issue to extract full verbatim sentences and surrounding text quotes.

  3. Stage 3 (Visual Verification): Open the direct image link (images.preview_width or images.max) to examine the original scanned page if the OCR text is degraded.


  • Historical Scope & API Coverage: Kungliga biblioteket's open data API (data.kb.se) provides open access to digitized newspapers from 1645 up to 1876. While public-domain newspapers up to circa 1906–1910 are viewable for free via the web viewer on tidningar.kb.se, post-1876 issues are not currently indexed in the open REST API. Later modern newspapers are protected by copyright.

  • Fair Use: The National Library implements rate throttling to ensure service availability. This server includes an identifying User-Agent and automated exponential backoff when encountering rate limits.


License

MIT License. Metadata and digitized content are provided by the National Library of Sweden (Kungliga biblioteket).

Available Tools

5 tools
get_newspaper_page_imageA
Generate direct image URLs and IIIF links for a specific newspaper page.

Args:
    image_service_id: IIIF image service URL returned from search_newspapers (e.g. 'https://data.kb.se/iiif/3/dark-30466%2Fbib4345612_18620716_0_s_0003.jp2').
    package_id: Package ID of the newspaper issue (e.g. 'dark-30466' or 'dark-37858').
    page_number: Page number within the issue (e.g. 1, 3, 4).
    part_number: Part/section number (default 1).
    width: Desired pixel width for the preview image (e.g. 1200 for readable size, 300 for thumbnail).

Inputs: width, package_id, page_number, part_number, +1 more. Returns: result

get_newspaper_timelineA
Get the temporal or newspaper distribution statistics for a search term.
Useful to discover when an event was reported most frequently or which newspapers covered it.

Args:
    query: Search term (e.g. 'kolera', 'ångbåt', 'Sveriges riksdag').
    field: Aggregation target: 'datePublished' (distribution by year) or 'isPartOf' (distribution by newspaper title).

Inputs: query (required), field. Returns: result

lookup_newspaper_idA
Convert bidirectionally between the National Library's internal package ID (e.g. 'dark-37858')
and the public web URL on tidningar.kb.se (e.g. 'https://tidningar.kb.se/dxqth86q2n2zwg9').

Args:
    id_or_url: A data.kb.se package ID, or a URL/ID from tidningar.kb.se.

Inputs: id_or_url (required). Returns: result

search_in_issueA
Search inside a specific newspaper issue to locate all occurrences of a word or phrase
with exact text lines and coordinates for image highlighting (IIIF Content Search).

Two-Stage Workflow Usage:
Use this tool as Stage 2 after 'search_newspapers' whenever a snippet is cut off or you need
the complete surrounding sentence (e.g. to uncover full names, occupations, causes of death,
travel origins/destinations, or accompanying persons).

Args:
    package_id: The package ID of the newspaper issue (e.g. 'dark-37858').
    query: Search word or phrase to locate within the issue.

Inputs: query (required), package_id (required). Returns: result

search_newspapersA
Search digitized Swedish historical newspapers (17th century to circa 1908–1910).
Performs OCR full-text search and returns page-level hits with highlighted snippets and image links.

Historical Search & OCR Strategies:
- Fraktur / Gothic Print: 17th to late 19th-century newspapers were mostly printed in Fraktur/blackletter.
  OCR engines frequently confuse similar glyphs (e.g. long 's' [ſ] misread as 'f', 'S', or 'l'; 'c' for 'e'; 'rn' for 'm').
- Historical Spelling & Wildcards: Use wildcard '*' or Boolean 'OR' to catch spelling variations
  (e.g. 'Carlscrona OR Karlskrona', 'Gustaf OR Gustav', 'Linné OR Linnaeus', or stem wildcards like 'Söder*').
- Two-Stage Workflow:
    1. Use this tool ('search_newspapers') for initial discovery of dates, issues, and page numbers.
    2. If snippets are cut off or you need surrounding sentences (e.g. destinations, causes of death, full names),
       call 'search_in_issue(package_id=..., query=...)' on the matched issue to retrieve complete verbatim quotes.
    3. Always present the 'images.preview_width' link so users can visually verify the scanned page if OCR is unclear.

Args:
    query: Search term or phrase in Swedish/English (e.g. 'ångfartyg', 'Carl von Linné', 'brand i Karlskrona').
    from_date: Start date in 'YYYY-MM-DD' format or simply year 'YYYY' (e.g. '1850').
    to_date: End date in 'YYYY-MM-DD' format or simply year 'YYYY' (e.g. '1899').
    newspaper: Filter by specific newspaper title (e.g. 'Aftonbladet', 'Dagens Nyheter', 'Post- och inrikes tidningar', 'Göteborgsposten').
    sort_by: Sort order: 'relevance' (most relevant), 'date_asc' (oldest first), or 'date_desc' (newest first).
    limit: Number of results to return per page (1-100, default 20).
    offset: Zero-based starting index for pagination (default 0).
    max_snippets: Maximum number of text snippets to include per newspaper page (default 5).

Inputs: query (required), limit, offset, sort_by, +4 more. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.4/5.0

    Scored across 5 tools

    Disambiguation5/5

    Each tool targets a separate step in the newspaper research workflow: corpus search, temporal/title aggregation, issue-level search, page image retrieval, and ID resolution. Although search_newspapers and search_in_issue both search, their scope is explicitly distinct, and the two-stage workflow clarifies when each should be used.

    Naming Consistency4/5

    All tool names use snake_case and mostly follow a clear verb + newspaper-related object pattern, such as search_newspapers, get_newspaper_timeline, and get_newspaper_page_image. The prepositional form search_in_issue and the use of lookup in lookup_newspaper_id are minor deviations, but they remain predictable and readable.

    Tool Count5/5

    Five tools form a tight, well-scoped set for a read-only historical newspaper search and display service. Each tool addresses a necessary part of the workflow without unnecessary duplication.

    Completeness4/5

    The set covers the core research loop: search, aggregate over time/title, drill into an issue, retrieve page images, and resolve identifiers. It lacks an explicit issue or page metadata browsing tool, but the search-first workflow makes this a minor gap rather than a dead end.

    Maintenance

    ActivitySlowing
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Enables users to search and access digital collections from the Swedish National Archives (Riksarkivet) through multiple APIs. Supports searching records by keywords, exploring collections, and downloading historical images and documents.
      2
      27
      Apache 2.0
    • F
      license
      Not graded
      quality
      D
      maintenance
      Provides access to Sweden's National Library (Kungliga biblioteket) open APIs, enabling search and retrieval of 20M+ bibliographic records, 10M+ cultural heritage objects, 2M+ research publications, and linked data through 52 tools across 10 endpoints.
      3
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables LLMs to search, access, and retrieve official Swedish statistics from Statistics Sweden (SCB), providing access to 1,200+ tables covering demographics, economy, environment, labor market, and education with 75+ years of historical data.
      9
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Enables Claude to search, browse, and read more than 20 million digitized historical US newspaper pages from the Library of Congress's Chronicling America archive, covering the 1700s through 1963. Queries can be filtered by date range, state, newspaper, or front pages only, and results include full OCR text with citations and links back to each scan and PDF.
      4
      MIT