NBP MCP Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@NBP MCP Server What was the USD to PLN exchange rate on 2024-01-15?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
NBP MCP Server
A Model Context Protocol (MCP) server for accessing Polish National Bank (NBP) data, including currency exchange rates and gold prices.
Features
This server provides access to the NBP public API with the following capabilities:
Currency Exchange Rates
Get current exchange rates for any currency
Retrieve complete exchange rate tables (A, B, or C)
Query historical exchange rates for specific date ranges
Get last N exchange rates for trend analysis
Gold Prices
Get current gold price (PLN per gram)
Retrieve historical gold prices
Query last N gold price quotations
Table Types
Table A: Average exchange rates of foreign currencies (updated daily)
Table B: Average exchange rates of other currencies (updated weekly)
Table C: Bid and ask rates for currencies (updated daily)
Related MCP server: FX Currency MCP Server
Installation
Create new project
uv init nbp-mcp-server
cd nbp-mcp-server
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activateAdd dependencies
uv add "mcp[cli]" httpxConfiguration
Claude Desktop
Add this to your Claude Desktop configuration file:
MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"nbp": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/nbp-mcp-server",
"run",
"main.py"
]
}
}
}Other MCP Clients
For other MCP clients that support stdio transport, configure them to run:
uv --directory /path/to/nbp-mcp-server run main.pyn8n (HTTP Transport)
For n8n integration, use the HTTP Streamable transport with Docker:
Docker Compose Configuration
nbp-mcp-server:
image: quay.io/migi/nbp-mcp-server:1.0.3
hostname: nbp
container_name: nbp-mcp-server
networks: ['mynetwork']
ports:
- 8000:8000
environment:
- PYTHONUNBUFFERED=1
restart: unless-stoppedn8n MCP Client Tool Node Setup
Configure the MCP Client Tool node in n8n:
URL:
http://nbp:8000/mcpServer Transport: HTTP Streamable
Sample AI Prompt for n8n
Ile kosztowało EURO 15 lutego 2022 roku.
# Rules
- The date which is going in the tool needs to be in a format YYYY-MM-DD
- Always use available MCP NBP tool to query for exchange rate.
- When asking for week of the year you need to use some external knowledge to get the dates
- If no data is returned you need to query the range at least 7 days prior to the given date and choose the closest one. This is because public holidays do not contain data.
# Output
- Always respond in pure JSON without any additional text or formatting.
- Always give ONLY one rate as a number without anything else
- Example output {'convertion': '4.2566'}
- If there is some problem simply give back {'conversion': 'n/a'}Available Tools
1. get_currency_rate
Get the exchange rate for a specific currency, either current or for a specific date.
Parameters:
code(required): Three-letter currency code (e.g., USD, EUR, GBP) - ISO 4217date(optional): Specific date in YYYY-MM-DD format (ISO 8601). If not provided, gets current rate.table(optional): Table type - 'a', 'b', or 'c' (default: 'a')
Example:
Get current USD exchange rate from table A
Get EUR bid/ask rates for 2024-01-15 (table C)
What was the GBP rate on 2024-03-20?2. get_exchange_table
Get a complete exchange rate table with all currencies, either current or for a specific date.
Parameters:
date(optional): Specific date in YYYY-MM-DD format (ISO 8601). If not provided, gets current table.table(optional): Table type - 'a', 'b', or 'c' (default: 'a')
Example:
Get the current table A with all exchange rates
Get table C with all bid/ask rates for 2024-02-15
What were all the exchange rates on 2024-01-01?3. get_currency_rate_history
Get historical exchange rates for a currency within a date range.
Parameters:
code(required): Three-letter currency code (ISO 4217)start_date(required): Start date in YYYY-MM-DD formatend_date(required): End date in YYYY-MM-DD formattable(optional): Table type - 'a', 'b', or 'c' (default: 'a')
Note: Date range cannot exceed 93 days.
Example:
Get USD rates from 2024-01-01 to 2024-01-31
Get EUR historical data for the last month4. get_currency_rate_last_n
Get the last N exchange rates for a currency.
Parameters:
code(required): Three-letter currency code (ISO 4217)count(required): Number of rates to retrieve (1-255)table(optional): Table type - 'a', 'b', or 'c' (default: 'a')
Example:
Get last 10 USD exchange rates
Get last 30 GBP rates from table C5. get_gold_price
Get the gold price in PLN per gram, either current or for a specific date.
Parameters:
date(optional): Specific date in YYYY-MM-DD format (ISO 8601). If not provided, gets current price.
Note: Gold price data is available from January 2, 2013.
Example:
What is the current gold price?
What was the gold price on 2024-01-15?
Get gold price for 2023-12-256. get_gold_price_history
Get historical gold prices within a date range.
Parameters:
start_date(required): Start date in YYYY-MM-DD formatend_date(required): End date in YYYY-MM-DD format
Note: Date range cannot exceed 93 days. Gold price data is available from January 2, 2013.
Example:
Get gold prices from 2024-01-01 to 2024-01-31
Show me gold price history for last month7. get_gold_price_last_n
Get the last N gold price quotations.
Parameters:
count(required): Number of prices to retrieve (1-255)
Example:
Get last 10 gold prices
Show me the last 30 gold quotationsUsage Examples
Once configured in Claude Desktop or another MCP client, you can ask:
"What's the current USD to PLN exchange rate?"
"What was the EUR rate on 2024-02-15?"
"Show me the last 30 days of EUR exchange rates"
"Get the complete table A with all current exchange rates"
"What were all the exchange rates on 2024-01-01?"
"What was the gold price on 2024-01-15?"
"Compare USD rates between table A and table C"
"Show me GBP exchange rate trends for the last 10 days"
Data Sources
All data is sourced from the official NBP (Narodowy Bank Polski) API:
API Documentation: https://api.nbp.pl/
Exchange rate data available from: January 2, 2002
Gold price data available from: January 2, 2013
Development
Running Locally
# Activate virtual environment
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Run the server
python main.pyTesting
The project includes comprehensive test coverage for all functionality.
Installing Test Dependencies
# Install all dependencies including dev extras (pytest, pytest-asyncio, pytest-cov)
uv sync --all-extrasRunning Tests
Important: Always use uv run pytest to ensure tests run in the correct virtual environment with all dependencies.
# Run all tests
uv run pytest
# Run tests with verbose output
uv run pytest -v
# Run tests with coverage report (default configuration)
uv run pytest
# Coverage reports are generated automatically per pyproject.toml config
# Run tests with HTML coverage report
uv run pytest --cov-report=html
# Then open htmlcov/index.html in your browser
# Run specific test file
uv run pytest tests/test_currency_rates.py
# Run specific test function
uv run pytest tests/test_currency_rates.py::test_get_currency_rate_success
# Run tests matching a pattern
uv run pytest -k "currency"Test Structure
The test suite is organized as follows:
tests/
├── __init__.py
├── conftest.py # Pytest configuration and fixtures
├── test_currency_rates.py # Tests for currency exchange rate tools
├── test_gold_prices.py # Tests for gold price tools
└── test_helpers.py # Tests for helper functionsTest Coverage
The tests cover:
Currency Rate Tools:
Getting current exchange rates (tables A, B, C)
Retrieving complete exchange rate tables
Querying historical rates by date range
Getting last N exchange rates
Input validation (invalid table types, counts)
Error handling (API errors, network issues)
Case-insensitive currency codes
Gold Price Tools:
Getting current gold price
Retrieving historical gold prices
Getting last N gold prices
Input validation
Error handling
Helper Functions:
API request handling with proper headers
HTTP error handling (404, timeouts, network errors)
Data formatting for rates, tables, and gold prices
Edge cases (missing fields, empty responses)
Continuous Testing
For development, you can use pytest-watch to automatically run tests when files change:
# Install pytest-watch
uv pip install pytest-watch
# Run tests in watch mode with uv
uv run ptwTesting with MCP Inspector
Option 1: Using stdio transport (Recommended)
npx @modelcontextprotocol/inspector uv --directory /FULL/PATH/to/nbp-mcp-server run main.pyThis uses the default stdio transport, which the inspector can communicate with directly.
Option 2: Using streamable-http transport
If you want to test the HTTP transport specifically, you need to run the server and inspector separately:
Terminal 1 - Start the server:
cd /path/to/nbp-mcp-server
uv run main.py --transport streamable-httpTerminal 2 - Connect the inspector to the running server:
npx @modelcontextprotocol/inspector http://localhost:8000/mcpImportant: The MCP endpoint is at /mcp, not at the root path.
By default, the server listens on 0.0.0.0:8000. You can customize this:
uv run main.py --transport streamable-http --host 127.0.0.1 --port 3000Then connect to http://localhost:3000/mcp
License
This project is under the Apache License, Version 2.0, however uses api calls to gather data from the NBP public API. Please refer to NBP's terms of service for data usage guidelines.
Contributing
Contributions are welcome! Please feel free to submit issues or pull requests.
Available Tools
7 toolsget_currency_rateA
Get exchange rate for a currency, either current or for a specific date.
Args: code: Three-letter currency code (e.g., USD, EUR, GBP) following ISO 4217 date: Specific date in YYYY-MM-DD format (ISO 8601). If empty, gets current rate. table: Table type - 'a' for average rates, 'b' for other currencies, 'c' for bid/ask rates (default: 'a')
Inputs: code (required), date, table. Returns: result
get_currency_rate_historyA
Get historical exchange rates for a currency within a date range.
Args: code: Three-letter currency code (e.g., USD, EUR, GBP) following ISO 4217 start_date: Start date in YYYY-MM-DD format (ISO 8601) end_date: End date in YYYY-MM-DD format (ISO 8601) table: Table type - 'a' for average rates, 'b' for other currencies, 'c' for bid/ask rates (default: 'a')
Inputs: code (required), end_date (required), start_date (required), table. Returns: result
get_currency_rate_last_nB
Get last N exchange rates for a currency.
Args: code: Three-letter currency code (e.g., USD, EUR, GBP) following ISO 4217 count: Number of last rates to retrieve (max 255) table: Table type - 'a' for average rates, 'b' for other currencies, 'c' for bid/ask rates (default: 'a')
Inputs: code (required), count (required), table. Returns: result
get_exchange_tableA
Get exchange rate table, either current or for a specific date.
Args: date: Specific date in YYYY-MM-DD format (ISO 8601). If empty, gets current table. table: Table type - 'a' for average rates, 'b' for other currencies, 'c' for bid/ask rates (default: 'a')
Inputs: date, table. Returns: result
get_gold_priceA
Get gold price in PLN per gram, either current or for a specific date.
Args: date: Specific date in YYYY-MM-DD format (ISO 8601). If empty, gets current price.
Inputs: date. Returns: result
get_gold_price_historyB
Get historical gold prices within a date range.
Args: start_date: Start date in YYYY-MM-DD format (ISO 8601) end_date: End date in YYYY-MM-DD format (ISO 8601)
Inputs: end_date (required), start_date (required). Returns: result
get_gold_price_last_nB
Get last N gold prices.
Args: count: Number of last gold prices to retrieve (max 255)
Inputs: count (required). Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
The currency and gold tools are mostly distinct: single-rate, full-table, date-range history, and last-N variants have clear boundaries. Some overlap exists between get_currency_rate and get_exchange_table, and between history and last_n, but the descriptions make the intended selection reasonably clear.
All tools use a consistent get_ prefix followed by domain-specific noun phrases. The currency and gold families mirror each other predictably, with suffixes like _history and _last_n used consistently.
Seven tools is well-scoped for a focused exchange-rate and gold-price server. Each tool covers a distinct retrieval pattern and there are no obviously redundant tools.
The surface covers current rates, specific dates, date-range history, and last-N retrieval for both currencies and gold, which is strong for the domain. Minor gaps remain, such as no explicit tool to list supported currencies or retrieve a full exchange table over a date range.
Maintenance
Related MCP Connectors
Official Polish central bank (NBP) exchange rates, currency conversion and gold prices.
Fetch latest and historical currency exchange rates from Frankfurter. Convert amounts between curr…
Live & historical FX rates and currency conversion for AI agents. No API keys.
Live & historical FX rates and currency conversion for AI agents. No API keys.
Related MCP Servers
- AlicenseAqualityDmaintenanceProvides access to currency exchange rates and conversion tools using the Frankfurter API, including latest rates, historical data, and time series from sources like the European Central Bank.5MIT
- FlicenseNot gradedqualityDmaintenanceProvides real-time and historical foreign exchange rates for 31+ currencies, enabling currency conversion, historical rate lookups, and time series analysis using data from the Frankfurter API.-
- AlicenseAqualityDmaintenanceProvides AI agents with real-time access to Polish official data: VAT whitelist for company verification and NBP exchange rates, enabling checks on VAT status, company details, and currency conversion without API keys.5MIT
- AlicenseNot gradedqualityCmaintenanceEnables access to National Bank of Poland (NBP) financial data, including exchange rates and other economic indicators, through the NBP Web API without requiring an API key.63 npmMIT