home / mcp / kb mcp server

KB MCP Server

Provides access to KB’s open APIs for national library data, culture, research, and linked data via a centralized MCP server.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "isakskogstad-kb-mcp": {
      "url": "https://your-service.onrender.com/mcp"
    }
  }
}

You can access Sweden’s national library API ecosystem through the MCP server, enabling unified queries across libraries, cultural heritage objects, publications, and authority vocabularies. This server consolidates data sources like Libris, K-samsök, Swepub, and id.kb.se, and exposes a coherent set of tools you can use from a client to search, retrieve, and export metadata.

How to use

Connect to the MCP server from your client (HTTP) or run it locally (stdio) to access tools that search bibliographic records, artefacts, publications, authorities, and linked data. You can perform full-text searches, retrieve specific records, run advanced queries, export bibliographies, and explore data with SPARQL and demographic prompts. Use the HTTP endpoint for remote access or run the local Python server to host the API on your machine.

How to install

Prerequisites you need before installation: Python 3.8+ and pip. You may also want a virtual environment to isolate dependencies.

# Clone or download the project
# Replace with your actual path
cd kb-mcp-server

# Create a virtual environment (recommended)
python -m venv venv
source venv/bin/activate  # Linux/Mac
# or: venv\Scripts\activate  # Windows

# Install dependencies
pip install -r requirements.txt

# Run tests
python test_kb_mcp.py

For Claude Desktop configuration (Mac), add an MCP server entry to Claude’s config to run the local server from the editor:

{
  "mcpServers": {
    "kb-api": {
      "command": "python",
      "args": ["kb_mcp_server.py"],
      "cwd": "/full/path/to/kb-mcp-server"
    }
  }
}

Remote deployment using Render:

# Push to GitHub

# In Render, create a new Web Service using this repository
Build Command: pip install -r requirements.txt
Start Command: python kb_mcp_server.py --http --port $PORT
```
"https://your-service.onrender.com" will be your service URL.

Dockerize the server for local experimentation:

docker build -t kb-mcp-server .
docker run -p 8000:8000 kb-mcp-server

Additional notes

The server exposes multiple endpoints for health, information, and streaming messages via MCP. Use the public URL or run the stdio version locally to access the full set of tools.

Troubleshooting and tips

If you run into port or networking issues, ensure the port specified in the Start Command is open and not blocked by a firewall. When running locally, verify your Python environment is activated and dependencies from requirements.txt are installed.

Examples of usage

Hitting Libris and K-samsök endpoints is straightforward via your MCP client. For example, you can search for authors, fetch records, or retrieve related works across multiple data sources using the unified toolset.

Available tools

libris_search

Fritextsökning för Libris bibliotekscatalogen

libris_search_author

Sök efter författare i Libris

libris_search_title

Sök efter titel i Libris

libris_search_subject

Sök efter ämne i Libris

libris_search_isbn

Sök efter bok- eller dokument-ISBN i Libris

libris_get_record

Hämta specifik Libris post

libris_find

Avancerad sökning i Libris med operatorer

libris_get_holdings

Hämta biblioteksbestånd för ett verk eller post

libris_get_work

Hämta alla utgåvor av ett verk

libris_autocomplete

Sökförslag i Libris

libris_related

Relaterade verk i Libris

ksamsok_search

CQL-sökning i K-samsök

ksamsok_search_location

Geografisk sökning i K-samsök

ksamsok_search_type

Sök efter objekttyp i K-samsök

ksamsok_search_time

Sök efter tidsperiod i K-samsök

ksamsok_get_object

Hämta specifikt objekt i K-samsök

ksamsok_get_relations

Objektrelationer i K-samsök

ksamsok_statistics

Statistik och facetter i K-samsök

oaipmh_list_records

Lista poster i OAI-PMH

oaipmh_get_record

Hämta enskild post i OAI-PMH

oaipmh_list_sets

Tillgängliga sets i OAI-PMH

oaipmh_list_formats

Metadataformat i OAI-PMH

oaipmh_resume

Paginering i OAI-PMH

kb_data_list_collections

Lista samlingar i data.kb.se

kb_data_get_item

Hämta objekt från data.kb.se

kb_data_search

Sök digitaliserat material i data.kb.se

kb_data_get_manifest

IIIF-manifest från data.kb.se

kb_data_get_metadata

Metadata i olika format från data.kb.se

swepub_search

Sök publikationer i Swepub

swepub_search_author

Sök efter forskare i Swepub

swepub_search_affiliation

Sök efter lärosäte i Swepub

swepub_search_subject

Sök efter ämne i Swepub

swepub_get_publication

Hämta publikation i Swepub

swepub_export

Exportera till RIS/BibTeX i Swepub

idkb_get_entity

Hämta entitet i id.kb.se

idkb_search

Sök auktoriteter i id.kb.se

idkb_get_vocab_term

Hämta vokabulärterm i id.kb.se

idkb_list_vocab

Lista vokabulär i id.kb.se

sparql_query

Kör SPARQL SELECT queries i Sparql

sparql_describe

Beskriv resursen i Sparql

sparql_count

Räkna SPARQL-resultat

sparql_templates

Frågemallar för SPARQL

export_author_bibliography

Författarbibliografi export

export_subject_bibliography

Ämnesbibliografi export

export_search_results

Exportera sökresultat

export_publication_list

Skapa publikationslista

export_formats_info

Information om format

kb_api_info

Översikt över alla API:er

kb_api_status

Kontrollera serverstatus

kb_search_tips

Sök- tips och syntax

kb_data_dictionary

Datadefinitioner

kb_example_queries

Exempelfrågor

combined_search

Sök i flera databaser samtidigt

quick_stats

Snabbstatistik från alla API:er

find_related_works

Hitta relaterade verk

historical_periods_search

Sök efter historisk period

swedish_counties_info

Lista svenska län