Skip to main content
Glama

PyPI Python Publish License: MIT

BCRP MCP

Servidor Model Context Protocol (MCP) para consultar BCRPData, la base oficial de estadísticas económicas del Banco Central de Reserva del Perú (BCRP).

Permite a clientes MCP y agentes de IA consultar tipos de cambio, tasas de interés, reservas internacionales, liquidez, crédito, commodities, bolsa y PBI. La API del BCRP es pública: no se necesita API key ni registro.

Instalación inicial

Se requiere Python 3.11 o posterior. La opción recomendada es uv, un gestor rápido de Python que crea los entornos y administra las dependencias automáticamente.

1. Instalar uv y agregarlo al PATH

Windows — PowerShell

irm https://astral.sh/uv/install.ps1 | iex

El instalador agrega uv a la ruta de usuario, normalmente %USERPROFILE%\.local\bin. Cierra y vuelve a abrir PowerShell, y verifica la instalación:

uv --version
Get-Command uv

Si uv no se encuentra en una terminal ya abierta, agrega la ruta solo para la sesión actual:

$env:Path = "$HOME\.local\bin;$env:Path"
uv --version

macOS y Linux

curl -LsSf https://astral.sh/uv/install.sh | sh
source "$HOME/.local/bin/env"
uv --version

Si tu shell no reconoce uv, agrega la ruta al PATH de forma permanente:

echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

Para Zsh, usa ~/.zshrc en lugar de ~/.bashrc. En macOS y Linux, el instalador normalmente configura esta ruta automáticamente.

2. Instalar BCRP MCP

Ejecución directa con uvx — recomendada para clientes MCP

uvx descarga y ejecuta la versión publicada sin modificar el proyecto local:

uvx bcrp-mcp

Para comprobar que el paquete está disponible en PyPI:

uvx bcrp-mcp --help

Instalación persistente como herramienta de uv

uv tool install bcrp-mcp
uv tool update-shell
bcrp-mcp --help

uv tool update-shell agrega el directorio de herramientas de uv al PATH. Reinicia la terminal si el comando todavía no aparece.

Con pip

python -m pip install bcrp-mcp
bcrp-mcp

La instalación también proporciona el CLI bcrp:

bcrp --help
bcrp catalog search "tipo de cambio"
bcrp series latest PD04637PD --n 5

3. Configuración inicial

No se requiere API key, cuenta ni archivo de credenciales. La configuración predeterminada funciona directamente contra la API pública de BCRPData.

Para personalizar el comportamiento, copia el archivo de ejemplo y edita los valores:

cp .env.example .env       # macOS/Linux
Copy-Item .env.example .env # Windows PowerShell

Las variables disponibles son BCRP_CACHE_TTL, BCRP_TIMEOUT, BCRP_MAX_RETRIES, BCRP_LANGUAGE y LOG_LEVEL. Consulta la sección Configuración opcional.

Comprueba la instalación y la conexión al catálogo local:

bcrp --version
bcrp catalog categories
bcrp catalog search "tipo de cambio"
bcrp series latest PD04637PD --n 5

4. Configurar el cliente MCP

El servidor usa transporte stdio. En Claude Desktop, Claude Code, Cursor y otros clientes compatibles, añade esta configuración:

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

Con uv tool install, también puedes usar el ejecutable directamente:

{
  "mcpServers": {
    "bcrp": {
      "command": "bcrp-mcp",
      "args": []
    }
  }
}

En VS Code + GitHub Copilot, guarda esta variante en .vscode/mcp.json:

{
  "servers": {
    "bcrp": {
      "type": "stdio",
      "command": "uvx",
      "args": ["bcrp-mcp"]
    }
  }
}

Reinicia el cliente MCP después de guardar la configuración y verifica que aparezca el servidor bcrp y sus herramientas.

Instalación desde el código fuente

git clone https://github.com/JOSETRA44/BCRP-mcp.git
cd BCRP-mcp
uv sync
uv run bcrp-mcp

Related MCP server: mcp-bcrp

Herramientas MCP

Herramienta

Uso

bcrp_get_series

Obtiene 1–10 series con un rango opcional; deben compartir frecuencia.

bcrp_get_latest

Obtiene los últimos valores de 1–10 series.

bcrp_get_series_long

Exporta hasta 50 series en una tabla larga, incluso con frecuencias mixtas.

bcrp_describe_series

Consulta nombre, frecuencia y rango disponible de una serie.

bcrp_search_catalog

Busca códigos en el catálogo curado de indicadores.

bcrp_list_catalog_categories

