MapleStatsMCP

One Canadian data server to rule them all.

Canadian data live in dozens of places. MapleStats puts 201 of them behind one connection, and every figure your AI agent gets back carries its citation, its quality flags and its licence, so you can trace each number to the publisher and check it. It is an MCP server, a connector your AI agent calls, not a portal to browse: it keeps no copy of the data and fetches each figure live from the publisher.

Every figure, traceable

Each value comes back with its table or series id, reference period, release date, unit and scale, geography and a link to the publisher's page. When a figure is not published, the server says so instead of letting the agent guess.

Scripts you can rerun

Most data calls can come back as an R, Python, Stata or Julia script (or an Excel Power Query) that fetches the same numbers straight from the source, so the analysis runs without the agent and a reviewer can see exactly what was pulled.

The easiest way: ask your agent One prompt connects MapleStats to the hosted server: nothing to install, no account, no key. The agent reads the setup steps from the repository and does the rest.

Connect the MapleStats MCP server to this agent. Follow the setup steps in https://github.com/dsanchezp18/maplestats-mcp
  1. Copy the prompt.
  2. Paste it into Claude Code, Codex, Cursor or any agent that can run commands on your computer.
  3. Restart the agent when it says so, then ask for data.

Try it

See it in action

Try MapleStats before you connect it to anything. Type a question about Canadian data, in English or French, or pick an example: the chat looks up the answer live through the hosted server, cites its source and shows each tool it called.

A demo: answers can be wrong, so check the source each one cites. The first question can take up to a minute. The chat lists the full terms.

3

MCPs for the statisticians, keepers of the weights and the margins,

7

for the demographers, counting who comes to stay,

9

for the financial analysts, doomed to explain the rate…

But MapleStats is the one MCP to rule them all.

Too many places to look, too many interfaces to learn.

Most Canadian data MCPs cover one source each: one for Statistics Canada, one for the Bank of Canada, others for open-data portals. Each is useful. Together, they bring back an old problem: you have to know where to look before you can ask a simple question. I built MapleStats so you don't: one MCP for Canadian open data.

MapleStats MCP

The data stay with their publishers.

The server keeps no dataset of its own, only short-lived caches. It calls each source directly, so every number comes from its publisher.

One search covers every source.

Each agency keeps its own adaptor underneath. The agent sees one search across all of them.

Ask the question; it finds the source.

The agent does not need to know whether the answer is a StatCan table, a Valet series, a CMHC dataset or a CKAN resource.

Why MapleStats

Built by a statistician, for anyone who works with the numbers.

Economists, demographers, policy analysts, researchers, journalists, students: anyone who needs a Canadian figure they can trust and cite. Data tools are often built by developers who never use them in an actual analysis project. MapleStats is built by someone who does, around the mistakes people actually make with official data, and we test it against other tools on public benchmarks: see how it does.

Every number names its source.

Every StatCan series carries a citation: the table and vector, the period, the release date, the unit and scale, the geography and a link to the official table. Every other result names its source, the exact URL it was read from and its licence, including whether commercial use is allowed: the AESO's market data, for one, are for non-commercial use only.

It knows the traps.

Constant vs current dollars, family vs individual income, annual average vs December over December, survey rent vs listing rent: it warns in plain language, and each fitness-for-use caution rests on the publisher's own documentation.

It says when data do not exist.

A series that is not published, a period not released yet or a date with no data gets a plain no, the nearest figure that does exist, and where it could come from: public microdata you can tabulate yourself, or a custom tabulation, RTRA or a Research Data Centre (not public, approval needed).

The answer can be checked before you see it.

Before replying, the assistant can send the StatCan and Bank of Canada figures it cites to check_answer, which re-reads them from the source: the right value and scale, the latest period, the geography you asked for and the seasonally adjusted headline. "Use with caution", "too unreliable to be published", preliminary and revised are spelled out on every StatCan value.

It does the arithmetic, with citations.

Ratios, rankings, compound annual growth and counts of rate changes across Statistics Canada and Bank of Canada series come back with the formula and every input's source, instead of being worked out by the assistant. The international comparators set Canada beside its peers: the OECD, the World Bank, BIS and ILOSTAT across countries, Eurostat and the ECB for the EU and the euro area, the Federal Reserve for the United States, the ONS for the United Kingdom and the ABS for Australia.

Your work stays reproducible.

It writes the R, Python, Stata or Julia script, or the Excel query, that pulls the same data from the source.

It only reads, in English and French.

The server only reads from public sources. The scripts it writes run only if you run them, and saving a workbook to disk is opt-in on a local server. Search, results and warnings work in both official languages.

Demos

What you can do with it

Nine questions, from nine kinds of work, each answered with MapleStats tool calls.

Macroeconomists

What bond markets expect, in one line

The gap between the 10-year and 2-year Government of Canada bond yields, every business day since 2019. When it drops below zero, markets expect rates to fall, usually because they expect the economy to slow. It inverted in 2019 to 2020 and 2022 to 2024. The chart ends with October 2026, the last full month when it was recorded.

