Riksdagen MCP Server

by amrtini

247 downloads
Not rated
GitHub

Description

# Riksdagen MCP Server This project implements a Model Context Protocol (MCP) server that allows Claude to search the Swedish Parliament (Riksdagen) document archive and retrieve URLs in JSON format. The project is generetad using Claude 3.7. ## Overview The Riksdagen MCP server…

About

# Riksdagen MCP Server This project implements a Model Context Protocol (MCP) server that allows Claude to search the Swedish Parliament (Riksdagen) document archive and retrieve URLs in JSON format. The project is generetad using Claude 3.7. ## Overview The Riksdagen MCP server provides tools for searching documents…

Details

Author
amrtini
Downloads
247
Categories
Other

- Search the Riksdagen archive by keyword, document type, and date
- Retrieve a list of available document type codes and descriptions
- Create URL lists for specific documents in JSON, HTML, or text format
- Output results as structured JSON for easy programmatic use
- Sort results by relevance, date, or document designation
- Limit the number of returned documents (default 10)

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Riksdagen MCP Server
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Install by cloning the repository, creating a Python 3.9+ virtual environment, and installing dependencies (FastAPI, Uvicorn, httpx, MCP Python SDK). Start the server with uvicorn mcp_riksdagen_server:app --host 0.0.0.0 --port 8000 --reload. Claude can then invoke its three MCP tools: riksdagen_search, riksdagen_get_document_types, and riksdagen_create_url_list using parameters like search term, document type, parliamentary year, date range, sort order, and format.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "riksdagen mcp server": {
            "riksdagen-mcp-server": {
                "type": "http",
                "url": "http://localhost:8000"
            }
        }
    }
}

McpServers

{
    "riksdagen-mcp-server": {
        "type": "http",
        "url": "http://localhost:8000"
    }
}

Riksdagen MCP Server

This project implements a Model Context Protocol (MCP) server that allows Claude to search the Swedish Parliament (Riksdagen) document archive and retrieve URLs in JSON format.
The project is generetad using Claude 3.7.

Overview

The Riksdagen MCP server provides tools for searching documents in the Swedish Parliament's open data archive. It allows Claude to:

1. Search for documents based on various criteria (keywords, document types, dates, etc.)
2. Get a list of available document types
3. Create lists of URLs for specific documents in various formats (JSON, HTML, text)

Prerequisites

- Python 3.9+
- FastAPI
- Uvicorn
- MCP Python SDK
- httpx

Installation

1. Clone this repository:

   git clone https://github.com/amrtini/riksdagen-mcp-server.git
cd riksdagen-mcp-server

2. Create a virtual environment:

   python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate

3. Install dependencies:

   pip install fastapi uvicorn httpx mcp

Note: You might need to install the MCP Python SDK directly from its repository:

   pip install git+https://github.com/modelcontextprotocol/python-sdk.git

Running the Server

1. Start the MCP server:

   uvicorn mcp_riksdagen_server:app --host 0.0.0.0 --port 8000 --reload

2. The server will be available at http://localhost:8000

MCP Tools

The server provides the following MCP tools:

1. riksdagen_search

Search for documents in the Riksdagen archive based on various criteria.

Parameters:
- sok: Search term (optional)
- doktyp: Document type (optional, e.g. "prop", "mot", "bet")
- rm: Parliamentary year (optional, e.g. "2021/22")
- from_date: From date in YYYY-MM-DD format (optional)
- tom: To date in YYYY-MM-DD format (optional)
- sort: Sort order (optional, default: "rel", options: "rel", "datum", "beteckning")
- sortorder: Sort direction (optional, default: "desc", options: "desc", "asc")
- limit: Maximum number of results to return (optional, default: 10)

Returns:
A JSON object containing document URLs and metadata.

2. riksdagen_get_document_types

Get a list of available document types in the Riksdagen archive.

Returns:
A dictionary mapping document type codes to their descriptions.

3. riksdagen_create_url_list

Create a list of URLs for Riksdagen documents in the specified format.

Parameters:
- document_ids: List of document IDs
- format: Format of the documents (default: "json", options: "json", "html", "text")

Returns:
A JSON object containing document URLs.

Using with Claude

Claude can use this MCP server to search for documents in the Riksdagen archive and generate URL lists for further processing. The example client demonstrates how to interact with the server.

Example Claude Prompt

I want to search for documents in the Swedish Parliament archive about climate change (klimat in Swedish) from the last year. Can you help me find relevant motions and create a list of URLs to access them?

Claude can then use the MCP tools to:
1. Search for documents with the term "klimat"
2. Filter for motion documents (doktyp="mot")
3. Set the parliamentary year to the current one
4. Create a list of URLs for the found documents

Using the Client

The included client demonstrates how to interact with the MCP server programmatically:

```python

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.