get_exchange_rate
Retrieve exchange rates for all currency pairs from Vietnam's stock market. Specify a date or get today's rates in JSON or dataframe format.
Instructions
Get exchange rate of all currency pairs from stock market
Args:
date: str = None (if None, return today's price. Format: YYYY-MM-DD)
output_format: Literal['json', 'dataframe'] = 'json'
Returns:
pd.DataFrame
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | No | ||
| output_format | No | json |
Implementation Reference
- src/vnstock_mcp/server.py:650-669 (handler)The handler function for the 'get_exchange_rate' MCP tool. Decorated with @server.tool() for automatic registration and schema inference from type hints and docstring. Fetches exchange rates using the vnstock library's vcb_exchange_rate function.@server.tool() def get_exchange_rate( date: str = None, output_format: Literal["json", "dataframe"] = "json" ): """ Get exchange rate of all currency pairs from stock market Args: date: str = None (if None, return today's price. Format: YYYY-MM-DD) output_format: Literal['json', 'dataframe'] = 'json' Returns: pd.DataFrame """ if not date: date = datetime.now().strftime("%Y-%m-%d") price = vcb_exchange_rate(date=date) if output_format == "json": return price.to_json(orient="records", force_ascii=False) else: return price