The Riksarkivet MCP Server enables searching and browsing millions of transcribed historical documents from the Swedish National Archives through AI assistants and command-line tools.
Core Capabilities:
Full-text search with advanced query syntax including wildcards (*, ?), fuzzy matching (~), proximity searches, boolean operators (AND/OR/NOT), and term boosting. Results support pagination, configurable hits per document (default: 3), and toggleable context display for balancing coverage with detail.
Document browsing by reference code with support for single pages, ranges (e.g., "1-10"), or comma-separated lists. View full transcriptions with optional search term highlighting and configurable page limits (default: 20).
Document structure and metadata retrieval including reference codes, PIDs, institution information, dates, and IIIF manifest data without fetching full content.
Archive guide navigation with access to a complete guide index and specific sections covering topics like courts (Domstolar) and prisons (Fängelse).
Integration features including ALTO XML transcriptions for structured data, IIIF high-resolution images with zoom/crop capabilities, interactive web viewers (Bildvisning), and integration with Riksarkivet APIs (Search API, IIIF Collections, OAI-PMH, semantic search).
Deployment options as an MCP server for AI assistants like Claude and ChatGPT via HTTP transport, command-line interface for local usage, and containerized deployment with development tools including MCP Inspector testing and Dagger-based CI/CD.
Typical workflow: Search using keywords → Paginate through results → Browse specific pages with highlighted terms → Access original images and metadata for citations.
ra-mcp
⚠️ Work in Progress (WIP)
This repository is the result of two hackathons and is currently under development. It's more of a proof of concept than a production-ready solution. The codebase, documentation, and build processes are being continuously refined.
Please note:
Expect changes and breaking updates
APIs and interfaces may change without notice
Use in production environments at your own risk
Contributions and feedback are welcome as we work toward stability
MCPs for Riksarkivet
A MCP server and command-line tools for searching and browsing transcribed historical documents from the Swedish National Archives (Riksarkivet).
Features
Full-text search across millions of transcribed historical documents
Complete page transcriptions with accurate text extraction from historical manuscripts
Reference-based document browsing using official archive reference codes
Contextual search highlighting to identify relevant content quickly
High-resolution image access to original document scans via IIIF
Getting Started
MCP
Adding ra-mcp with streamable http for ChatGPT or Claude:
url: https://riksarkivet-ra-mcp.hf.space/mcp
Claude Code
IDEs
CLI
Install cli
How to Use
1. Search for Keywords
Find documents containing specific words or phrases:
Search Options:
--max N- Maximum search results (default: 50)--max-display N- Maximum results to display (default: 20)--max-hits-per-vol N- Maximum hits to return per volume (default: 3)
Search Types:
Type | Syntax | Example | Description |
Exact |
|
| Find exact matches |
Wildcard (single) |
|
| Matches any single character |
Wildcard (multiple) |
|
| Matches zero or more characters |
Fuzzy |
|
| Finds similar terms based on edit distance (default: 2) |
Fuzzy (custom) |
|
| Finds similar terms with max edit distance N (0-2) |
Proximity |
|
| Finds terms within N words of each other |
Boosting |
|
| Increases relevance of boosted term (default: 1) |
Boolean AND |
|
| Both terms must be present |
Boolean OR |
|
| Either term (or both) must be present |
Boolean NOT |
|
| First term without second term |
Required/Exclude |
|
| Require term (+) or exclude term (-) |
Grouping |
|
| Group clauses to form sub-queries |
2. Browse Specific Documents
When you find interesting documents, browse them directly:
Options:
--pageor--pages- Page numbers (e.g., "5", "1-10", "5,7,9")--search-term- Highlight this term in the text--max-display N- Maximum pages to display (default: 20)
Output Features
🔍 Search Results
When you run a search, results are presented with:
Document grouping - Related pages grouped together for context
Institution & dates - Archive location and document dates
Page numbers - Specific pages containing your search terms
Highlighted snippets - Preview text with keywords emphasized
Browse commands - Ready-to-run commands for deeper exploration
Example output:
🔗 Available Resources
Each result provides direct access to:
Resource | Description | Use Case |
ALTO XML | Structured transcription data with precise positioning | Text analysis, data extraction |
IIIF Images | High-resolution document scans with zoom/crop support | Visual inspection, citations |
Bildvisning | Interactive web viewer with search highlighting | Online browsing, sharing |
Collections | IIIF metadata for document series | Understanding document context |
Examples
Basic Workflow
Search for a keyword:
uv run ra search "Stockholm"Browse specific documents:
uv run ra browse "SE/RA/123456" --page "10-15" --search-term "Stockholm"
Advanced Usage
Technical Details
Riksarkivet APIs & Data Sources
This tool integrates with multiple Riksarkivet APIs to provide comprehensive access to historical documents:
Current Integrations
Search API - Primary endpoint for full-text search across transcribed materials (Documentation)
IIIF Collections - Access to digitized document collections via IIIF standard (Documentation)
ALTO XML - Structured text transcriptions with precise positioning data
IIIF Images - High-resolution document images with zoom and cropping capabilities
Bildvisning - Interactive document viewer with search highlighting
OAI-PMH - Metadata harvesting for archive records and references (Documentation)
Additional Resources
The Riksarkivet Data Platform Wiki provides comprehensive documentation for building additional MCP integrations.
Experimental Features
Förvaltningshistorik - Semantic search interface (under evaluation)
AI-Riksarkivet HTRflow - Handwritten text recognition pipeline (PyPI package)
Troubleshooting
Common Issues
No results found: Try broader search terms or check spelling
Page not loading: Some pages may not have transcriptions available
Network timeouts: Tool includes retry logic, but very slow connections may time out
Getting Help
MCP Server Development
Running the MCP Server
Testing with MCP Inspector
Use the MCP Inspector to test and debug the MCP server:
The MCP Inspector provides a web interface to test server tools, resources, and prompts during development.
Building and Publishing with Dagger
The project uses Dagger for containerized builds and publishing to Docker registries. Pre-built images are available on Docker Hub.
Prerequisites
Dagger CLI installed
Docker registry credentials (for publishing)
Available Commands
Build locally:
Run tests:
Build and publish to Docker registry:
Available Dagger Functions
build: Creates a production-ready container image using the Dockerfiletest: Runs the test suite using pytest with coverage reportingpublish: Builds and publishes container image to registry with authenticationbuild-local: Build with custom environment variables and registry settings
The Dagger configuration is located in .dagger/main.go and provides a complete CI/CD pipeline for the project.
Current MCP Server Implementation
The MCP server provides access to transcribed historical documents from the Swedish National Archives (Riksarkivet) through three primary tools and two resources:
🔧 Available Tools
1. search_transcribed
Search for keywords in transcribed materials with pagination support.
2. browse_document
Browse specific pages of a document by reference code.
📚 Available Resources
riksarkivet://contents/table_of_contents - Complete guide index (Innehållsförteckning)
riksarkivet://guide/{filename} - Specific guide sections (e.g., '01_Domstolar.md', '02_Fangelse.md')
🔄 Typical Workflow
Search →
search_transcribed("trolldom", offset=0)to find relevant documentsPaginate → Continue with
offset=50, 100, 150...for comprehensive discoveryBrowse → Use
browse_document()to view specific pages with full transcriptions
💡 Search Strategy Tips
Start with
show_context=Falseto maximize hit coverageUse pagination (increasing offsets) to find all matches
Enable
show_context=Trueonly when you need full page text for specific hitsBrowse specific pages for detailed examination with keyword highlighting