Skip to main content
Glama
juhemcp

Juhe Exchange Rates MCP Server

by juhemcp

query_exchange_rates

Queries the exchange rate between two currencies using three-letter codes, such as CNY to USD. Returns the conversion rate to convert one currency to another.

Instructions

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

Input Schema

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

Implementation Reference

  • The main handler function for the 'query_exchange_rates' tool. It takes from_code and to_code (3-letter currency codes), calls the JUHE exchange API via HTTP POST, and returns the exchange rate result or error message as text content.
    @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']}"
                    )
                ]
  • Registration of the tool via @mcp.tool decorator with name='query_exchange_rates' and a description in Chinese.
    @mcp.tool(name="query_exchange_rates", description="根据货币的三位字母代码查询两者之间的兑换汇率")
  • Function signature and pydantic Field descriptions defining the input schema: from_code and to_code are both required strings (3-letter currency codes). The return type is list of TextContent | ImageContent | EmbeddedResource.
    async def query_exchange_rates(
        from_code: str = Field(description="您希望转换的货币的三位字母货币代码。如:CNY"),
        to_code : str = Field(description="您希望转换为目标货币的三位字母货币代码。如:USD")
    ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
  • Helper constants: API base URL and API key loaded from environment variable JUHE_EXCHANGE_API_KEY.
    JUHE_EXCHANGE_API_BASE = "http://op.juhe.cn/onebox/exchange/"
    JUHE_EXCHANGE_API_KEY = os.environ.get("JUHE_EXCHANGE_API_KEY")
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description bears full burden. It only says 'query' implying read-only but does not disclose whether it is real-time, requires internet, or error handling.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence, no wasted words, directly to the point.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Tool is simple with 2 params, no output schema. Description covers purpose and parameters, but lacks details on return format or constraints.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% so baseline is 3. The description adds no new meaning beyond what the schema already provides for the parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool queries exchange rates between two currencies using three-letter codes, which is a specific verb+resource and distinguishes from any potential siblings.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use or not use this tool, no prerequisites or alternatives mentioned despite being a simple query tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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