BCRP Statistical API MCP Server

Access over 5,000 macroeconomic indicators from the BCRP statistical database.

README.md

mcp-bcrp

MCP Server and Python library for the Banco Central de Reserva del Perú (BCRP) Statistical API. Access over 5,000 macroeconomic indicators directly from your AI agent or Python environment.


Overview

The mcp-bcrp package provides a standardized interface to the BCRP statistical database through the Model Context Protocol (MCP). It supports both direct Python usage and integration with AI assistants such as Claude, Gemini, and other MCP-compatible agents.

The library implements:

  • Asynchronous HTTP client for efficient data retrieval
  • Deterministic search engine with fuzzy matching capabilities
  • Spanish language processing for query canonicalization
  • Automatic frequency detection (daily, monthly, quarterly, annual)

Features

Feature Description
Smart Search Deterministic search engine with fuzzy matching, attribute extraction, and ambiguity detection
Async Native Built on httpx for non-blocking HTTP requests with connection pooling
Dual Interface Use as MCP server for AI agents or as standalone Python library
Chart Generation Generate publication-ready charts with automatic Spanish date parsing
Full Coverage Access to 5,000+ BCRP economic indicators across all categories
Metadata Cache Local caching of 17MB metadata file for fast offline searches

Requirements

  • Python 3.10 or higher
  • Internet connection for API requests
  • Dependencies: httpx, pandas, fastmcp, rapidfuzz, matplotlib

Installation

From PyPI (when published)

pip install mcp-bcrp

From Source

git clone https://github.com/YOUR_USERNAME/mcp-bcrp.git
cd mcp-bcrp
pip install -e .

With Optional Dependencies

pip install "mcp-bcrp[charts]"  # Include matplotlib for chart generation
pip install "mcp-bcrp[dev]"     # Include development dependencies

Configuration

MCP Server Configuration

Add the following to your MCP configuration file (e.g., mcp_config.json):

{
  "mcpServers": {
    "bcrp-api": {
      "command": "python",
      "args": ["C:/absolute/path/to/mcp_bcrp/run.py"]
    }
  }
}

[!TIP] If you have installed the package via pip, you can also use ["-m", "mcp_bcrp"] as the arguments.

Environment Variables

Variable Description Default
BCRP_CACHE_DIR Directory for metadata cache User cache dir
BCRP_TIMEOUT HTTP request timeout in seconds 120

Usage

As MCP Server

Once configured, the server can be invoked by MCP-compatible AI assistants:

User: What is the current policy interest rate in Peru?
Agent: [calls search_series("tasa politica monetaria")]
Agent: [calls get_data(["PD04722MM"], "2024-01/2025-01")]

As Python Library

import asyncio
from mcp_bcrp.client import AsyncBCRPClient, BCRPMetadata

async def main():
    # Initialize metadata client
    metadata = BCRPMetadata()
    await metadata.load()
    
    # Search for an indicator (deterministic)
    result = metadata.solve("tasa politica monetaria")
    print(result)
    # Output: {'codigo_serie': 'PD04722MM', 'confidence': 1.0, ...}
    
    # Fetch time series data
    client = AsyncBCRPClient()
    df = await client.get_series(
        series_codes=["PD04722MM"],
        start_date="2024-01",
        end_date="2025-01"
    )
    print(df.head())

asyncio.run(main())

Available Tools (MCP)

Tool Parameters Description
search_series query: str Search BCRP indicators by keyword. Returns determinis

Tools 1

search_seriesSearch BCRP indicators by keyword to find relevant series codes.

Environment Variables

BCRP_CACHE_DIRDirectory for metadata cache
BCRP_TIMEOUTHTTP request timeout in seconds

Try it

What is the current policy interest rate in Peru?
Search for indicators related to the inflation rate in Peru.
Find the series code for the exchange rate and fetch data for the last 12 months.
Get the GDP growth data for the last 5 years.

Frequently Asked Questions

What are the key features of BCRP Statistical API?

Access to over 5,000 macroeconomic indicators from the BCRP database. Deterministic search engine with fuzzy matching capabilities. Automatic frequency detection for daily, monthly, quarterly, and annual data. Asynchronous HTTP client for efficient data retrieval. Local metadata caching for fast offline searches.

What can I use BCRP Statistical API for?

Retrieving real-time Peruvian economic indicators for financial reporting. Automating the collection of time-series data for economic research. Generating publication-ready economic charts using AI agents. Integrating BCRP statistical data into custom AI-driven financial dashboards.

How do I install BCRP Statistical API?

Install BCRP Statistical API by running: pip install mcp-bcrp

What MCP clients work with BCRP Statistical API?

BCRP Statistical API works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep BCRP Statistical API docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Open Conare