Skip to main content
Glama
julie-berlin

Tavily Web Search MCP Server

by julie-berlin

get_exchange_rate

Retrieve current exchange rates from a specified base currency to all supported currencies using ISO 4217 codes for accurate financial data.

Instructions

Get the latest exchange rates from provided base currency code (ISO 4217) to all other supported currencies

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
currency_codeYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • server.py:29-33 (handler)
    The handler function for the 'get_exchange_rate' tool, registered with @mcp.tool(). It invokes the ExchangeRateClient to fetch and return exchange rates for the given currency code.
    @mcp.tool()
    async def get_exchange_rate(currency_code: str) -> str:
        """Get the latest exchange rates from provided base currency code (ISO 4217) to all other supported currencies"""
        exchange_rates = exchange_rate_client.get_rates(code=currency_code)
        return exchange_rates
  • Supporting method in ExchangeRateClient class that handles the HTTP request to the exchange rate API, parses the response, and formats the output as JSON.
    def get_rates(self, code: str) -> str:
        """Get latest exchange rates for the specified base currency code"""
        if not self.api_key:
            raise ValueError("API key is required")
        
        url = f"{self.base_url}/{self.api_key}/latest/{code.upper()}"
        
        try:
            response = requests.get(url)
            response.raise_for_status()
            
            data = response.json()
            
            if data.get("result") == "success":
                rates = data.get("conversion_rates", {})
                base_code = data.get("base_code")
                last_update = data.get("time_last_update_utc")
                
                result = {
                    "base_currency": base_code,
                    "last_updated": last_update,
                    "exchange_rates": rates
                }
                
                return json.dumps(result, indent=2)
            else:
                error_type = data.get("error-type", "unknown")
                return f"Error: {error_type}"
                
        except requests.exceptions.RequestException as e:
            return f"Network error: {str(e)}"
        except json.JSONDecodeError:
            return "Error: Invalid response format"
        except Exception as e:
            return f"Unexpected error: {str(e)}"
  • Instantiation of the ExchangeRateClient with API key from environment variable, used by the get_exchange_rate tool.
    exchange_rate_client = ExchangeRateClient(os.getenv("EXCHANGERATE_API_KEY"))
  • server.py:29-29 (registration)
    The @mcp.tool() decorator registers the get_exchange_rate function as an MCP tool.
    @mcp.tool()
  • Function signature with type hints and docstring defining the input (currency_code: str) and output (str), serving as the tool schema.
    async def get_exchange_rate(currency_code: str) -> str:
        """Get the latest exchange rates from provided base currency code (ISO 4217) to all other supported currencies"""
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the tool fetches 'latest' rates but doesn't specify update frequency, rate limits, error handling, or authentication needs. For a data-fetching tool with zero annotation coverage, this leaves significant gaps in understanding its operational behavior.

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?

The description is a single, well-structured sentence that efficiently conveys the core functionality without unnecessary details. It's front-loaded with the main action and includes key specifications (ISO 4217, all supported currencies), making it highly concise and effective.

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?

Given the tool's moderate complexity (fetching financial data), no annotations, and an output schema present (which likely covers return values), the description is minimally adequate. It specifies the input format and output scope but lacks details on data freshness, error cases, or usage constraints, which could be important for reliable agent operation.

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 description coverage is 0%, with one parameter ('currency_code') undocumented in the schema. The description adds value by specifying the parameter must be in 'ISO 4217' format, which clarifies the expected input beyond the schema's generic string type. However, it doesn't detail supported codes or validation rules, leaving some ambiguity.

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

Purpose4/5

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

The description clearly states the tool's purpose with a specific verb ('Get') and resource ('latest exchange rates'), specifying the input (base currency code in ISO 4217 format) and output scope (to all other supported currencies). It doesn't explicitly distinguish from sibling tools like 'roll_dice' or 'web_search', but those are unrelated, so differentiation isn't critical here.

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?

The description provides no guidance on when to use this tool versus alternatives, prerequisites, or limitations. While sibling tools are unrelated (e.g., 'roll_dice' for random number generation, 'web_search' for general queries), the description lacks explicit usage context, such as frequency constraints or data source reliability.

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/julie-berlin/pub-aie7-mcp-session'

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