MCP Tools
MCP tool and resource registrations exposed by the ra-mcp server.
Search Tools
search_tool
Search MCP tool for Riksarkivet transcribed documents.
Provides the search_transcribed tool with pagination and formatting helpers.
register_search_tool(mcp)
Register the search tools with the MCP server.
Source code in packages/search-mcp/src/ra_mcp_search_mcp/search_tool.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | |
Formatter
PlainTextFormatter
Formatter that produces plain text without any Rich markup.
format_browse_results(browse_result, highlight_term=None, show_links=False, show_success_message=True)
Format browse results as plain text with emojis for MCP/LLM consumption.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
browse_result
|
BrowseResult containing page contexts and metadata |
required | |
highlight_term
|
Optional term to highlight in text |
None
|
|
show_links
|
bool
|
Whether to show ALTO/Image/Bildvisning links |
False
|
show_success_message
|
bool
|
Whether to show success message (ignored in plain text) |
True
|
Returns:
| Type | Description |
|---|---|
str
|
Formatted plain text browse results |
Source code in packages/search-mcp/src/ra_mcp_search_mcp/formatter.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | |
format_error_message(error_message, error_suggestions=None)
Format an error message with optional suggestions.
Source code in packages/search-mcp/src/ra_mcp_search_mcp/formatter.py
82 83 84 | |
format_no_results_message(search_result)
Generate appropriate message when no results are found.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
search_result
|
SearchResult containing keyword, offset, and total_hits |
required |
Returns:
| Type | Description |
|---|---|
str
|
Formatted no results message |
Source code in packages/search-mcp/src/ra_mcp_search_mcp/formatter.py
86 87 88 89 90 91 92 93 94 95 96 97 98 | |
format_panel(panel_content, panel_title='', panel_border_style='')
Format content as plain text without panels or borders.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
panel_content
|
str
|
Content to display |
required |
panel_title
|
str
|
Optional title |
''
|
panel_border_style
|
str
|
Ignored in plain text mode |
''
|
Returns:
| Type | Description |
|---|---|
str
|
Plain text formatted content |
Source code in packages/search-mcp/src/ra_mcp_search_mcp/formatter.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
format_search_results(search_result, maximum_documents_to_display=20, seen_pages=None)
Format search results as plain text with emojis for MCP/LLM consumption.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
search_result
|
SearchResult containing documents and metadata |
required | |
maximum_documents_to_display
|
int
|
Maximum number of documents to display |
20
|
seen_pages
|
dict[str, list[int]] | None
|
Optional dict mapping reference_code to list of already-seen page numbers. When provided, documents/snippets that were already shown are compacted or skipped. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Formatted plain text search results |
Source code in packages/search-mcp/src/ra_mcp_search_mcp/formatter.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | |
format_table(column_headers, table_rows, table_title='')
Create a plain text table without borders.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
column_headers
|
list[str]
|
List of column headers |
required |
table_rows
|
list[list[str]]
|
List of row data |
required |
table_title
|
str
|
Optional table title |
''
|
Returns:
| Type | Description |
|---|---|
str
|
Plain text formatted table |
Source code in packages/search-mcp/src/ra_mcp_search_mcp/formatter.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
format_text(text_content, style_name='')
Return plain text without any styling.
Source code in packages/search-mcp/src/ra_mcp_search_mcp/formatter.py
11 12 13 | |
highlight_search_keyword(text_content, search_keyword)
Highlight search keywords using markdown-style bold.
Source code in packages/search-mcp/src/ra_mcp_search_mcp/formatter.py
74 75 76 | |
Browse Tool
browse_tool
Browse MCP tool for Riksarkivet document pages.
Provides the browse_document tool for viewing full page transcriptions.
register_browse_tool(mcp)
Register the browse tool with the MCP server.
Source code in packages/browse-mcp/src/ra_mcp_browse_mcp/browse_tool.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
Formatter
PlainTextFormatter
Formatter that produces plain text without any Rich markup.
format_browse_results(browse_result, highlight_term=None, show_links=False, show_success_message=True, seen_page_numbers=None)
Format browse results as plain text with emojis for MCP/LLM consumption.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
browse_result
|
BrowseResult containing page contexts and metadata |
required | |
highlight_term
|
Optional term to highlight in text |
None
|
|
show_links
|
bool
|
Whether to show ALTO/Image/Bildvisning links |
False
|
show_success_message
|
bool
|
Whether to show success message (ignored in plain text) |
True
|
seen_page_numbers
|
set[int] | None
|
Optional set of page numbers already shown in this session. When provided, previously-shown pages get a one-liner stub. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Formatted plain text browse results |
Source code in packages/browse-mcp/src/ra_mcp_browse_mcp/formatter.py
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | |
format_no_results_message(search_result)
Generate appropriate message when no results are found.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
search_result
|
SearchResult containing keyword, offset, and total_hits |
required |
Returns:
| Type | Description |
|---|---|
str
|
Formatted no results message |
Source code in packages/browse-mcp/src/ra_mcp_browse_mcp/formatter.py
82 83 84 85 86 87 88 89 90 91 92 93 94 | |
format_panel(panel_content, panel_title='', panel_border_style='')
Format content as plain text without panels or borders.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
panel_content
|
str
|
Content to display |
required |
panel_title
|
str
|
Optional title |
''
|
panel_border_style
|
str
|
Ignored in plain text mode |
''
|
Returns:
| Type | Description |
|---|---|
str
|
Plain text formatted content |
Source code in packages/browse-mcp/src/ra_mcp_browse_mcp/formatter.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
format_search_results(search_result, maximum_documents_to_display=20)
Format search results as plain text with emojis for MCP/LLM consumption.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
search_result
|
SearchResult containing documents and metadata |
required | |
maximum_documents_to_display
|
int
|
Maximum number of documents to display |
20
|
Returns:
| Type | Description |
|---|---|
str
|
Formatted plain text search results |
Source code in packages/browse-mcp/src/ra_mcp_browse_mcp/formatter.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
format_table(column_headers, table_rows, table_title='')
Create a plain text table without borders.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
column_headers
|
list[str]
|
List of column headers |
required |
table_rows
|
list[list[str]]
|
List of row data |
required |
table_title
|
str
|
Optional table title |
''
|
Returns:
| Type | Description |
|---|---|
str
|
Plain text formatted table |
Source code in packages/browse-mcp/src/ra_mcp_browse_mcp/formatter.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
format_text(text_content, style_name='')
Return plain text without any styling.
Source code in packages/browse-mcp/src/ra_mcp_browse_mcp/formatter.py
11 12 13 | |
highlight_search_keyword(text_content, search_keyword)
Highlight search keywords using markdown-style bold.
Source code in packages/browse-mcp/src/ra_mcp_browse_mcp/formatter.py
74 75 76 | |
Guide Resources
tools
Riksarkivet Historical Guide MCP Server.
Provides MCP resources for accessing historical documentation about Swedish archives.
get_guide_content(filename)
Load content from specific sections of the Riksarkivet historical guide.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Markdown filename to load (e.g., '01_Domstolar.md', '02_Fangelse.md') |
required |
Returns:
| Type | Description |
|---|---|
str
|
The content of the requested guide section |
Source code in packages/guide-mcp/src/ra_mcp_guide_mcp/tools.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
get_table_of_contents()
Get the table of contents (Innehållsförteckning) for the Riksarkivet historical guide.
Source code in packages/guide-mcp/src/ra_mcp_guide_mcp/tools.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
HTR Tools
tools
Riksarkivet HTR MCP Server.
This module sets up the FastMCP server and registers the htr_transcribe tool, which delegates to a remote Gradio Space via gradio_client.
HtrResult
Bases: BaseModel
Result from an HTR transcription job.
htr_transcribe(image_urls, language='swedish', layout='single_page', export_format='alto_xml', custom_yaml=None)
async
Transcribe handwritten documents and return results as file URLs.
Sends images to the HTRflow Gradio Space for AI-powered handwritten text recognition. Returns URLs to an interactive viewer, per-page JSON transcriptions, and an archival export file.
Source code in packages/htr-mcp/src/ra_mcp_htr_mcp/tools.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
Viewer Tools
tools
Document Viewer MCP App — Tool & resource registrations.
Tools
- view_document: entry point, resolves reference code → URLs, returns transcription for the model
- load_page: fetches a single page on demand (called by View via callServerTool)
- load_thumbnails: batch-fetches thumbnail images (called by View via callServerTool)
load_page(image_url, text_layer_url, page_index)
async
Fetch a single page on demand.
Source code in packages/viewer-mcp/src/ra_mcp_viewer_mcp/tools.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
load_thumbnails(image_urls, page_indices)
async
Fetch and resize a batch of page images into thumbnails (concurrent).
Source code in packages/viewer-mcp/src/ra_mcp_viewer_mcp/tools.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
search_all_pages(text_layer_urls, term)
async
Search all pages concurrently and return per-page match counts.
Source code in packages/viewer-mcp/src/ra_mcp_viewer_mcp/tools.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |
view_document(reference_code, pages, ctx, highlight_term=None, max_pages=20)
async
View document pages with zoomable images and text layer overlays.
Source code in packages/viewer-mcp/src/ra_mcp_viewer_mcp/tools.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |