Skip to main content
Glama
CBR Currency Rate

CBR Currency Rate

by tordagaz-ops

# CBR Currency Rate — MCP server

MCP Python License

Ask your AI assistant "what is the official dollar rate today, and what was it a month ago?" and get the numbers the Central Bank actually published — not a plausible figure from training data.

This server wraps the public Bank of Russia (CBR) XML feeds — no key, no account, no registration — and exposes them as five read-only MCP tools: look up one rate, convert amounts, read the whole daily table, pull a history series, and search the currency directory.

Languages: English · Español · Русский


Why this exists

Exchange rates are exactly the kind of fact a language model will invent confidently. Worse, the numbers it invents look right: a dollar rate of 82 roubles is believable in a way that 8 200 is not.

This server answers from the official feed, and it is explicit about the cases that are easy to get wrong:

  • The rouble is the base, not a row. The CBR quotes everything against the rouble, so RUB never appears in the feed. It is accepted everywhere and always equals 1.0.

  • Nominals are not always 1. The yen is quoted per 100, the dong per 10 000. Reporting "55.12 roubles" for the yen instead of "0.55 roubles per yen" is the classic error; every row here carries both the quoted value and the per-unit rate.

  • A non-publication day is not a zero. The CBR publishes on business days only. Asking for a day it did not publish returns the rates of the most recent day it did, and the response says so with date_adjusted: true and a message instead of pretending that day had rates of its own.

  • The rouble has no history series. Asking for RUB history returns error: "base_currency" with an explanation, not an empty list.

Related MCP server: UZCBU MCP Server

Tools

get_currency_rate

Argument

Type

Default

Description

currency

string

—

ISO code: USD, EUR, CNY… or a numeric code such as 840

date

string

latest

2026-11-26, 26.11.2026 or 26/11/2026

{
  "currency": "USD",
  "name": "US Dollar",
  "name_en": "US Dollar",
  "name_ru": "Доллар США",
  "numeric_code": "840",
  "nominal": 1,
  "quoted_value_rub": 82.313,
  "rub_per_unit": 82.313,
  "units_per_rub": 0.01214875,
  "date": "2026-11-26",
  "requested_date": "2026-11-26",
  "date_adjusted": false,
  "base_currency": "RUB",
  "source": "Bank of Russia",
  "source_url": "https://www.cbr.ru/currency_base/daily/"
}

quoted_value_rub is what the CBR printed — roubles per nominal units. rub_per_unit is that value divided by the nominal, which is the number you can do arithmetic with. For the yen:

{ "currency": "JPY", "nominal": 100, "quoted_value_rub": 55.1234, "rub_per_unit": 0.551234 }

convert_currency

Argument

Type

Default

Description

amount

number

—

How much to convert

from_currency

string

—

Source ISO code

to_currency

string

—

Target ISO code

date

string

latest

Date of the rates used

{
  "amount": 1000,
  "from_currency": "USD",
  "to_currency": "EUR",
  "result": 865.36,
  "rate": 0.86536,
  "from": { "currency": "USD", "name": "US Dollar", "nominal": 1, "quoted_value_rub": 82.313, "rub_per_unit": 82.313 },
  "to":   { "currency": "EUR", "name": "Euro", "nominal": 1, "quoted_value_rub": 95.1234, "rub_per_unit": 95.1234 },
  "date": "2026-11-26",
  "requested_date": "2026-11-26",
  "date_adjusted": false,
  "base_currency": "RUB",
  "source": "Bank of Russia"
}

Both legs are crossed through the rouble, so any two quoted currencies can be converted — not just pairs involving RUB.

list_currency_rates

Argument

Type

Default

Description

currency_codes

array of string

all

Narrow to specific codes, e.g. ["USD", "EUR", "CNY"]

date

string

latest

Date of the table

{
  "count": 2,
  "total": 54,
  "rates": [
    { "currency": "EUR", "name": "Euro", "numeric_code": "978", "nominal": 1, "quoted_value_rub": 95.1234, "rub_per_unit": 95.1234 },
    { "currency": "USD", "name": "US Dollar", "numeric_code": "840", "nominal": 1, "quoted_value_rub": 82.313, "rub_per_unit": 82.313 }
  ],
  "date": "2026-11-26",
  "requested_date": "2026-11-26",
  "date_adjusted": false,
  "base_currency": "RUB",
  "source": "Bank of Russia"
}

Codes that were asked for but are not quoted come back in missing, so a typo in a filter never silently returns a shorter list.

get_rate_history

Argument

Type

Default

Description

currency

string

—

ISO code

start_date

string

end_date - 29 days

First day, inclusive

end_date

string

today (Moscow)

Last day, inclusive

{
  "currency": "USD",
  "name": "US Dollar",
  "start_date": "2026-11-01",
  "end_date": "2026-11-26",
  "count": 18,
  "points": [
    { "date": "2026-11-03", "nominal": 1, "quoted_value_rub": 82.0, "rub_per_unit": 82.0 },
    { "date": "2026-11-05", "nominal": 1, "quoted_value_rub": 83.0, "rub_per_unit": 83.0 }
  ],
  "first": 82.0,
  "last": 83.0,
  "min_rub_per_unit": 82.0,
  "max_rub_per_unit": 83.0,
  "change": 1.0,
  "change_percent": 1.2195,
  "base_currency": "RUB",
  "source": "Bank of Russia"
}

