๐ 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.

๐ Quick Start
This server allows you to access real - time and historical USD/MXN exchange rates and other economic indicators from Banxico via the MCP protocol.
โจ 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
๐ฆ Installation
Prerequisites
- Python 3.10+ installed on your system
- uvx (recommended) or uv package manager
- 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:
-
Install uvx (if not already installed):
pip install uv
-
Download the server file:
curl -O https://raw.githubusercontent.com/cfocoder/banxico_mcp/main/banxico_mcp_server.py
-
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
-
Clone the repository:
git clone https://github.com/cfocoder/banxico_mcp.git
cd banxico_mcp
-
Install dependencies:
pip install fastmcp httpx
-
Run the server:
BANXICO_API_TOKEN=your_token_here python banxico_mcp_server.py
๐ป 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?"
๐ Documentation
Available Tools
| Property |
Details |
get_latest_usd_mxn_rate() |
Get the most recent USD/MXN exchange rate. Parameters: None |
get_usd_mxn_historical_data(limit) |
Get historical exchange rate data. Parameters: limit: Max data points (default: 30) |
get_series_metadata(series_id) |
Get metadata for a data series. Parameters: series_id: Series ID (default: SF63528) |
get_date_range_data(start_date, end_date, series_id) |
Get data for specific date range. Parameters: start_date, end_date: YYYY - MM - DD format |
get_inflation_data(inflation_type, limit) |
Get inflation data. Parameters: inflation_type: 'monthly', 'accumulated', 'annual' (default: 'monthly'); limit: Max data points (default: 12) |
get_udis_data(limit) |
Get UDIS (Investment Units) values. Parameters: limit: Max data points (default: 30) |
get_cetes_28_data(limit) |
Get CETES 28 - day interest rates. Parameters: limit: Max data points (default: 30) |
get_banxico_reserves_data(limit) |
Get Banxico Reserve Assets data. Parameters: limit: Max data points (default: 30) |
get_unemployment_data(limit) |
Get unemployment rate data. Parameters: limit: Max data points (default: 24) |
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
๐ง Technical Details
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:
export BANXICO_API_TOKEN=your_token_here
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
โ ๏ธ Important Note
- "BANXICO_API_TOKEN environment variable not set": Ensure your API token is properly configured in the MCP client settings
- "Failed to retrieve data": Check your internet connection, verify your API token is valid, and ensure the Banxico API is accessible
- Server doesn't start: Verify Python 3.10+ is installed, and 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
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature)
- Commit your changes (
git commit -m 'Add amazing feature')
- Push to the branch (
git push origin feature/amazing-feature)
- Open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
๐ Related Projects