Banxico MCP Server

Banxico MCP Server

Enables access to Bank of Mexico (Banxico) economic data including real-time and historical USD/MXN exchange rates, inflation data, interest rates, and other financial indicators. Supports querying current rates, historical data with date ranges, and economic metadata through natural language.

Category
访问服务器

README

Banxico MCP Server

A Model Context Protocol (MCP) server for accessing the Bank of Mexico (Banxico) SIE API to retrieve USD/MXN exchange rate data and other economic indicators.

License: MIT Python 3.10+

Features

  • Real-time Exchange Rates: Get the latest USD/MXN exchange rate from Banxico
  • Historical Data: Retrieve historical exchange rate data with customizable limits
  • Series Metadata: Access detailed information about economic data series
  • Date Range Queries: Get exchange rate data for specific date ranges
  • MCP Compatible: Works with Claude Desktop, Gemini CLI, and other MCP clients

Prerequisites

  1. Python 3.10+ installed on your system
  2. uvx (recommended) or uv package manager
  3. Banxico API Token - Get one from Banxico SIE API

Installation Methods

Option 1: Direct from GitHub (Auto-Updates) ⭐ Recommended

This method automatically gets the latest updates when you restart your MCP client:

Configuration for MCP clients:

"banxico": {
  "command": "uvx",
  "args": [
    "--from",
    "git+https://github.com/cfocoder/banxico_mcp",
    "banxico-mcp-server"
  ],
  "env": {
    "BANXICO_API_TOKEN": "your_token_here"
  }
}

No manual installation needed! uvx will automatically download and run the latest version.

Option 2: Download Single File (Manual Updates)

If you prefer to download the file locally:

  1. Install uvx (if not already installed):

    pip install uv
    
  2. Download the server file:

    curl -O https://raw.githubusercontent.com/cfocoder/banxico_mcp/main/banxico_mcp_server.py
    
  3. Configuration for MCP clients:

    "banxico": {
      "command": "uvx",
      "args": [
        "--python", "3.12",
        "--from", "fastmcp",
        "--with", "httpx",
        "--",
        "python",
        "/absolute/path/to/banxico_mcp_server.py"
      ],
      "env": {
        "BANXICO_API_TOKEN": "your_token_here"
      }
    }
    

    To get updates: Re-download the file when new features are added.

Option 3: Traditional Installation

  1. Clone the repository:

    git clone https://github.com/cfocoder/banxico_mcp.git
    cd banxico_mcp
    
  2. Install dependencies:

    pip install fastmcp httpx
    
  3. Run the server:

    BANXICO_API_TOKEN=your_token_here python banxico_mcp_server.py
    

Configuration

Get Your Banxico API Token

  1. Visit Banxico Token Registration
  2. Fill out the form to request an API token
  3. You'll receive your token via email

Configure MCP Clients

Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "banxico": {
      "command": "uvx",
      "args": [
        "--python", "3.12",
        "--from", "fastmcp",
        "--with", "httpx",
        "--",
        "python",
        "/absolute/path/to/banxico_mcp_server.py"
      ],
      "env": {
        "BANXICO_API_TOKEN": "your_banxico_token_here"
      }
    }
  }
}

Gemini CLI

Add to ~/.gemini/settings.json:

{
  "mcpServers": {
    "banxico": {
      "command": "uvx",
      "args": [
        "--python", "3.12",
        "--from", "fastmcp",
        "--with", "httpx",
        "--",
        "python",
        "/absolute/path/to/banxico_mcp_server.py"
      ],
      "env": {
        "BANXICO_API_TOKEN": "your_banxico_token_here"
      }
    }
  }
}

Available Tools

