Skip to main content
Glama

Marketstack MCP Server

by matteoantoci

get_etf_holdings

Retrieve comprehensive ETF data, including holdings, by specifying a ticker and optional date range using the Marketstack MCP Server tool.

Instructions

Get complete set of exchange-traded funds data based on the unique identifier code of an ETF.

Input Schema

NameRequiredDescriptionDefault
date_fromNoFilter results based on a specific timeframe by passing a from-date in `YYYY-MM-DD` format.
date_toNoFilter results based on a specific timeframe by passing an end-date in `YYYY-MM-DD` format.
tickerYesTo get results based on a ETF ticker.

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "date_from": { "description": "Filter results based on a specific timeframe by passing a from-date in `YYYY-MM-DD` format.", "type": "string" }, "date_to": { "description": "Filter results based on a specific timeframe by passing an end-date in `YYYY-MM-DD` format.", "type": "string" }, "ticker": { "description": "To get results based on a ETF ticker.", "type": "string" } }, "required": [ "ticker" ], "type": "object" }

Implementation Reference

  • The main handler function that implements the get_etf_holdings tool logic. It constructs API parameters for the 'etfholdings' endpoint using the input ticker and optional dates, fetches data via MarketstackClient, and returns the response.
    const getEtfHoldingsHandler = async (input: Input, client: MarketstackClient): Promise<Output> => { try { const { ticker, date_from, date_to } = input; const apiRequestParams: MarketstackApiParams = { endpoint: 'etfholdings', ticker, ...(date_from && { date_from }), // Include if date_from is provided ...(date_to && { date_to }), // Include if date_to is provided }; const data = await client.fetchApiData(apiRequestParams); return data; } catch (error: unknown) { console.error('getEtfHoldings tool error:', error); const message = error instanceof Error ? error.message : 'An unknown error occurred.'; throw new Error(`getEtfHoldings tool failed: ${message}`); } };
  • Zod-based input schema shape defining the parameters for the get_etf_holdings tool: required ticker and optional date_from/date_to.
    const getEtfHoldingsInputSchemaShape = { ticker: z.string().describe('To get results based on a ETF ticker.'), date_from: z .string() .optional() .describe('Filter results based on a specific timeframe by passing a from-date in `YYYY-MM-DD` format.'), date_to: z .string() .optional() .describe('Filter results based on a specific timeframe by passing an end-date in `YYYY-MM-DD` format.'), };
  • Registration of the get_etf_holdings tool with the MCP server using server.tool(), referencing the tool definition imported from getEtfHoldings.ts.
    server.tool( getEtfHoldingsTool.name, getEtfHoldingsTool.description, getEtfHoldingsTool.inputSchemaShape, wrapToolHandler((input) => getEtfHoldingsTool.handler(input, client)) );
  • Tool definition export that bundles name, description, schema, and handler for get_etf_holdings, used in higher-level registration.
    export const getEtfHoldingsTool: MarketstackToolDefinition = { name: 'get_etf_holdings', description: 'Get complete set of exchange-traded funds data based on the unique identifier code of an ETF.', inputSchemaShape: getEtfHoldingsInputSchemaShape, handler: getEtfHoldingsHandler, };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/matteoantoci/mcp-marketstack'

If you have feedback or need assistance with the MCP directory API, please join our Discord server