Sponsored by Deepsite.site

Riksbanken MCP Server

Created By
aerugo8 months ago
An MCP Server for Riksbank data (monetary policy, SWEA, SWESTR)
Content

Riksbanken MCP Server

An MCP Server for accessing macroeconomic and financial data from the Riksbank. This server provides tools for retrieving data about monetary policy forecasts, exchange and interest rate data (via SWEA), and short-term money market rates (via SWESTR). It is built using asynchronous programming with httpx and uses pydantic for data validation.

Features

  • Monetary Policy Tools

    • List all monetary policy rounds.
    • Retrieve forecast data for key economic indicators (GDP, unemployment, CPI, CPIF, CPIF ex-energy, hourly labour cost, wages (NA and NMO), population, employment, labour force).
  • SWEA Tools

    • Fetch the official policy (repo) rate.
    • Retrieve exchange rate series (USD/SEK, EUR/SEK, GBP/SEK).
    • Retrieve average mortgage interest rates.
  • SWESTR Tools

    • Retrieve daily SWESTR (Swedish Short Term Rate) and its latest published value.
    • Retrieve compounded averages (e.g., 1-week, 1-month).
  • Modern, Asynchronous, and Type-Safe

    • Fully asynchronous, using Python 3.13's async/await and httpx for network requests.
    • Uses pydantic models for robust data validation and self-documenting API responses.

Installation

Ensure you have Python 3.13 or higher installed. Then, install the package in editable mode:

pip install -e .

This will install the required dependencies as specified in pyproject.toml (including mcp, httpx, and pydantic).

Running the Server

Using the CLI

After installation, you can launch the MCP server with the CLI command:

riksbanken-mcp

Via Python Module

Alternatively, run the server directly using:

python -m riksbank_mcp.server

The server uses the stdio transport to communicate and registers all MCP tools.

Repository Structure

riksbank_mcp/
├── __init__.py             # Package version and initialization
├── server.py               # Main MCP server entry point and tool registration
├── models.py               # Pydantic models for API responses and data validation
├── services/
│   ├── __init__.py         # Services package initialization
│   ├── monetary_policy_api.py  # Helper for the Monetary Policy API
│   ├── swea_api.py         # Helper for the SWEA API
│   └── swestr_api.py       # Helper for the SWESTR API
├── tools/
│   ├── __init__.py         # Tools package initialization
│   ├── monetary_policy_tools.py  # Tools for Monetary Policy data
│   ├── swea_tools.py       # Tools for SWEA data (policy rate, exchange rates, mortgage rate)
│   └── swestr_tools.py     # Tools for SWESTR data (short term rates and averages)
└── pyproject.toml          # Build and dependency configuration

Usage Examples

Example: Fetching GDP Forecast Data

import asyncio
from riksbank_mcp.tools.monetary_policy_tools import get_gdp_data

async def main():
    # Retrieve forecast data for GDP for a specific policy round.
    gdp_forecast = await get_gdp_data("2023:4")
    for obs in gdp_forecast.observations:
        print(f"Date: {obs.date}, GDP forecast: {obs.value} (billion SEK)")

asyncio.run(main())

Example: Retrieving the Latest SWESTR Rate

import asyncio
from riksbank_mcp.tools.swestr_tools import get_latest_swestr

async def main():
    latest = await get_latest_swestr()
    print(f"Latest SWESTR: {latest.date} - {latest.value}%")

asyncio.run(main())

Example: Retrieving USD/SEK Exchange Rates

import asyncio
from riksbank_mcp.tools.swea_tools import get_usd_exchange_rate

async def main():
    usd_data = await get_usd_exchange_rate()
    for obs in usd_data.observations[-5:]:
        print(f"{obs.date}: {obs.value} SEK per USD")

asyncio.run(main())

Testing

We use pytest along with pytest-asyncio for testing. Run the test suite using:

pytest

Contributing

Contributions are welcome! When submitting changes, please adhere to the following principles:

  • Follow PEP 8 and Python 3.13's type hinting conventions.
  • Use asynchronous programming consistently.
  • Update docstrings and Pydantic models accordingly.
  • Ensure new tools or changes are covered with tests.

License

This project is licensed under the MIT License. See LICENSE for details.

Additional Resources

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Amap Maps高德地图官方 MCP Server
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
DeepChatYour AI Partner on Desktop
Serper MCP ServerA Serper MCP Server
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
WindsurfThe new purpose-built IDE to harness magic
CursorThe AI Code Editor
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
ChatWiseThe second fastest AI chatbot™
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Tavily Mcp
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Playwright McpPlaywright MCP server
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code