get_currencies
Retrieve a list of available currencies for conversion using real-time exchange rate data from the Frankfurter API.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/get_currencies.ts:13-51 (handler)The handler function that fetches the list of available currencies from the Frankfurter API endpoint and returns the data as a JSON string in a ToolResponse format, or an error message if the fetch fails.export async function getCurrencies( _input: GetCurrenciesInput, ): Promise<ToolResponse> { try { const url = `${FRANKFURTER_API_BASE}/currencies`; const response = await fetch(url); if (!response.ok) { return { content: [ { type: "text", text: `Error: Unable to fetch currencies. Status: ${response.status}`, }, ], }; } const data = (await response.json()) as CurrenciesResponse; return { content: [ { type: "text", text: JSON.stringify(data), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error: Failed to fetch currencies - ${error instanceof Error ? error.message : "Unknown error"}`, }, ], }; } }
- src/tools/get_currencies.ts:7-11 (schema)The schema definition (empty object indicating no input parameters) and TypeScript types for input (empty record) and output (CurrenciesResponse).export const getCurrenciesSchema = {}; export type GetCurrenciesInput = Record<string, never>; export type GetCurrenciesOutput = CurrenciesResponse;
- src/index.ts:33-35 (registration)The registration of the "get_currencies" tool on the MCP server, providing the schema and handler function.this.server.tool("get_currencies", getCurrenciesSchema, async (input) => getCurrencies(input), );