Only published days appear, so weekends and holidays are gaps, not repeats — count is the number of business days, not the calendar length. Ranges are capped at 366 days per request; error: "range_too_long" says by how much.

search_currencies

Argument

Type

Default

Description

query

string

""

Text matched against ISO code, numeric code, English name and Russian name

limit

integer

20

1–100

{
  "query": "yuan",
  "count": 1,
  "matches": 1,
  "scanned": 79,
  "results": [
    { "currency": "CNY", "name_en": "Chinese yuan", "name_ru": "Китайский юань", "numeric_code": "156", "nominal": 1, "quoted": true }
  ],
  "source": "Bank of Russia"
}

quoted separates the roughly 79 currencies in the directory from the ~54 that actually have a daily rate, so the model never suggests a code that the other tools would then reject. An empty query lists the directory in code order.

Quick start

Try these in order — they cover every tool:

  1. search_currencies with query: "yuan" → learn that the code is CNY.

  2. get_currency_rate with currency: "CNY" → the official rate today.

  3. convert_currency with amount: 5000, from_currency: "CNY", to_currency: "RUB".

  4. get_rate_history with currency: "USD" → the last 30 published days.

  5. list_currency_rates with currency_codes: ["USD", "EUR"] → both at once.

Install

pip install git+https://github.com/tordagaz-ops/cbr-currency-rate

or from a clone:

git clone https://github.com/tordagaz-ops/cbr-currency-rate
cd cbr-currency-rate
pip install .

Connect it

Claude Desktop / Claude Code

{
  "mcpServers": {
    "cbr-currency-rate": {
      "command": "python",
      "args": ["-m", "mcp_cbr_rate"],
      "env": { "MCP_LOCALE": "en" }
    }
  }
}

Smithery

The repository ships a smithery.yaml, so Smithery can build and host it directly — pick the language in the configuration form.

HTTP transport

MCP_TRANSPORT=http MCP_HOST=0.0.0.0 MCP_PORT=8000 python -m mcp_cbr_rate
# endpoint: http://localhost:8000/mcp

Docker

docker build -t cbr-currency-rate .
docker run -i --rm cbr-currency-rate

Example conversation

You: What's the official dollar rate today?

Assistant: (calls get_currency_rate with currency: "USD") 82.3130 roubles per dollar, per the Bank of Russia for 26 November 2026.

You: And the yen?

Assistant: (calls get_currency_rate with currency: "JPY") 0.551234 roubles per yen — the CBR quotes it per 100 yen at 55.1234.

You: Convert 5 000 yuan to roubles.

Assistant: (calls convert_currency) 5 000 CNY is 57 061.50 roubles at today's official rates.

You: How has the euro moved this month?

Assistant: (calls get_rate_history with currency: "EUR") Eighteen published days, from 95.12 to 96.40 — up 1.34 % over the period.

You: What's the rate for Sunday?

Assistant: (calls get_currency_rate with a Sunday date) The CBR does not publish that day; these are the most recent published rates, and the response flags the shift with date_adjusted: true.

Errors

Failures are data, never exceptions or stack traces:

{ "error": "unknown_currency", "message": "…", "currency": "GBP", "date": "2026-11-26" }

error

Meaning

What to do

empty_currency

No currency supplied

Pass an ISO code

invalid_currency

Not a plausible code

Use USD, EUR…

unknown_currency

The CBR does not quote it

Call search_currencies

base_currency

Asked for RUB history

Convert another currency to RUB instead

invalid_date

Not a real calendar date

Pass 2026-11-26

empty_amount

No amount supplied

Pass a number

invalid_amount

Not a number

Pass 1000 or 250.75

bad_date_range

start_date after end_date

Swap them

range_too_long

More than 366 days

Narrow or split the range

no_data

Nothing published for that date or the week before

Pick an earlier date

no_rate

A currency has no value that day

Retry later

timeout

Upstream too slow

Retry

network_error

Connection failed

Retry

upstream_unavailable

The CBR returned 5xx after retries

Retry later

upstream_rejected

The CBR rejected the request

Check arguments

bad_payload

Unexpected document shape

Report as a bug

Every date-bearing success payload also carries date (what was actually published), requested_date (what you asked for) and date_adjusted (whether they differ), plus a message explaining the shift when they do.

Behaviour and limits

  • Caching. A day's table is cached for 10 minutes, the currency directory for 24 hours, history ranges for 30 minutes. Concurrent identical requests share one upstream call.

  • Retries. 408/425/429/5xx are retried with jittered backoff, honouring Retry-After; other 4xx are not.

  • Business days only. The CBR publishes once per business day, around 11:30 Moscow time, and its feeds contain only that day's rates. Before publication the server looks back up to seven days and reports the day it used.

  • Time zones. "Today" means today in Moscow, because that is the calendar the CBR publishes on.

  • Encoding. The feeds are windows-1251, not UTF-8; decoding is explicit rather than guessed, so Russian names never arrive as mojibake.

  • Coverage. Precious metals and the rouble itself are not in the daily feed. Neither are currencies the CBR has stopped quoting.

  • Read-only. No account, no payments, no key.