Tool Description Parameters
get_latest_usd_mxn_rate() Get the most recent USD/MXN exchange rate None
get_usd_mxn_historical_data(limit) Get historical exchange rate data limit: Max data points (default: 30)
get_series_metadata(series_id) Get metadata for a data series series_id: Series ID (default: SF63528)
get_date_range_data(start_date, end_date, series_id) Get data for specific date range start_date, end_date: YYYY-MM-DD format
get_inflation_data(inflation_type, limit) Get inflation data inflation_type: 'monthly', 'accumulated', 'annual' (default: 'monthly')<br>limit: Max data points (default: 12)
get_udis_data(limit) Get UDIS (Investment Units) values limit: Max data points (default: 30)
get_cetes_28_data(limit) Get CETES 28-day interest rates limit: Max data points (default: 30)
get_banxico_reserves_data(limit) Get Banxico Reserve Assets data limit: Max data points (default: 30)
get_unemployment_data(limit) Get unemployment rate data limit: Max data points (default: 24)

Usage Examples

Once configured with your MCP client, you can ask:

Exchange Rates:

  • "What's the current USD to MXN exchange rate?"
  • "Show me the USD/MXN exchange rate for the last 10 days"
  • "Get the exchange rate data from 2024-01-01 to 2024-01-31"
  • "What's the metadata for the USD/MXN series?"

Inflation Data:

  • "What's the current monthly inflation rate in Mexico?"
  • "Show me the annual inflation data for the last year"
  • "Get the accumulated inflation for the last 6 months"

Interest Rates:

  • "What are the current CETES 28-day rates?"
  • "Show me the CETES rates for the last month"

Financial Indicators:

  • "What are the current UDIS values?"
  • "Show me Banxico's reserve assets"
  • "Get the latest financial indicators from Banxico"

Labor Market:

  • "What's the current unemployment rate in Mexico?"
  • "Show me unemployment trends for the last year"
  • "How has unemployment changed over the last 2 years?"

API Reference

The server uses the Banxico SIE API with the following endpoints:

Exchange Rates:

  • Latest Data: /series/SF63528/datos/oportuno
  • Historical Data: /series/SF63528/datos
  • Series Metadata: /series/SF63528
  • Date Range: /series/SF63528/datos/{start_date}/{end_date}

Inflation Data:

  • Monthly Inflation: /series/SP30577/datos
  • Accumulated Inflation: /series/SP30579/datos
  • Annual Inflation: /series/SP30578/datos

Financial Indicators:

  • UDIS: /series/SP68257/datos
  • CETES 28-day: /series/SF282/datos
  • Banxico Reserves: /series/SF308843/datos

Labor Market:

  • Unemployment Rate: /series/SL1/datos

Development

Project Structure

banxico-mcp-server/
├── banxico_mcp_server.py    # Main server file
├── README.md                # This file
├── LICENSE                  # MIT License
├── CONTRIBUTING.md          # Development guidelines
└── docs/                    # Documentation and examples
    ├── EXTENDING.md         # Guide for adding new endpoints
    └── examples/            # Configuration examples
        ├── claude-desktop.md
        ├── continue.md
        ├── env-template.md
        ├── gemini-cli.md
        └── vscode-cline.md

Testing

To test the server without an MCP client:

# Set your token
export BANXICO_API_TOKEN=your_token_here

# Run the server with a timeout to test startup
timeout 5s python banxico_mcp_server.py && echo "Server starts successfully"

Adding New Tools

See EXTENDING.md for detailed instructions on adding new Banxico API endpoints.

Troubleshooting

Common Issues

  1. "BANXICO_API_TOKEN environment variable not set"

    • Ensure your API token is properly configured in the MCP client settings
  2. "Failed to retrieve data"

    • Check your internet connection
    • Verify your API token is valid
    • Ensure the Banxico API is accessible
  3. Server doesn't start

    • Verify Python 3.10+ is installed
    • Check that uvx or required dependencies are available

Debug Mode

Run with debug logging:

BANXICO_API_TOKEN=your_token PYTHONPATH=. python -c "
import logging
logging.basicConfig(level=logging.DEBUG)
from banxico_mcp_server import mcp
mcp.run()
"

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Related Projects

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选