Skip to main content
Glama
anirbanbasu

FrankfurterMCP

get_supported_currencies

Read-only

Retrieve available three-letter currency codes for currency exchange rate queries using the Frankfurter API.

Instructions

Returns a list of three-letter currency codes for the supported currencies.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function that executes the get_supported_currencies tool logic. It makes an HTTP GET request to the Frankfurter API at /currencies endpoint, decodes the response content, and returns it wrapped in a ToolResult.
    async def get_supported_currencies(self, ctx: Context):
        """Returns a list of three-letter currency codes for the supported currencies."""
        try:
            with self.get_httpx_client() as client:
                await ctx.info(f"Fetching supported currencies from Frankfurter API at {self.frankfurter_api_url}")
                http_response = client.get(f"{self.frankfurter_api_url}/currencies")
                http_response.raise_for_status()
                # Note: The following line could easily be result = http_response.json() but we use content.decode() to
                # demonstrate the TextContent wrapping capability of the get_response_content utility method.
                # Questionable choice? Should we just use # pragma: no cover in the respective branch of get_response_content?
                result = http_response.content.decode()
                return self.get_response_content(response=result, http_response=http_response)
        except httpx.RequestError as e:
            raise ValueError(f"Failed to fetch supported currencies from {self.frankfurter_api_url}. {e}")
  • Tool registration metadata declaring 'get_supported_currencies' as an MCP tool with tags ['currency-rates', 'supported-currencies'] and annotations indicating it's a readOnly, openWorld operation.
    tools = [
        {
            "fn": "get_supported_currencies",
            "tags": ["currency-rates", "supported-currencies"],
            "annotations": {
                "readOnlyHint": True,
                "openWorldHint": True,
            },
        },
  • The register_features method in MCPMixin that iterates over the tools list and registers each tool with the FastMCP instance using the mcp.tool() decorator. This is where the actual MCP tool registration happens.
    def register_features(self, mcp: FastMCP) -> FastMCP:
        """Register tools, resources, and prompts with the given FastMCP instance.
    
        Args:
            mcp (FastMCP): The FastMCP instance to register features with.
    
        Returns:
            FastMCP: The FastMCP instance with registered features.
        """
        # Register tools
        for tool in self.tools:
            assert "fn" in tool, "Tool metadata must include the 'fn' key."
            tool_copy = copy.deepcopy(tool)
            fn_name = tool_copy.pop("fn")
            fn = getattr(self, fn_name)
            mcp.tool(**tool_copy)(fn)
            logger.debug(f"Registered MCP tool: {fn_name}")
  • The get_response_content helper method used by the handler to convert response data into a ToolResult format with optional metadata. It handles various data types including strings, dicts, lists, and Pydantic models.
    def get_response_content(
        self,
        response: Any,
        http_response: httpx.Response | None = None,
        include_metadata: bool = EnvVar.MCP_SERVER_INCLUDE_METADATA_IN_RESPONSE,
        cached_response: bool = False,
    ) -> ToolResult:
        """Convert response data to a ToolResult format with optional metadata.
    
        Args:
            response (Any): The response data to convert.
            http_response (httpx.Response): The HTTP response object for header extraction.
            include_metadata (bool): Whether to include metadata in the response.
            cached_response (bool): Indicates if the response was served from cache, which will be reflected in metadata.
    
        Returns:
            ToolResult: The ToolResult enclosing the TextContent representation of the response
            along with metadata if requested.
        """
        literal_text = "text"
        text_content: TextContent | None = None
        structured_content: dict[str, Any] | None = None
        if isinstance(response, TextContent):  # pragma: no cover
            text_content = response
            structured_content = {"result": response.text}
        elif isinstance(response, (str, int, float, complex, bool, type(None))):  # pragma: no cover
            text_content = TextContent(type=literal_text, text=str(response))
            structured_content = {"result": response}
        elif isinstance(response, list):  # pragma: no cover
            text_content = TextContent(type=literal_text, text=json.dumps(response))
            structured_content = {"result": response}
        elif isinstance(response, dict):
            structured_content = response
        elif isinstance(response, BaseModel):
            structured_content = response.model_dump()
        else:  # pragma: no cover
            raise TypeError(
                f"Unsupported data type: {type(response).__name__}. "
                "Only str, int, float, complex, bool, dict, list, and Pydantic BaseModel types are supported."
            )
        if text_content is not None:
            tool_result = ToolResult(content=[text_content], structured_content=structured_content)
        elif structured_content is not None:
            tool_result = ToolResult(content=structured_content)
        else:
            assert False, (
                "Unreachable code reached in get_response_content. "
                "Both text_content and structured_content should not have been None."
            )
        if include_metadata:
            tool_result.meta = {
                AppMetadata.PACKAGE_NAME: ResponseMetadata(
                    version=AppMetadata.package_metadata["Version"],
                    api_url=HttpUrl(self.frankfurter_api_url) if http_response else None,
                    api_status_code=http_response.status_code if http_response else None,
                    api_bytes_downloaded=http_response.num_bytes_downloaded if http_response else None,
                    api_elapsed_time=http_response.elapsed.microseconds if http_response else None,
                    cached_response=cached_response,
                ).model_dump(),
            }
        return tool_result
  • The get_httpx_client helper method from HTTPHelperMixin that creates and returns an httpx.Client for making HTTP requests to the Frankfurter API, with configurable SSL verification and timeouts.
    def get_httpx_client(self) -> httpx.Client:
        """Obtain an HTTPX client for making requests."""
        verify = EnvVar.HTTPX_VERIFY_SSL
        if verify is False:  # pragma: no cover
            logging.warning("SSL verification is disabled. This is not recommended for production use.")
        ctx = ssl.create_default_context(
            cafile=os.environ.get("SSL_CERT_FILE", certifi.where()),
            capath=os.environ.get("SSL_CERT_DIR"),
        )
        client = httpx.Client(
            verify=verify if (verify is not None and verify is False) else ctx,
            follow_redirects=True,
            trust_env=True,
            timeout=EnvVar.HTTPX_TIMEOUT,
        )
        return client
Behavior3/5

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

Annotations already provide readOnlyHint=true and openWorldHint=true, indicating this is a safe read operation with dynamic data. The description adds value by specifying the output format ('list of three-letter currency codes'), which isn't covered by annotations. However, it doesn't disclose additional behavioral traits like rate limits, caching, or data freshness, which could be useful context.

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 directly states the tool's function without any fluff. It's front-loaded with the core action and resource, making it easy for an agent to parse quickly. Every word earns its place.

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

Completeness4/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 (0 parameters, simple read operation) and good annotations, the description is mostly complete. It explains the output format, which is crucial since there's no output schema. However, it could improve by mentioning if the list is static or updates dynamically, aligning with the openWorldHint annotation.

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

Parameters4/5

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

The tool has 0 parameters, and schema description coverage is 100%, so there's no need for parameter details in the description. The description appropriately focuses on the output, which is helpful since there's no output schema. This meets the baseline of 4 for zero-parameter tools.

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 ('Returns') and resource ('list of three-letter currency codes for the supported currencies'). It distinguishes itself from siblings by focusing on currency codes rather than conversion or historical rates, though it doesn't explicitly name alternatives.

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

Usage Guidelines3/5

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

The description implies usage context by mentioning 'supported currencies,' suggesting this tool is for discovering available currencies before using conversion tools. However, it lacks explicit guidance on when to use this versus alternatives like get_latest_exchange_rates or convert_currency_latest, leaving the agent to infer based on the tool name and description.

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/anirbanbasu/frankfurtermcp'

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