Skip to main content
Glama
ariesanhthu

VNStock MCP Server

by ariesanhthu

get_exchange_rate

Retrieve exchange rates for all currency pairs from Vietnam's stock market. Specify a date for historical data or get today's rates, with output 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
NameRequiredDescriptionDefault
dateNo
output_formatNojson

Implementation Reference

  • The primary handler for the 'get_exchange_rate' MCP tool. It is registered via @server.tool() decorator and implements the core logic: fetches exchange rates using the external vcb_exchange_rate function for the specified date (defaults to today), and returns the result as JSON or pandas DataFrame based on the output_format parameter.
    @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
  • The @server.tool() decorator registers the get_exchange_rate function as an MCP tool with the FastMCP server instance.
    @server.tool()
  • The function signature defines the input schema with type hints: optional date (str), output_format as Literal['json', 'dataframe']. The docstring provides additional description for MCP tool schema.
    def get_exchange_rate( date: str = None, output_format: Literal["json", "dataframe"] = "json"
  • Import of the vcb_exchange_rate helper function from vnstock library, which is called within the tool handler to fetch the actual exchange rate data.
    from vnstock.explorer.misc.exchange_rate import vcb_exchange_rate

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ariesanhthu/mcp-server-vietnam-stock-trading'

If you have feedback or need assistance with the MCP directory API, please join our Discord server