Languages

Set MCP_LOCALE to en, es or ru. It controls tool titles, descriptions, parameter text and every error message. Default is English; when MCP_LOCALE is unset the server falls back to LANGUAGE / LANG, then to English.

Currency names follow the locale: Russian names in Russian, the CBR's English names otherwise (Spanish has no official CBR name list, and inventing one would be worse than using English).

Development

python -m venv .venv
.venv/Scripts/activate        # Windows; source .venv/bin/activate elsewhere
pip install -e ".[dev]"

pytest -m "not live and not e2e"   # unit: parsing, dates, mocked feeds
pytest -m e2e                      # end-to-end: real stdio process, real protocol
pytest -m live                     # live: hits the real CBR feeds
pytest                             # everything

Layout:

src/mcp_cbr_rate/
  server.py   FastMCP wiring, tool signatures, error mapping
  cbr.py      XML parsing, nominal normalisation, cached client
  i18n.py     en / es / ru strings
  core.py     HTTP client with retries, TTL cache, locale plumbing

Attribution

Exchange rates come from the public XML feeds of the Central Bank of the Russian Federation (Банк России) and remain their data. This project is an independent wrapper, not affiliated with or endorsed by the Bank of Russia.

Rates are the CBR's official accounting figures, not market or trading quotes. This is not financial advice.

License

MIT — see LICENSE.

Available Tools

5 tools
convert_currencyA
Read-only

Convert an amount from one currency to another using the official Bank of Russia rates, crossing through the rouble. Both currencies must be quoted by the CBR (or be 'RUB'). Returns the converted amount together with the effective rate. Example: amount=1000, from_currency='USD', to_currency='RUB'.

Inputs: amount (required), to_currency (required), from_currency (required), date. Returns: object

get_currency_rateA
Read-only

Return the official Bank of Russia rate for one currency: roubles per unit, the inverse, the quoted nominal and both the English and Russian names. 'date' is optional and accepts 2026-11-26, 26.11.2026 or 26/11/2026; without it the latest published day is used. Weekends and holidays fall back to the previous business day and the response says which day was used. 'RUB' is accepted and always equals 1. Example: currency='USD'.

Inputs: currency (required), date. Returns: object

get_rate_historyA
Read-only

Return a series of official rates for one currency between start_date and end_date, both inclusive. Ranges are capped at 366 days. Only business days are published, so weekends and holidays are absent rather than repeated. Example: currency='USD', start_date='2026-11-01', end_date='2026-11-26'.

Inputs: currency (required), end_date, start_date. Returns: object

list_currency_ratesA
Read-only

Return the Bank of Russia daily rate table: every quoted currency with its nominal, value and per-unit rate. Pass currency_codes to narrow the list, for example ['USD', 'EUR', 'CNY']. Without it the whole table is returned, sorted by ISO code. Example: currency_codes=['USD', 'EUR'].

Inputs: date, currency_codes. Returns: object

search_currenciesA
Read-only

Search the Bank of Russia currency directory by ISO code, numeric code, English name or Russian name, and report which of the matches the daily feed actually quotes. Use this when you are not sure of a currency code before calling the rate tools. Example: query='yuan'.

Inputs: limit, query. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.2/5.0

    Scored across 5 tools

    Disambiguation5/5

    Each tool maps to a distinct operation: single-rate lookup, conversion, full table listing, historical series, and directory search. Descriptions explicitly state when to prefer one over another (e.g. search_currencies before rate lookups), leaving no realistic chance of misselection.

    Naming Consistency5/5

    All five names follow a strict snake_case verb_noun pattern (get_, convert_, list_, get_..._history, search_) and use consistent domain vocabulary. get_currency_rate vs get_rate_history are differentiated by the noun suffix rather than by arbitrary verb changes.

    Tool Count5/5

    Five tools is tightly scoped to the CBR rates domain, and each one covers a genuinely different access pattern (point lookup, computation, bulk listing, time series, discovery). Nothing is redundant or padded.

    Completeness4/5

    Lookup, reverse rate, conversion, table listing, history and code discovery give full lifecycle coverage for the stated purpose. Minor gaps: convert_currency does not document a date parameter for historical conversion, and there is no batch multi-currency history call, though agents can work around both.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Provides access to Croatian National Bank exchange rates without needing an API key, enabling currency conversion and rate queries through natural language.
      54 npm
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to fetch official Uzbekistan Central Bank currency rates, including current and historical rates, and perform currency conversions via MCP.
      1
      -
    • A
      license
      A
      quality
      C
      maintenance
      Enables querying Central Bank of Russia data including daily currency rates, exchange rate dynamics, key rate and history, precious metals prices, and currency conversion, with no authorization required.
      7
      58 npm
      1
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to query the Russian central bank’s key-rate history and official exchange rates by currency, date, or date range through live keyless calls.
      MIT