The yield curve: 10-year minus 2-year Government of Canada benchmark bond yields, monthly average of daily values, with inverted months shaded−200 bp−100 bp0 bp100 bp200 bpInverted202020252019-06-01: 2 bp2019-07-01: 0 bp2019-08-01: −16 bp2019-09-01: −18 bp2019-10-01: −13 bp2019-11-01: −7 bp2019-12-01: −6 bp2020-01-01: −9 bp2020-02-01: −12 bp2020-03-01: 20 bp2020-04-01: 29 bp2020-05-01: 26 bp2020-06-01: 26 bp2020-07-01: 24 bp2020-08-01: 28 bp2020-09-01: 30 bp2020-10-01: 36 bp2020-11-01: 42 bp2020-12-01: 49 bp2021-01-01: 64 bp2021-02-01: 89 bp2021-03-01: 124 bp2021-04-01: 124 bp2021-05-01: 121 bp2021-06-01: 105 bp2021-07-01: 79 bp2021-08-01: 74 bp2021-09-01: 82 bp2021-10-01: 82 bp2021-11-01: 69 bp2021-12-01: 47 bp2022-01-01: 58 bp2022-02-01: 44 bp2022-03-01: 29 bp2022-04-01: 24 bp2022-05-01: 27 bp2022-06-01: 16 bp2022-07-01: −13 bp2022-08-01: −50 bp2022-09-01: −58 bp2022-10-01: −63 bp2022-11-01: −79 bp2022-12-01: −87 bp2023-01-01: −80 bp2023-02-01: −88 bp2023-03-01: −83 bp2023-04-01: −81 bp2023-05-01: −88 bp2023-06-01: −119 bp2023-07-01: −123 bp2023-08-01: −105 bp2023-09-01: −97 bp2023-10-01: −72 bp2023-11-01: −71 bp2023-12-01: −78 bp2024-01-01: −66 bp2024-02-01: −68 bp2024-03-01: −69 bp2024-04-01: −56 bp2024-05-01: −58 bp2024-06-01: −55 bp2024-07-01: −37 bp2024-08-01: −21 bp2024-09-01: −4 bp2024-10-01: 11 bp2024-11-01: 10 bp2024-12-01: 17 bp2025-01-01: 36 bp2025-02-01: 37 bp2025-03-01: 47 bp2025-04-01: 58 bp2025-05-01: 63 bp2025-06-01: 66 bp2025-07-01: 72 bp2025-08-01: 73 bp2025-09-01: 72 bp2025-10-01: 71 bp2025-11-01: 73 bp2025-12-01: 81 bp2026-01-01: 84 bp2026-02-01: 80 bp2026-03-01: 68 bp2026-04-01: 65 bp2026-05-01: 61 bp2026-06-01: 63 bp2026-07-01: 71 bp2026-08-01: 72 bp2026-09-01: 62 bp2026-10-01: 60 bp60 bpThe yield curve: 10-year minus 2-year Government of Canada benchmark bond yields, monthly average of daily values, with inverted months shaded−200 bp−100 bp0 bp100 bp200 bpInverted202020252019-06-01: 2 bp2019-07-01: 0 bp2019-08-01: −16 bp2019-09-01: −18 bp2019-10-01: −13 bp2019-11-01: −7 bp2019-12-01: −6 bp2020-01-01: −9 bp2020-02-01: −12 bp2020-03-01: 20 bp2020-04-01: 29 bp2020-05-01: 26 bp2020-06-01: 26 bp2020-07-01: 24 bp2020-08-01: 28 bp2020-09-01: 30 bp2020-10-01: 36 bp2020-11-01: 42 bp2020-12-01: 49 bp2021-01-01: 64 bp2021-02-01: 89 bp2021-03-01: 124 bp2021-04-01: 124 bp2021-05-01: 121 bp2021-06-01: 105 bp2021-07-01: 79 bp2021-08-01: 74 bp2021-09-01: 82 bp2021-10-01: 82 bp2021-11-01: 69 bp2021-12-01: 47 bp2022-01-01: 58 bp2022-02-01: 44 bp2022-03-01: 29 bp2022-04-01: 24 bp2022-05-01: 27 bp2022-06-01: 16 bp2022-07-01: −13 bp2022-08-01: −50 bp2022-09-01: −58 bp2022-10-01: −63 bp2022-11-01: −79 bp2022-12-01: −87 bp2023-01-01: −80 bp2023-02-01: −88 bp2023-03-01: −83 bp2023-04-01: −81 bp2023-05-01: −88 bp2023-06-01: −119 bp2023-07-01: −123 bp2023-08-01: −105 bp2023-09-01: −97 bp2023-10-01: −72 bp2023-11-01: −71 bp2023-12-01: −78 bp2024-01-01: −66 bp2024-02-01: −68 bp2024-03-01: −69 bp2024-04-01: −56 bp2024-05-01: −58 bp2024-06-01: −55 bp2024-07-01: −37 bp2024-08-01: −21 bp2024-09-01: −4 bp2024-10-01: 11 bp2024-11-01: 10 bp2024-12-01: 17 bp2025-01-01: 36 bp2025-02-01: 37 bp2025-03-01: 47 bp2025-04-01: 58 bp2025-05-01: 63 bp2025-06-01: 66 bp2025-07-01: 72 bp2025-08-01: 73 bp2025-09-01: 72 bp2025-10-01: 71 bp2025-11-01: 73 bp2025-12-01: 81 bp2026-01-01: 84 bp2026-02-01: 80 bp2026-03-01: 68 bp2026-04-01: 65 bp2026-05-01: 61 bp2026-06-01: 63 bp2026-07-01: 71 bp2026-08-01: 72 bp2026-09-01: 62 bp2026-10-01: 60 bp60 bp
Show the data
The 10-year minus 2-year yield gap by year: the average, lowest and highest of that year's monthly averages
YearAverageLowest monthHighest month
2019−8 bp−18 bp2 bp
202024 bp−12 bp49 bp
202188 bp47 bp124 bp
2022−13 bp−87 bp58 bp
2023−91 bp−123 bp−71 bp
2024−33 bp−69 bp17 bp
202563 bp36 bp81 bp
202669 bp60 bp84 bp
Source: Bank of Canada, Canadian bond yields, queried 10 November 2026

The other eight

Sources

Where the data come from

Federal agencies answer most national questions; provincial agencies and open-data catalogues add the local detail. Every result comes straight from its publisher. Recent additions range from DFO's commercial fisheries landings and the tables inside each release of The Daily to the AESO's Alberta electricity market, the AER's ST98 energy outlook, the City of Toronto's neighbourhood profiles, RentSafeTO, short-term rentals and DineSafe, and Niagara Open Data.

49
federal and national sources, plus 10 international comparators
142
provincial, territorial and city sources
12/13
provinces and territories with local data
201
sources, one connection