Lista las categorías disponibles.

bcrp_get_macro_snapshot

Devuelve un resumen de indicadores macroeconómicos clave.

Ejemplos de preguntas:

¿Cuál es el tipo de cambio actual en Perú?
Compara la tasa de referencia y las reservas internacionales desde 2020.
Obtén un snapshot de los principales indicadores de la economía peruana.

CLI

El comando bcrp usa la misma lógica que el servidor MCP y admite salida para terminal o automatización:

bcrp series describe PD04637PD
bcrp series latest PD04637PD PD12301MD --n 5
bcrp series get PN00196MM --start 2020-1 --end 2024-12
bcrp catalog categories
bcrp macro snapshot

Opciones útiles:

bcrp series latest PD04637PD --n 5 --json
bcrp series latest PD04637PD --n 5 --ascii --no-color

Los formatos de período dependen de la frecuencia: diario DD-MM-YYYY, mensual YYYY-M, trimestral YYYY-Q y anual YYYY. Las series de una misma consulta deben tener la misma frecuencia, salvo bcrp_get_series_long.

Configuración opcional

Todos los valores tienen valores predeterminados razonables y pueden definirse con variables de entorno o un archivo .env:

Variable

Predeterminado

Descripción

BCRP_CACHE_TTL

300

Duración de la caché en segundos; 0 la desactiva.

BCRP_TIMEOUT

30

Timeout HTTP en segundos.

BCRP_MAX_RETRIES

3

Reintentos ante errores transitorios.

BCRP_LANGUAGE

esp

Idioma de nombres: esp o ing.

LOG_LEVEL

INFO

Nivel de logging.

No se configura ninguna credencial: BCRPData es de acceso abierto.

Desarrollo

uv sync
uv run pytest -q
uv run python -m build

El proyecto usa src/ layout, Hatchling para construir el paquete y publica dos entry points: bcrp-mcp (servidor) y bcrp (CLI).

Publicación

Las versiones se publican mediante GitHub Actions al crear un release de GitHub. El workflow .github/workflows/publish.yml ejecuta las pruebas, construye los artefactos y publica en PyPI usando Trusted Publishing (OIDC); no requiere un token de PyPI almacenado en secretos.

Datos y licencia

Los datos provienen de BCRPData. Consulte sus condiciones de uso.

MIT — consulte LICENSE.

Documentación del proyecto

Available Tools

7 tools
bcrp_describe_seriesA

Get metadata about 1–10 BCRP series without fetching all data points.

Returns series names, frequency, decimal precision, and available date range. Use this to verify series codes exist and understand what they measure before fetching large date ranges with bcrp_get_series.

Inputs: series_codes (required), language.

bcrp_get_latestA

Get the most recent data points for 1–10 BCRP series (same frequency).

Convenience wrapper around bcrp_get_series that fetches latest data without specifying a date range, then returns only the last n_periods values.

Prefer this over bcrp_get_series when the question is "what is it now?" — today's exchange rate, the current policy rate. Use bcrp_get_series for a specific historical window, and bcrp_get_series_long for many series at once or mixed frequencies.

Results are cached on disk; n_periods accepts 1–50 and defaults to 5.

Example codes:

  • Daily rates/prices: PD04637PD, PD12301MD, PD04650MD, PD04701XD

  • Monthly monetary: PN00196MM, PN00496MM, PN00178MM

  • Quarterly growth: PN03503MQ, PN03501MQ

Inputs: series_codes (required), language, n_periods.

bcrp_get_macro_snapshotA

Fetch a real-time snapshot of Peru's key macroeconomic indicators in one call.

Returns the latest values for: Daily indicators:

  • Exchange rate (TC Interbancario S/ por US$)

  • BCRP policy rate (%)

  • International reserves (millions US$)

  • Copper price (cUS$ per pound)

  • Lima stock market index (BVL)

Monthly indicators (last 3 months):

  • Total liquidity M2 (millions S/)

  • Private sector credit (millions S/)

  • Currency in circulation (millions S/)

  • Credit growth 12-month (%)

Use bcrp_get_series for custom date ranges or additional series.

Inputs: language.

bcrp_get_seriesA

Fetch time series data from the BCRP (Banco Central de Reserva del Perú) API.

Accepts 1–10 series codes of the SAME frequency. Series codes can be found using bcrp_search_catalog or the bcrp://series-catalog resource.

