Skip to main content
Glama
berlinbra

AlphaVantage-MCP

get-crypto-exchange-rate

Retrieve current cryptocurrency exchange rates for trading pairs like BTC/USD or ETH/EUR using Alpha Vantage market data.

Instructions

Get current cryptocurrency exchange rate

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
crypto_symbolYesCryptocurrency symbol (e.g., BTC, ETH)
marketNoMarket currency (e.g., USD, EUR)USD

Implementation Reference

  • The main handler function that implements the core logic for the 'get-crypto-exchange-rate' tool. It validates input parameters, makes an asynchronous HTTP request to the Alpha Vantage CURRENCY_EXCHANGE_RATE API using the make_alpha_request helper, handles errors, formats the response using format_crypto_rate, and returns a formatted text content response.
    elif name == "get-crypto-exchange-rate":
        crypto_symbol = arguments.get("crypto_symbol")
        if not crypto_symbol:
            return [types.TextContent(type="text", text="Missing crypto_symbol parameter")]
    
        market = arguments.get("market", "USD")
        crypto_symbol = crypto_symbol.upper()
        market = market.upper()
    
        async with httpx.AsyncClient() as client:
            crypto_data = await make_alpha_request(
                client,
                "CURRENCY_EXCHANGE_RATE",
                None,
                {
                    "from_currency": crypto_symbol,
                    "to_currency": market
                }
            )
    
            if isinstance(crypto_data, str):
                return [types.TextContent(type="text", text=f"Error: {crypto_data}")]
    
            formatted_rate = format_crypto_rate(crypto_data)
            rate_text = f"Cryptocurrency exchange rate for {crypto_symbol}/{market}:\n\n{formatted_rate}"
    
            return [types.TextContent(type="text", text=rate_text)]
  • Tool registration in the list_tools handler, defining the tool name, description, and JSON schema for input validation (crypto_symbol required, market optional with USD default).
    types.Tool(
        name="get-crypto-exchange-rate",
        description="Get current cryptocurrency exchange rate",
        inputSchema={
            "type": "object",
            "properties": {
                "crypto_symbol": {
                    "type": "string",
                    "description": "Cryptocurrency symbol (e.g., BTC, ETH)",
                },
                "market": {
                    "type": "string",
                    "description": "Market currency (e.g., USD, EUR)",
                    "default": "USD"
                }
            },
            "required": ["crypto_symbol"],
        },
    ),
  • JSON schema defining the input parameters for the tool: crypto_symbol (string, required) and market (string, optional default 'USD').
    inputSchema={
        "type": "object",
        "properties": {
            "crypto_symbol": {
                "type": "string",
                "description": "Cryptocurrency symbol (e.g., BTC, ETH)",
            },
            "market": {
                "type": "string",
                "description": "Market currency (e.g., USD, EUR)",
                "default": "USD"
            }
        },
        "required": ["crypto_symbol"],
    },
  • Supporting helper function that takes the raw API response from Alpha Vantage CURRENCY_EXCHANGE_RATE and formats it into a readable multi-line string with currency details, exchange rate, bid/ask prices, and metadata.
    def format_crypto_rate(crypto_data: Dict[str, Any]) -> str:
        """Format cryptocurrency exchange rate data into a concise string.
        
        Args:
            crypto_data: The response data from the Alpha Vantage CURRENCY_EXCHANGE_RATE endpoint
            
        Returns:
            A formatted string containing the cryptocurrency exchange rate information
        """
        try:
            realtime_data = crypto_data.get("Realtime Currency Exchange Rate", {})
            if not realtime_data:
                return "No exchange rate data available in the response"
    
            return (
                f"From: {realtime_data.get('2. From_Currency Name', 'N/A')} ({realtime_data.get('1. From_Currency Code', 'N/A')})\n"
                f"To: {realtime_data.get('4. To_Currency Name', 'N/A')} ({realtime_data.get('3. To_Currency Code', 'N/A')})\n"
                f"Exchange Rate: {realtime_data.get('5. Exchange Rate', 'N/A')}\n"
                f"Last Updated: {realtime_data.get('6. Last Refreshed', 'N/A')} {realtime_data.get('7. Time Zone', 'N/A')}\n"
                f"Bid Price: {realtime_data.get('8. Bid Price', 'N/A')}\n"
                f"Ask Price: {realtime_data.get('9. Ask Price', 'N/A')}\n"
                "---"
            )
        except Exception as e:
            return f"Error formatting cryptocurrency data: {str(e)}"
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While 'Get' implies a read-only operation, it doesn't specify whether this is a real-time query, cached data, rate-limited, requires authentication, or what happens with invalid symbols. For a financial data tool with zero annotation coverage, this leaves significant behavioral questions unanswered.

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, efficient sentence that gets straight to the point. It's appropriately sized for a simple lookup tool and wastes no words. Every word earns its place by conveying the core functionality.

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 low complexity (2 parameters, no nested objects) and 100% schema coverage, the description is minimally adequate. However, with no output schema and no annotations, the description should ideally mention what format the exchange rate is returned in (e.g., number, object with timestamp) or any limitations. It's complete enough for basic understanding but could be more informative.

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?

The input schema has 100% description coverage, with both parameters clearly documented in the schema itself. The description adds no additional parameter semantics beyond what's already in the schema. According to the scoring rules, when schema_description_coverage is high (>80%), the baseline is 3 even with no param info in the description.

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 verb ('Get') and resource ('current cryptocurrency exchange rate'), making the purpose immediately understandable. However, it doesn't distinguish this tool from its sibling 'get-crypto-daily', 'get-crypto-weekly', and 'get-crypto-monthly' tools, which likely provide time-series data rather than current rates. The description is specific but lacks sibling differentiation.

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. It doesn't mention the sibling crypto tools (daily, weekly, monthly) or explain that this is for real-time/current rates rather than historical data. There's also no mention of prerequisites, limitations, or when not to use it.

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/berlinbra/alpha-vantage-mcp'

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