Skip to main content
Glama

Juhe Exchange Rates MCP Server

by juhemcp

query_exchange_rates

Convert currency using 3-letter codes to find real-time exchange rates, enabling accurate cross-currency calculations for financial tasks.

Instructions

根据货币的三位字母代码查询两者之间的兑换汇率

Input Schema

NameRequiredDescriptionDefault
from_codeYes您希望转换的货币的三位字母货币代码。如:CNY
to_codeYes您希望转换为目标货币的三位字母货币代码。如:USD

Input Schema (JSON Schema)

{ "properties": { "from_code": { "description": "您希望转换的货币的三位字母货币代码。如:CNY", "title": "From Code", "type": "string" }, "to_code": { "description": "您希望转换为目标货币的三位字母货币代码。如:USD", "title": "To Code", "type": "string" } }, "required": [ "from_code", "to_code" ], "title": "query_exchange_ratesArguments", "type": "object" }

Implementation Reference

  • The main handler function for the 'query_exchange_rates' tool, including the @mcp.tool decorator for registration and Pydantic Field definitions for input schema. It makes an HTTP POST request to the JUHE API to fetch exchange rates between two currencies and returns the result as TextContent.
    @mcp.tool(name="query_exchange_rates", description="根据货币的三位字母代码查询两者之间的兑换汇率") async def query_exchange_rates( from_code: str = Field(description="您希望转换的货币的三位字母货币代码。如:CNY"), to_code : str = Field(description="您希望转换为目标货币的三位字母货币代码。如:USD") ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]: """根据城市、地区、区县名称查询当地实时天气预报情况""" url = f"{JUHE_EXCHANGE_API_BASE}/currency" params = { "version": "2", "from": from_code, "to": to_code, "key": JUHE_EXCHANGE_API_KEY } async with httpx.AsyncClient() as client: response = await client.post(url, params=params) data = response.json() if data["error_code"] == 0: result = data["result"] return [ types.TextContent( type="text", text=f"{result}" ) ] else: return [ types.TextContent( type="text", text=f"Error: {data['reason']}" ) ]

Other Tools

Related Tools

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/juhemcp/jexchange-mcp-server'

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