Statistics Canada, in depth Every table, series and microdata file an agent can reach, and the hard parts MapleStats handles for you.

How it works

From a question to a sourced number

Ask your agent a question in plain words. MapleStats finds the right source, fetches the numbers with a link back to the publisher, and can write you a script to rerun the work yourself. The examples below are real.

  1. 01

    Find the source

    Your agent searches every source at once, in English or French. Try it: this box runs the same search in your browser.

  2. 02

    Get the numbers

    The agent pulls the numbers straight from the publisher. Every result says where it came from and when it was fetched.

    call_toolRecorded 10 November 2026

    Prompt

    What is the Bank of Canada's overnight rate?

    Result

    Target for the overnight rate (business daily) V39079
    DateValue
    6 November 20262.50
    5 November 20262.50
    4 November 20262.50

    Provenance

    Queried
    10 November 2026, 03:17 UTC
    Result type
    boc.ObservationsResult
    Show the full response as JSON
    {
      "series": {
        "V39079": {"name": "V39079", "label": "Target for the overnight rate (business daily)", "description": "Also called the policy interest rate, the average rate that the Bank of Canada wants to see in the market for overnight money market financing. (V39079)", "unit": "Percent", "frequency": "Business daily", "status": "active", "last_observation": "2026-11-06", "successor": null, "note": null}
      },
      "observations": [
        {"ref_date": "2026-11-06", "values": {"V39079": 2.5}, "non_numeric": null},
        {"ref_date": "2026-11-05", "values": {"V39079": 2.5}, "non_numeric": null},
        {"ref_date": "2026-11-04", "values": {"V39079": 2.5}, "non_numeric": null}
      ],
      "transformed": null,
      "provenance": {
        "source": "boc",
        "url": "https://www.bankofcanada.ca/valet/observations/V39079/json?recent=3",
        "queried_at": "2026-11-10T03:17:52.892553Z",
        "as_of": "2026-11-06T00:00:00Z",
        "freshness": null,
        "coverage": null,
        "limits": null,
        "cached": false,
        "lang": "en",
        "schema_name": "boc.ObservationsResult",
        "licence": "Bank of Canada Terms of Use (https://www.bankofcanada.ca/terms/): attribute the Bank of Canada as the source and indicate if changes were made, without implying the Bank endorses the use; content passed on through paid services must be identified as obtained from the Bank's website.",
        "commercial_use": "allowed",
        "caveats": [],
        "reproduce": "For scripts, call reproduce_code with this tool's name and arguments."
      }}
  3. 03

    Rerun it yourself

    Ask for a script and the same call becomes R, Python, Stata or Julia code, or an Excel Power Query, so you can rerun the analysis without the agent.

    reproduce_codeRun when this page was built

    Prompt

    Write me a script that fetches this, so I can rerun it myself.

    R

    # ============================================================
    # Bank of Canada Valet: V39079
    # Purpose: Fetch the data behind MapleStats MCP's boc_get_observations
    #          (exact: Valet request rebuilt from the tool's arguments)
    # Inputs:  https://www.bankofcanada.ca/valet/observations/V39079/json?recent=3
    # Outputs: data/raw/valet_observations.json; the prepared table as `data`
    # ============================================================
    
    # 0. Setup ----
    
    library(dplyr)
    library(httr2)
    library(janitor)
    library(jsonlite)
    library(lubridate)
    library(purrr)
    library(readr)
    library(stringr)
    library(tibble)
    library(tidyr)
    
    dir.create("data/raw", recursive = TRUE, showWarnings = FALSE)
    
    # 1. Read inputs ----
    
    response <- request("https://www.bankofcanada.ca/valet/observations/V39079/json?recent=3") |>
      req_perform()
    
    writeLines(resp_body_string(response), "data/raw/valet_observations.json")
    
    payload <- fromJSON("data/raw/valet_observations.json", flatten = TRUE)
    data <- as_tibble(payload[["observations"]])
    
    # 2. Check inputs ----
    
    stopifnot("https://www.bankofcanada.ca/valet/observations/V39079/json?recent=3 returned no rows" = nrow(data) > 0)
    
    # 3. Prepare data ----
    
    data <- data |>
      clean_names()
    
    # Valet nests each series as <series>.v; make one row per date and series.
    
    data <- data |>
      pivot_longer(-d, names_to = "series", values_to = "value") |>
      mutate(
        series = str_remove(series, "_v$") |> str_to_upper(),
        value = as.numeric(value),
        date = ymd(d)
      ) |>
      select(date, series, value)
    
    # Standard cleaning: trimmed text, empty strings as missing, and numbers
    # stored as text converted to numbers. Codes stay text as the source
    # wrote them: columns named like one (coordinate, vector_id, dguid, NAICS,
    # postal code) and columns with a leading zero (01, 000000001).
    
    code_columns <- "^(coordinate|vector|vector_?id|product_?id|pid|dguid|[a-z0-9_]*_dguid|postal_?code|[a-z0-9_]*_postal_code|fsa|[a-z0-9_]*naics[a-z0-9_]*|noc|noc_[a-z0-9_]*|[a-z0-9_]*_noc|sgc|sgc_[a-z0-9_]*|[a-z0-9_]*_sgc)$"
    data <- data |>
      mutate(across(where(is.character), \(x) na_if(str_trim(x), "")))
    keep_text <- names(data)[
      str_detect(names(data), code_columns) |
        map_lgl(
          data,
          \(column) is.character(column) && any(str_detect(column, "^-?0[0-9]"), na.rm = TRUE)
        )
    ]
    data <- data |>
      mutate(
        across(any_of(keep_text), \(x) if (is.list(x)) x else as.character(x)),
        across(where(is.character) & !any_of(keep_text), parse_guess)
      )

    Python

    # ============================================================
    # Bank of Canada Valet: V39079
    # Purpose: Fetch the data behind MapleStats MCP's boc_get_observations
    #          (exact: Valet request rebuilt from the tool's arguments)
    # Inputs:  https://www.bankofcanada.ca/valet/observations/V39079/json?recent=3
    # Outputs: data/raw/valet_observations.json; the prepared table as `data`
    # ============================================================
    
    # %% 0. Setup
    
    import json
    import re
    import unicodedata
    from pathlib import Path
    
    import httpx
    import polars as pl
    
    RAW_DIR = Path("data/raw")
    RAW_DIR.mkdir(parents=True, exist_ok=True)
    raw_path = RAW_DIR / "valet_observations.json"
    
    # %% 1. Read inputs
    
    with httpx.Client(
        http2=True,
        follow_redirects=True,
        timeout=300,
        headers={"User-Agent": "MapleStats MCP reproduction script (https://github.com/dsanchezp18/maplestats-mcp)"},
    ) as client:
        response = client.get('https://www.bankofcanada.ca/valet/observations/V39079/json?recent=3')
    response.raise_for_status()
    raw_path.write_bytes(response.content)
    
    payload = json.loads(raw_path.read_text(encoding="utf-8"))
    records = payload['observations']
    data = pl.json_normalize(records, strict=False)
    
    # %% 2. Check inputs
    
    assert data.height > 0, "https://www.bankofcanada.ca/valet/observations/V39079/json?recent=3 returned no rows"
    
    # %% 3. Prepare data
    
    # Valet nests each series as <series>.v; make one row per date and series.
    
    data = data.unpivot(index="d", variable_name="series", value_name="value")
    data = data.with_columns(
        pl.col("d").str.to_date().alias("date"),
        pl.col("series").str.replace(r"\.v$", ""),
        pl.col("value").cast(pl.Float64, strict=False),
    ).select("date", "series", "value")
    
    # Standard cleaning: snake_case names as janitor's clean_names() gives them
    # in R (PÉRIODE -> periode, referenceNumber -> reference_number, # -> number,
    # % -> percent, apostrophes dropped, a leading digit prefixed with x),
    # trimmed text, empty strings as missing. Names that clean alike are
    # numbered as janitor numbers them (Indicator, indicator -> indicator,
    # indicator_2).
    
    clean_names = [
        re.sub(
            r"[^0-9a-z]+",
            "_",
            re.sub(
                r"([a-z0-9])([A-Z])",
                r"\1_\2",
                "".join(
                    " " if unicodedata.category(ch)[0] in "PS" and not ch.isascii() else ch
                    for ch in unicodedata.normalize("NFKD", column.replace("'", ""))
                )
                .replace("#", " number ")
                .replace("%", " percent ")
                .encode("ascii", "ignore")
                .decode(),
            ).lower(),
        ).strip("_")
        or "x"
        for column in data.columns
    ]
    clean_names = [f"x{name}" if name[0].isdigit() else name for name in clean_names]
    while len(set(clean_names)) < len(clean_names):
        name_counts = {}
        numbered = []
        for name in clean_names:
            name_counts[name] = name_counts.get(name, 0) + 1
            count = name_counts[name]
            numbered.append(name if count == 1 else f"{name}_{count}")
        clean_names = numbered
    data = data.rename(dict(zip(data.columns, clean_names)))
    data = data.with_columns(pl.col(pl.Utf8).str.strip_chars().replace("", None))
    
    # Numbers stored as text become numbers. Codes stay text as the source
    # wrote them: columns named like one (coordinate, vector_id, dguid, NAICS,
    # postal code) and columns with a leading zero (01, 000000001).
    
    code_columns = re.compile(r"^(coordinate|vector|vector_?id|product_?id|pid|dguid|[a-z0-9_]*_dguid|postal_?code|[a-z0-9_]*_postal_code|fsa|[a-z0-9_]*naics[a-z0-9_]*|noc|noc_[a-z0-9_]*|[a-z0-9_]*_noc|sgc|sgc_[a-z0-9_]*|[a-z0-9_]*_sgc)$")
    for column in data.columns:
        dtype = data.schema[column]
        if code_columns.search(column) and not dtype.is_nested():
            data = data.with_columns(pl.col(column).cast(pl.Utf8))
            continue
        if dtype != pl.Utf8 or data[column].null_count() == data.height:
            continue
        numbers = data[column].cast(pl.Float64, strict=False)
        leading_zero = data[column].str.contains(r"^-?0[0-9]").any()
        if numbers.null_count() > data[column].null_count() or leading_zero:
            continue
        whole = data[column].cast(pl.Int64, strict=False)
        data = data.with_columns(whole if whole.null_count() == numbers.null_count() else numbers)

    Stata

    * ============================================================
    * Bank of Canada Valet: V39079
    * Purpose: Fetch the data behind MapleStats MCP's boc_get_observations
    *          (exact: Valet request rebuilt from the tool's arguments)
    * Inputs:  https://www.bankofcanada.ca/valet/observations/V39079/json?recent=3
    * Outputs: data/raw/valet_observations.json; the prepared table as `data`
    * ============================================================
    
    version 18
    clear all
    set more off
    
    * 0. Setup
    
    capture mkdir "logs"
    capture log close
    log using "logs/boc_get_observations.log", replace
    capture mkdir "data"
    capture mkdir "data/raw"
    
    * 1. Read inputs
    
    * Stata reads no JSON or HTML and truncates long column names, so its
    * built-in Python (Stata 16+) fetches, filters and writes a CSV. Point
    * Stata at a Python with these packages first: python set exec <path>.
    
    python:
    import json
    from pathlib import Path
    import httpx
    import polars as pl
    RAW_DIR = Path("data/raw")
    RAW_DIR.mkdir(parents=True, exist_ok=True)
    raw_path = RAW_DIR / "valet_observations.json"
    with httpx.Client(http2=True, follow_redirects=True, timeout=300, headers={"User-Agent": "MapleStats MCP reproduction script (https://github.com/dsanchezp18/maplestats-mcp)"}) as client: response = client.get('https://www.bankofcanada.ca/valet/observations/V39079/json?recent=3')
    response.raise_for_status()
    raw_path.write_bytes(response.content)
    payload = json.loads(raw_path.read_text(encoding="utf-8"))
    records = payload['observations']
    data = pl.json_normalize(records, strict=False)
    nested = [name for name, dtype in data.schema.items() if dtype.is_nested()]
    data = data.with_columns(pl.col(name).map_elements(lambda value: json.dumps(value.to_list() if isinstance(value, pl.Series) else value, default=str), return_dtype=pl.Utf8) for name in nested)
    data.write_csv(RAW_DIR / "valet_observations_prepared.csv")
    end
    
    import delimited "data/raw/valet_observations_prepared.csv", clear varnames(1) encoding("utf-8") stringcols(_all) bindquote(strict) maxquotedrows(unlimited)
    
    * 2. Check inputs
    
    assert _N > 0
    
    * 3. Prepare data
    
    * One column per series (<series>_v), one row per date.
    
    generate date = date(d, "YMD")
    format date %td
    drop d
    
    * Standard cleaning: lower-case names, trimmed text, and numbers stored as
    * text converted (destring leaves genuinely non-numeric text alone). Codes
    * stay text as the source wrote them: variables named like one (coordinate,
    * vectorid, dguid, NAICS, postal code) and ones with a leading zero (01).
    * rename *, lower stops at a clash (Indicator next to indicator), so names
    * that lower-case alike are numbered as janitor numbers them (indicator,
    * indicator_2), then renamed in one group rename, which allows swaps.
    
    local names
    foreach var of varlist _all {
        local names `names' `=strlower("`var'")'
    }
    local dups : list dups names
    while "`dups'" != "" {
        local numbered
        local before
        foreach name of local names {
            local count 1
            foreach earlier of local before {
                if "`earlier'" == "`name'" local ++count
            }
            local before `before' `name'
            if `count' > 1 {
                local name = substr("`name'", 1, 32 - strlen("_`count'")) + "_`count'"
            }
            local numbered `numbered' `name'
        }
        local names `numbered'
        local dups : list dups names
    }
    local old_names
    local new_names
    local i 0
    foreach var of varlist _all {
        local ++i
        local name : word `i' of `names'
        if "`name'" != "`var'" {
            local old_names `old_names' `var'
            local new_names `new_names' `name'
        }
    }
    if "`old_names'" != "" {
        rename (`old_names') (`new_names')
    }
    quietly ds, has(type string)
    local text_vars `r(varlist)'
    foreach var of local text_vars {
        replace `var' = strtrim(`var')
        if regexm("`var'|", "^(coordinate|vector|vector_?id|product_?id|pid|dguid|[a-z0-9_]*_dguid|postal_?code|[a-z0-9_]*_postal_code|fsa|[a-z0-9_]*naics[a-z0-9_]*|noc|noc_[a-z0-9_]*|[a-z0-9_]*_noc|sgc|sgc_[a-z0-9_]*|[a-z0-9_]*_sgc)[|]") continue
        quietly count if regexm(`var', "^-?0[0-9]")
        if r(N) > 0 continue
        destring `var', replace
    }
    
    log close

    Julia

    # ============================================================
    # Bank of Canada Valet: V39079
    # Purpose: Fetch the data behind MapleStats MCP's boc_get_observations
    #          (exact: Valet request rebuilt from the tool's arguments)
    # Inputs:  https://www.bankofcanada.ca/valet/observations/V39079/json?recent=3
    # Outputs: data/raw/valet_observations.json; the prepared table as `data`
    # ============================================================
    
    # 0. Setup
    
    using DataFrames
    using Dates
    using Downloads
    using JSON3
    using Tables
    using TidierData
    
    mkpath("data/raw")
    
    # 1. Read inputs
    
    Downloads.download("https://www.bankofcanada.ca/valet/observations/V39079/json?recent=3", "data/raw/valet_observations.json")
    payload = JSON3.read(read("data/raw/valet_observations.json", String))
    records = payload["observations"]
    data = DataFrame(Tables.dictrowtable(records))
    data = mapcols(col -> [x === nothing ? missing : x for x in col], data)
    
    # 2. Check inputs
    
    @assert nrow(data) > 0 "https://www.bankofcanada.ca/valet/observations/V39079/json?recent=3 returned no rows"
    
    # 3. Prepare data
    
    # Valet nests each series as {v: value}; make one row per date and series.
    
    data = stack(data, Not("d"); variable_name = "series", value_name = "cell")
    data.value = [
        ismissing(cell) ? missing :
            something(tryparse(Float64, string(get(cell, :v, ""))), missing)
        for cell in data.cell
    ]
    data.date = Date.(data.d)
    data = select(data, "date", "series", "value")
    
    # Standard cleaning: snake_case names, trimmed text, empty strings as missing.
    
    data = @chain data begin
        @clean_names
    end
    data = mapcols(
        col -> eltype(col) <: Union{Missing, AbstractString} ?
            [ismissing(x) || isempty(strip(x)) ? missing : strip(x) for x in col] : col,
        data,
    )
    
    # Numbers stored as text become numbers. Codes stay text as the source
    # wrote them: columns named like one (coordinate, vector_id, dguid, NAICS,
    # postal code) and columns with a leading zero (01, 000000001).
    
    code_columns = r"^(coordinate|vector|vector_?id|product_?id|pid|dguid|[a-z0-9_]*_dguid|postal_?code|[a-z0-9_]*_postal_code|fsa|[a-z0-9_]*naics[a-z0-9_]*|noc|noc_[a-z0-9_]*|[a-z0-9_]*_noc|sgc|sgc_[a-z0-9_]*|[a-z0-9_]*_sgc)$"
    for name in names(data)
        column = data[!, name]
        if occursin(code_columns, name)
            data[!, name] = [ismissing(x) ? missing : string(x) for x in column]
            continue
        end
        eltype(column) <: Union{Missing, AbstractString} || continue
        values = collect(skipmissing(column))
        (isempty(values) || any(v -> occursin(r"^-?0[0-9]", v), values)) && continue
        any(v -> isnothing(tryparse(Float64, v)), values) && continue
        whole = all(v -> !isnothing(tryparse(Int, v)), values)
        data[!, name] = [
            ismissing(x) ? missing : parse(whole ? Int : Float64, x) for x in column
        ]
    end

    Excel (Power Query)

    // ============================================================
    // Bank of Canada Valet: V39079
    // Purpose: Fetch the data behind MapleStats MCP's boc_get_observations
    //          (exact: Valet request rebuilt from the tool's arguments)
    // Inputs:  https://www.bankofcanada.ca/valet/observations/V39079/json?recent=3
    // Outputs: the prepared table, loaded to a worksheet or the Data Model
    // How to run: Excel > Data > Get Data > From Other Sources > Blank Query >
    //   Advanced Editor; paste this query, Done, then Close & Load. Answer the
    //   first prompt with Anonymous access; Data > Refresh All fetches it again.
    //   A worksheet holds 1,048,576 rows: load a larger table (a full StatCan
    //   table can be) with Close & Load To > Only Create Connection > Add this
    //   data to the Data Model.
    // ============================================================
    let
        // 0. Setup
        // Cell values as text or number, null-safe, for the filters and checks.
        AsText = (value as any) as text =>
            if value = null then "" else (try Text.From(value) otherwise ""),
        AsNumber = (value as any) as nullable number =>
            if value = null then null else (try Number.From(value, "en-US") otherwise null),
        // Records to a table with every field any record has, not only the first's.
        ToTable = (records as list) as table =>
            Table.FromRecords(
                records,
                List.Distinct(List.Combine(List.Transform(records, Record.FieldNames))),
                MissingField.UseNull
            ),
        // 1. Read inputs
        Raw = Web.Contents("https://www.bankofcanada.ca/valet/observations/V39079/json?recent=3"),
        Payload = Json.Document(Raw),
        Loaded = ToTable(Record.Field(Payload, "observations")),
        // 2. Check inputs
        // Stop with a clear message instead of loading an empty table.
        Checked = if Table.IsEmpty(Loaded)
            then error Error.Record("MapleStats", "https://www.bankofcanada.ca/valet/observations/V39079/json?recent=3 returned no rows")
            else Loaded,
        // 3. Prepare data
        // Valet nests each series as <series>[v]; make one row per date and series.
        Long = Table.UnpivotOtherColumns(Checked, {"d"}, "series", "cell"),
        Valued = Table.AddColumn(
            Long, "value", each try Number.From([cell][v], "en-US") otherwise null, type number
        ),
        Tidy = Table.RenameColumns(Table.SelectColumns(Valued, {"d", "series", "value"}), {{"d", "date"}}),
        // Standard cleaning, as the R script's clean_names() and type_convert():
        // snake_case names without accents (PÉRIODE -> periode, referenceNumber ->
        // reference_number), names that clean alike numbered (indicator,
        // indicator_2), trimmed text, empty text as null, then columns whose
        // every value is a number or an ISO date (YYYY-MM-DD) converted.
        Accents = [#"à" = "a", #"â" = "a", #"ä" = "a", #"á" = "a", #"ç" = "c", #"é" = "e", #"è" = "e", #"ê" = "e", #"ë" = "e", #"î" = "i", #"ï" = "i", #"í" = "i", #"ô" = "o", #"ö" = "o", #"ó" = "o", #"ù" = "u", #"û" = "u", #"ü" = "u", #"ú" = "u", #"ÿ" = "y", #"ñ" = "n", #"œ" = "oe", #"æ" = "ae", #"À" = "A", #"Â" = "A", #"Ä" = "A", #"Á" = "A", #"Ç" = "C", #"É" = "E", #"È" = "E", #"Ê" = "E", #"Ë" = "E", #"Î" = "I", #"Ï" = "I", #"Í" = "I", #"Ô" = "O", #"Ö" = "O", #"Ó" = "O", #"Ù" = "U", #"Û" = "U", #"Ü" = "U", #"Ú" = "U", #"Ÿ" = "Y", #"Ñ" = "N", #"Œ" = "OE", #"Æ" = "AE"],
        CleanName = (name as text) as text =>
            let
                Plain = Text.Combine(
                    List.Transform(Text.ToList(name), (ch) => Record.FieldOrDefault(Accents, ch, ch))
                ),
                Words = Splitter.SplitTextByCharacterTransition({"a".."z", "0".."9"}, {"A".."Z"})(
                    Plain
                ),
                Lower = Text.Lower(Text.Combine(Words, "_")),
                Spaced = Text.Combine(
                    List.Transform(
                        Text.ToList(Lower), (ch) => if List.Contains(NameCharacters, ch) then ch else " "
                    )
                ),
                Snake = Text.Combine(List.Select(Text.Split(Spaced, " "), (part) => part <> ""), "_")
            in
                if Snake = "" then "x" else Snake,
        NameCharacters = {"a".."z", "0".."9"},
        OldNames = Table.ColumnNames(Tidy),
        CleanNames = List.Transform(OldNames, CleanName),
        NewNames = List.Transform(
            List.Positions(CleanNames),
            (i) =>
                let
                    Earlier = List.Count(
                        List.Select(List.FirstN(CleanNames, i), (name) => name = CleanNames{i})
                    )
                in
                    if Earlier = 0 then CleanNames{i} else CleanNames{i} & "_" & Text.From(Earlier + 1)
        ),
        Renamed = Table.RenameColumns(
            Tidy,
            List.Select(List.Zip({OldNames, NewNames}), (pair) => pair{0} <> pair{1})
        ),
        Trimmed = Table.TransformColumns(
            Renamed,
            List.Transform(
                Table.ColumnNames(Renamed),
                (name) =>
                    {
                        name,
                        (value) =>
                            if value is text
                            then (if Text.Trim(value) = "" then null else Text.Trim(value))
                            else value
                    }
            )
        ),
        IsNumberText = (value as any) as logical =>
            value is number
            or (value is text and (try Number.FromText(value, "en-US") otherwise null) <> null),
        IsIsoDate = (value as any) as logical =>
            value is text
            and Text.Length(value) = 10
            and Text.Middle(value, 4, 1) = "-"
            and Text.Middle(value, 7, 1) = "-"
            and (try Date.FromText(value, "en-US") otherwise null) <> null,
        ColumnsWhere = (table as table, test as function) as list =>
            List.Select(
                Table.ColumnNames(table),
                (name) =>
                    let
                        Values = List.RemoveNulls(Table.Column(table, name))
                    in
                        not List.IsEmpty(Values) and List.AllTrue(List.Transform(Values, test))
            ),
        // Codes stay text as the source wrote them: columns named like one
        // (coordinate, vector_id, dguid, NAICS, postal code; StatCan's "2.1" and
        // "2.10" are different coordinates) and columns with a leading zero (01).
        CodeName = (name as text) as logical =>
            List.Contains(
                {"coordinate", "vector", "vector_id", "vectorid", "product_id", "productid", "pid",
                  "dguid", "postal_code", "postalcode", "fsa", "noc", "sgc"},
                name
            )
            or Text.EndsWith(name, "_dguid")
            or Text.EndsWith(name, "_postal_code")
            or Text.Contains(name, "naics")
            or Text.StartsWith(name, "noc_")
            or Text.EndsWith(name, "_noc")
            or Text.StartsWith(name, "sgc_")
            or Text.EndsWith(name, "_sgc"),
        HasLeadingZero = (value as any) as logical =>
            value is text
            and (
                let
                    Digits = if Text.StartsWith(value, "-") then Text.Middle(value, 1) else value
                in
                    Text.Length(Digits) > 1
                    and Text.Start(Digits, 1) = "0"
                    and List.Contains({"0".."9"}, Text.Middle(Digits, 1, 1))
            ),
        CodeColumns = List.Select(
            Table.ColumnNames(Trimmed),
            (name) => CodeName(name) or List.AnyTrue(List.Transform(Table.Column(Trimmed, name), HasLeadingZero))
        ),
        Codes = Table.TransformColumns(
            Trimmed,
            List.Transform(
                CodeColumns,
                (name) =>
                    {
                        name,
                        (value) =>
                            if value = null then null
                            else if value is number then Number.ToText(value, "G", "en-US")
                            else Text.From(value),
                        type text
                    }
            )
        ),
        NumberColumns = List.Difference(ColumnsWhere(Codes, IsNumberText), CodeColumns),
        Numbers = Table.TransformColumnTypes(
            Codes, List.Transform(NumberColumns, (name) => {name, type number}), "en-US"
        ),
        DateColumns = ColumnsWhere(Numbers, IsIsoDate),
        Cleaned = Table.TransformColumns(
            Numbers,
            List.Transform(
                DateColumns,
                (name) => {name, (value) => if value = null then null else Date.FromText(value, "en-US"), type date}
            )
        ),
        Data = Cleaned
    in
        Data

Connect

Add it to your client

Your client starts the server with uv when it needs it. There is nothing to host and no port to open.

Full setup, hosting and troubleshooting

Claude Code

Run this once in a terminal. --scope user makes the server available in every project; leave it out to add it to the current project only.

Terminal
claude mcp add --scope user maplestats -- uvx maplestats-mcp

Claude Desktop

In Claude Desktop, open Settings, then Developer, then Edit Config. Add the server to the file that opens, save it and restart Claude.

claude_desktop_config.json
{
  "mcpServers": {
    "maplestats": {
      "command": "uvx",
      "args": ["maplestats-mcp"]
    }
  }
}

The file lives at ~/Library/Application Support/Claude/claude_desktop_config.json on macOS and %APPDATA%\Claude\claude_desktop_config.json on Windows.

Cursor

The link opens Cursor with the entry filled in. To add it by hand, put it in ~/.cursor/mcp.json for every project, or in .cursor/mcp.json for one project.

~/.cursor/mcp.json
{
  "mcpServers": {
    "maplestats": {
      "command": "uvx",
      "args": ["maplestats-mcp"]
    }
  }
}

VS Code

To add it by hand, note that VS Code uses a servers key, not mcpServers. Put this in .vscode/mcp.json in a workspace, or run MCP: Open User Configuration from the Command Palette to add it for every workspace.

.vscode/mcp.json
{
  "servers": {
    "maplestats": {
      "type": "stdio",
      "command": "uvx",
      "args": ["maplestats-mcp"]
    }
  }
}

Codex CLI

Add it from the terminal, or write the same entry into ~/.codex/config.toml yourself.

Terminal
codex mcp add maplestats -- uvx maplestats-mcp
~/.codex/config.toml
[mcp_servers.maplestats]
command = "uvx"
args = ["maplestats-mcp"]

Gemini CLI

Add it from the terminal (-s user for every project), or write the entry into ~/.gemini/settings.json next to any settings already there.

Terminal
gemini mcp add -s user maplestats uvx maplestats-mcp
~/.gemini/settings.json
{
  "mcpServers": {
    "maplestats": {
      "command": "uvx",
      "args": ["maplestats-mcp"]
    }
  }
}

Other clients

Most MCP clients accept this mcpServers entry. If you installed the command with uv tool install or pip, use "command": "maplestats-mcp" and drop args.

JSON
{
  "mcpServers": {
    "maplestats": {
      "command": "uvx",
      "args": ["maplestats-mcp"]
    }
  }
}

Every source. One server.

The square: 59 federal and international publishers around the outside, the provinces and cities with local sources inside, and 504 tools as segments by subjectABS (Australia) · Bank of Canada · BIS statistics · Borealis · Canada Gazette · CBSA · CDC · CER · CFIA · CGC · CIHI · CMHC · Competition Bureau · CRA charities · CRA digital economy · CRA tax statistics · CREA · CRTC telecom prices · Customs Tariff · DFO landings · DFO tides · Earthquakes Canada · ECB · ECCC · ECCC Data Catalogue · Elections Canada · Elections Canada (historical results) · Eurostat · FCAC · Federal Reserve · Finance Canada · GC InfoBase · Health Canada · House of Commons · ILOSTAT (International Labour Organization) · IMF · IRCC · ISC First Nations · ISED · Job Bank · National Forestry Database · NRCan burned areas · NRCan energy use · NRCan minerals · NRCan places · NRCan wildfires · OECD statistics · ONS (United Kingdom) · PBO · PHAC Health Infobase · PMPRB · PMRA · Proactive disclosure · Recalls · Represent · Senate · StatCan · Transport Canada · World Bank WDI · ABS (Australia) · Bank of Canada · BIS statistics · Borealis · Canada Gazette · CBSA · CDC · CER · CFIA · CGC · CIHI · CMHC · Competition Bureau · CRA charities · CRA digital economy · CRA tax statistics · CREA · CRTC telecom prices · Customs Tariff · DFO landings · DFO tides · Earthquakes Canada · ECB · ECCC · ECCC Data Catalogue · Elections Canada · Elections Canada (historical results) · Eurostat · FCAC · Federal Reserve · Finance Canada · GC InfoBase · Health Canada · House of Commons · ILOSTAT (International Labour Organization) · IMF · IRCC · ISC First Nations · ISED · Job Bank · National Forestry Database · NRCan burned areas · NRCan energy use · NRCan minerals · NRCan places · NRCan wildfires · OECD statistics · ONS (United Kingdom) · PBO · PHAC Health Infobase · PMPRB · PMRA · Proactive disclosure · Recalls · Represent · Senate · StatCan · Transport Canada · World Bank WDI · British Columbia · Abbotsford · BC Transit real-time · Burnaby · Coquitlam · Delta · Kamloops · Kelowna · Maple Ridge · Nanaimo GIS · New Westminster · Penticton · Port Moody · Prince George · Saanich · Surrey · Transit schedules · Vancouver · Victoria · White Rock · Alberta · Airdrie · Calgary · Canmore · Cochrane · Edmonton · Grande Prairie · Lethbridge · Medicine Hat · Okotoks · Parkland · Red Deer · St. Albert · Strathcona · Sturgeon · Transit schedules · Saskatchewan · Regina · Saskatoon · Transit schedules · Manitoba · Transit schedules · Winnipeg · Ontario · Aurora · Barrie · Brampton · Burlington · Cambridge · Central Lake Ontario Conservation Authority · Conservation Halton · Credit Valley Conservation · Data Kingston · Durham · Greater Sudbury · Guelph · Hamilton Conservation Authority · Kitchener · London · Markham · Milton · Mississauga · Newmarket · Niagara · Oakville · Orangeville · Oshawa · Ottawa · Peel · Peterborough · Pickering · Quinte Conservation Authority · Sarnia · St Catharines · Thunder Bay · Toronto · Transit schedules · Waterloo · Whitby · Windsor · York · Quebec · Montreal · Transit schedules · New Brunswick · Fredericton · Moncton · Saint John · Transit schedules · Nova Scotia · Halifax · Transit schedules · Prince Edward Island · Transit schedules · Newfoundland and Labrador · Transit schedules · Yukon · Transit schedules · Northwest Territories · Transit schedules · Yellowknife · British Columbia · Abbotsford · BC Transit real-time · Burnaby · Coquitlam · Delta · Kamloops · Kelowna · Maple Ridge · Nanaimo GIS · New Westminster · Penticton · Port Moody · Prince George · Saanich · Surrey · Transit schedules · Vancouver · Victoria · White Rock · Alberta · Airdrie · Calgary · Canmore · Cochrane · Edmonton · Grande Prairie · Lethbridge · Medicine Hat · Okotoks · Parkland · Red Deer · St. Albert · Strathcona · Sturgeon · Transit schedules · Saskatchewan · Regina · Saskatoon · Transit schedules · Manitoba · Transit schedules · Winnipeg · Ontario · Aurora · Barrie · Brampton · Burlington · Cambridge · Central Lake Ontario Conservation Authority · Conservation Halton · Credit Valley Conservation · Data Kingston · Durham · Greater Sudbury · Guelph · Hamilton Conservation Authority · Kitchener · London · Markham · Milton · Mississauga · Newmarket · Niagara · Oakville · Orangeville · Oshawa · Ottawa · Peel · Peterborough · Pickering · Quinte Conservation Authority · Sarnia · St Catharines · Thunder Bay · Toronto · Transit schedules · Waterloo · Whitby · Windsor · York · Quebec · Montreal · Transit schedules · New Brunswick · Fredericton · Moncton · Saint John · Transit schedules · Nova Scotia · Halifax · Transit schedules · Prince Edward Island · Transit schedules · Newfoundland and Labrador · Transit schedules · Yukon · Transit schedules · Northwest Territories · Transit schedules · Yellowknife · Provinces and cities: open-data catalogues, provincial, municipal (157)Statistics: statistics and census (155)Land and energy: agriculture and food, environment and hazards, energy and mining, geography, transport and safety (57)Money and business: money, prices and public finance, business, IP and competition (51)People: health, housing, immigration (49)Parliament: parliament, law and elections (24)Provinces and cities 157Statistics 155Land and energy 57Money and business 51People 49Parliament 24
Show the data
The 504 tools by subject (the segments); MapleStats' own tools are counted only in the total
SubjectTools
Provinces and cities: open-data catalogues, provincial, municipal157
Statistics: statistics and census155
Land and energy: agriculture and food, environment and hazards, energy and mining, geography, transport and safety57
Money and business: money, prices and public finance, business, IP and competition51
People: health, housing, immigration49
Parliament: parliament, law and elections24