get_ticker_info
Fetch detailed information about financial market tickers using Marketstack API. Retrieve data including EOD, intraday, splits, dividends, and exchanges for informed decision-making.
Instructions
Look up information about tickers.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ticker | Yes | To get results based on a ticker. |
Implementation Reference
- The handler function that executes the get_ticker_info tool logic, fetching ticker information from the Marketstack API using the provided ticker symbol.const getTickerInfoHandler = async (input: Input, client: MarketstackClient): Promise<Output> => { try { const { ticker } = input; const apiRequestParams: MarketstackApiParams = { endpoint: 'tickerinfo', ticker, }; const data = await client.fetchApiData(apiRequestParams); return data; } catch (error: unknown) { console.error('getTickerInfo tool error:', error); const message = error instanceof Error ? error.message : 'An unknown error occurred.'; throw new Error(`getTickerInfo tool failed: ${message}`); } };
- Zod schema and TypeScript types for the input (ticker symbol) of the get_ticker_info tool.// Define the input schema shape for the Ticker Info tool const getTickerInfoInputSchemaShape = { ticker: z.string().describe('To get results based on a ticker.'), }; type RawSchemaShape = typeof getTickerInfoInputSchemaShape; type Input = z.infer<z.ZodObject<RawSchemaShape>>; type Output = any; // TODO: Define a more specific output type based on Marketstack response
- src/tools/referenceData/index.ts:36-41 (registration)Registration of the get_ticker_info tool with the MCP server using server.tool, wrapping the handler with the Marketstack client.server.tool( getTickerInfoTool.name, getTickerInfoTool.description, getTickerInfoTool.inputSchemaShape, wrapToolHandler((input) => getTickerInfoTool.handler(input, client)) );
- Tool definition object that bundles the name, description, schema, and handler for get_ticker_info.export const getTickerInfoTool: MarketstackToolDefinition = { name: 'get_ticker_info', description: 'Look up information about tickers.', inputSchemaShape: getTickerInfoInputSchemaShape, handler: getTickerInfoHandler, };