list_indices
Retrieve and paginate through all supported stock market indices using limit and offset parameters for precise data access via the Marketstack API.
Instructions
List all supported stock market indices.
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 handler function that executes the list_indices tool logic, fetching indices data from the Marketstack API using provided limit and offset parameters.const listIndicesHandler = async (input: Input, client: MarketstackClient): Promise<Output> => { try { const { limit, offset } = input; // Assuming the endpoint for listing indices is 'index' or 'indices' // The documentation is slightly ambiguous, using 'indexinfo' for details // and showing a listing response structure without a clear endpoint path. // We'll try 'index' first based on the 'indexinfo' example. const endpoint = 'index'; const apiRequestParams: MarketstackApiParams = { endpoint, ...(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('listIndices tool error:', error); const message = error instanceof Error ? error.message : 'An unknown error occurred.'; throw new Error(`listIndices tool failed: ${message}`); } };
- Zod schema shape defining the input parameters (limit and offset) for the list_indices tool.const listIndicesInputSchemaShape = { 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/financialInstruments/index.ts:20-25 (registration)Registration of the list_indices tool with the MCP server using server.tool().server.tool( listIndicesTool.name, listIndicesTool.description, listIndicesTool.inputSchemaShape, wrapToolHandler((input) => listIndicesTool.handler(input, client)) );
- src/tools/financialInstruments/listIndices.ts:66-71 (registration)Tool definition object that bundles name, description, schema, and handler for list_indices.export const listIndicesTool: MarketstackToolDefinition = { name: 'list_indices', description: 'List all supported stock market indices.', inputSchemaShape: listIndicesInputSchemaShape, handler: listIndicesHandler, };