get_index_info
Retrieve detailed information for a specific stock market index, such as Australia All Ordinaries, using the Marketstack MCP Server to access accurate financial market data.
Instructions
Get details for a specific stock market index.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| index | Yes | Specify your benchmark/index id for your request, e.g. australia_all_ordinaries. |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"index": {
"description": "Specify your benchmark/index id for your request, e.g. australia_all_ordinaries.",
"type": "string"
}
},
"required": [
"index"
],
"type": "object"
}
Implementation Reference
- The main handler function that executes the tool logic by fetching index information from the Marketstack API using the provided index identifier.const getIndexInfoHandler = async (input: Input, client: MarketstackClient): Promise<Output> => { try { const { index } = input; const apiRequestParams: MarketstackApiParams = { endpoint: 'indexinfo', index, }; const data = await client.fetchApiData(apiRequestParams); return data; } catch (error: unknown) { console.error('getIndexInfo tool error:', error); const message = error instanceof Error ? error.message : 'An unknown error occurred.'; throw new Error(`getIndexInfo tool failed: ${message}`); } };
- Zod input schema defining the required 'index' parameter for the tool.const getIndexInfoInputSchemaShape = { index: z.string().describe('Specify your benchmark/index id for your request, e.g. australia_all_ordinaries.'), };
- src/tools/financialInstruments/index.ts:27-32 (registration)MCP server registration of the 'get_index_info' tool, providing name, description, input schema, and wrapped handler.server.tool( getIndexInfoTool.name, getIndexInfoTool.description, getIndexInfoTool.inputSchemaShape, wrapToolHandler((input) => getIndexInfoTool.handler(input, client)) );
- Tool definition object that bundles the name, description, schema, and handler for use in registration.export const getIndexInfoTool: MarketstackToolDefinition = { name: 'get_index_info', description: 'Get details for a specific stock market index.', inputSchemaShape: getIndexInfoInputSchemaShape, handler: getIndexInfoHandler, };