list_currencies
Retrieve a list of all currencies supported by the Marketstack API, with options to paginate results using limit and offset parameters for efficient data access.
Instructions
Look up all currencies supported by the marketstack API.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Specify a pagination limit (number of results per page) for your API request. Default limit value is `100`, maximum allowed limit value is `1000`. | |
| offset | No | Specify a pagination offset value for your API request. Example: An offset value of `100` combined with a limit value of 10 would show results 100-110. Default value is `0`, starting with the first available result. |
Implementation Reference
- The main handler function for the 'list_currencies' tool. It extracts limit and offset from input, constructs API params for the 'currencies' endpoint, fetches data using the Marketstack client, and returns the data or throws an error.const listCurrenciesHandler = async (input: Input, client: MarketstackClient): Promise<Output> => { try { const { limit, offset } = input; const apiRequestParams: MarketstackApiParams = { endpoint: 'currencies', ...(limit && { limit }), // Include if limit is provided ...(offset && { offset }), // Include if offset is provided }; const data = await client.fetchApiData(apiRequestParams); return data; } catch (error: unknown) { console.error('listCurrencies tool error:', error); const message = error instanceof Error ? error.message : 'An unknown error occurred.'; throw new Error(`listCurrencies tool failed: ${message}`); } };
- Zod input schema shape defining optional 'limit' (1-1000, default 100) and 'offset' (min 0, default 0) parameters with descriptions.const listCurrenciesInputSchemaShape = { limit: z .number() .int() .min(1) .max(1000) .optional() .default(100) .describe( 'Specify a pagination limit (number of results per page) for your API request. Default limit value is `100`, maximum allowed limit value is `1000`.' ), offset: z .number() .int() .min(0) .optional() .default(0) .describe( 'Specify a pagination offset value for your API request. Example: An offset value of `100` combined with a limit value of 10 would show results 100-110. Default value is `0`, starting with the first available result.' ), };
- src/tools/referenceData/index.ts:64-69 (registration)MCP server registration of the 'list_currencies' tool using server.tool(), referencing the tool definition's name, description, schema, and wrapped handler.server.tool( listCurrenciesTool.name, listCurrenciesTool.description, listCurrenciesTool.inputSchemaShape, wrapToolHandler((input) => listCurrenciesTool.handler(input, client)) );
- src/tools/referenceData/listCurrencies.ts:60-65 (registration)Tool definition object exporting the 'list_currencies' tool with its name, description, input schema, and handler for use in registration.export const listCurrenciesTool: MarketstackToolDefinition = { name: 'list_currencies', description: 'Look up all currencies supported by the marketstack API.', inputSchemaShape: listCurrenciesInputSchemaShape, handler: listCurrenciesHandler, };