Period format by frequency:

  • Monthly: YYYY-M (e.g. 2024-1 = January 2024, 2024-12 = December 2024)

  • Quarterly: YYYY-Q (e.g. 2024-1 = Q1 2024, 2024-4 = Q4 2024)

  • Daily: DD-MM-YYYY (e.g. 01-01-2025)

  • Annual: YYYY (e.g. 2024)

  • Leave both periods empty to get the most recent available data.

Important: All series in one call must have the same frequency (all daily, all monthly, etc.). Need MORE than 10 series, or a mix of frequencies? Use bcrp_get_series_long instead — up to 50 codes of any frequencies, returned as one tidy long table.

Responses are cached on disk between calls, so repeating a query is free. An empty series list means the code is valid but has no data in that range, not that the code is wrong — check it with bcrp_describe_series.

Example codes: PD04637PD (exchange rate), PD12301MD (policy rate), PN00196MM (total liquidity), PN03503MQ (GDP var%)

Inputs: series_codes (required), language, end_period, start_period.

bcrp_get_series_longA

Fetch MANY BCRP series at once as one tidy long-format table.

Unlike bcrp_get_series, the codes do NOT have to share a frequency and the limit is 50 rather than 10 — each series is fetched separately, so the code→value mapping is always correct.

Returns rows of {series_code, period, date, value}. date is an ISO-sortable rendering of BCRP's human period label. Missing observations are omitted rather than emitted as nulls.

Set all_history=true to pull each series' entire published history (bounded by max_rows).

Inputs: series_codes (required), language, max_rows, end_period, +2 more.

bcrp_list_catalog_categoriesA

List all available categories in the BCRP series catalog.

Returns category IDs (usable as the category filter in bcrp_search_catalog), the number of series per category, and their frequency.

Categories include: exchange rates, interest rates, international reserves, liquidity (M1/M2), credit, financial markets, commodities, and GDP.

Inputs: no named parameters.

bcrp_search_catalogA

Search the built-in catalog of important BCRP series by keyword.

Returns matching series codes, names, descriptions, frequency, units, and the period format needed to query them with bcrp_get_series.

Example queries:

  • 'tipo de cambio' → exchange rate series

  • 'tasa referencia' → BCRP policy rate

  • 'reservas internacionales' → international reserves

  • 'cobre' → copper price

  • 'liquidez' → monetary liquidity (M1/M2)

  • 'credito' → private sector credit

  • 'BVL' → Lima stock exchange index

  • 'PBI' → GDP quarterly series

Use bcrp_list_catalog_categories to see all available categories.

Inputs: query (required), category, frequency.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4.4/5.0

    Scored across 7 tools

    Disambiguation4/5

    Each tool has a distinct role, and the descriptions explicitly cross-reference when to use which sibling (e.g. get_series vs get_series_long vs get_latest vs get_macro_snapshot). The only real overlap is that get_latest, get_series_long, and get_macro_snapshot are all convenience wrappers over get_series, but the descriptions define clear boundaries between them.

    Naming Consistency5/5

    All seven tools follow the same `bcrp_<verb>_<noun>` pattern with a uniform prefix and snake_case throughout (get_series, get_series_long, describe_series, search_catalog, list_catalog_categories, get_macro_snapshot). No mixed conventions or vague verbs.

    Tool Count5/5

    Seven tools is well-scoped for a central-bank data API: catalog discovery, series metadata, three query shapes (windowed, latest, bulk long), and one curated snapshot. Each tool earns its place without redundant surface.

    Completeness4/5

    The lifecycle is well covered — discover series (search_catalog, list_catalog_categories), validate them (describe_series), and fetch them at multiple granularities. Minor gaps: no direct 'list all series in a category' browse tool (only keyword search with a category filter) and no export/serialization option beyond the returned tables.

    Maintenance

    ActivityMaintained
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      A
      quality
      D
      maintenance
      Model Context Protocol server that provides access to economic and financial time series data from Peru's Central Reserve Bank, enabling AI agents to search, explore, and analyze Peru's economic indicators through a standardized interface.
      3
      4
      -
    • A
      license
      A
      quality
      D
      maintenance
      Provides access to over 5,000 macroeconomic indicators from the Banco Central de Reserva del Perú (BCRP) statistical database. It enables AI agents to search for indicators, fetch time-series data, and generate professional economic charts.
      4
      10 PyPI
      1
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Enables AI agents to access SEC EDGAR filings, US Treasury rates, BLS labor statistics, and economic indicators without API keys.
      6
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Connects MCP-compatible AI agents to Peru's official statistics platform (INEI Estadist), providing access to Census 2017 data, population indicators, and geographic profiles for all Peruvian departments, provinces, and districts without requiring an API key.
      9
      MIT