list_exchanges
Retrieve detailed information on over 2700 stock exchanges by searching name or MIC, with pagination options for managing large datasets efficiently.
Instructions
Look up information any of the 2700+ stock exchanges supported by this endpoint.
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. | |
| search | No | Use this parameter to search stock exchanges by name or MIC. |
Implementation Reference
- The handler function for the 'list_exchanges' tool that fetches exchange data from Marketstack API using provided search, limit, and offset parameters.const listExchangesHandler = async (input: Input, client: MarketstackClient): Promise<Output> => { try { const { search, limit, offset } = input; const apiRequestParams: MarketstackApiParams = { endpoint: 'exchanges', ...(search && { search }), // Include if search is provided ...(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('listExchanges tool error:', error); const message = error instanceof Error ? error.message : 'An unknown error occurred.'; throw new Error(`listExchanges tool failed: ${message}`); } };
- Zod-based input schema shape for the 'list_exchanges' tool, defining optional search, limit, and offset parameters.const listExchangesInputSchemaShape = { search: z.string().optional().describe('Use this parameter to search stock exchanges by name or MIC.'), 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:43-48 (registration)Registration of the 'list_exchanges' tool with the MCP server using server.tool(), wrapping the handler for client injection.server.tool( listExchangesTool.name, listExchangesTool.description, listExchangesTool.inputSchemaShape, wrapToolHandler((input) => listExchangesTool.handler(input, client)) );
- Tool definition object exporting name, description, input schema, and handler for the 'list_exchanges' tool.export const listExchangesTool: MarketstackToolDefinition = { name: 'list_exchanges', description: 'Look up information any of the 2700+ stock exchanges supported by this endpoint.', inputSchemaShape: listExchangesInputSchemaShape, handler: listExchangesHandler, };