get_end_of_day_data
Retrieve end-of-day stock market data for specified tickers, filter by exchange, date range, and sort. Supports up to 100 symbols per request, pagination, and exact date/time queries for precise analysis.
Instructions
Obtain end-of-day data for one or multiple stock tickers.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date_from | No | Filter results based on a specific timeframe by passing a from-date in `YYYY-MM-DD` format. You can also specify an exact time in ISO-8601 date format, e.g. `2020-05-21T00:00:00+0000`. | |
| date_to | No | Filter results based on a specific timeframe by passing an end-date in `YYYY-MM-DD` format. You can also specify an exact time in ISO-8601 date format, e.g. `2020-05-21T00:00:00+0000`. | |
| exchange | No | Filter your results based on a specific stock exchange by specifying the MIC identification of a stock exchange. Example: `XNAS` | |
| 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. | |
| sort | No | By default, results are sorted by date/time descending. Use this parameter to specify a sorting order. Available values: `DESC` (Default), `ASC`. | DESC |
| symbols | Yes | Specify one or multiple comma-separated stock symbols (tickers) for your request, e.g. `AAPL` or `AAPL,MSFT`. Each symbol consumes one API request. Maximum: 100 symbols |
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. You can also specify an exact time in ISO-8601 date format, e.g. `2020-05-21T00:00:00+0000`.",
"type": "string"
},
"date_to": {
"description": "Filter results based on a specific timeframe by passing an end-date in `YYYY-MM-DD` format. You can also specify an exact time in ISO-8601 date format, e.g. `2020-05-21T00:00:00+0000`.",
"type": "string"
},
"exchange": {
"description": "Filter your results based on a specific stock exchange by specifying the MIC identification of a stock exchange. Example: `XNAS`",
"type": "string"
},
"limit": {
"default": 100,
"description": "Specify a pagination limit (number of results per page) for your API request. Default limit value is `100`, maximum allowed limit value is `1000`.",
"maximum": 1000,
"minimum": 1,
"type": "integer"
},
"offset": {
"default": 0,
"description": "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.",
"minimum": 0,
"type": "integer"
},
"sort": {
"default": "DESC",
"description": "By default, results are sorted by date/time descending. Use this parameter to specify a sorting order. Available values: `DESC` (Default), `ASC`.",
"enum": [
"DESC",
"ASC"
],
"type": "string"
},
"symbols": {
"description": "Specify one or multiple comma-separated stock symbols (tickers) for your request, e.g. `AAPL` or `AAPL,MSFT`. Each symbol consumes one API request. Maximum: 100 symbols",
"type": "string"
}
},
"required": [
"symbols"
],
"type": "object"
}
Implementation Reference
- The async handler function that executes the tool logic: destructures input params, builds API request for Marketstack EOD endpoint, fetches data, and returns it or throws error.const getEndOfDayDataHandler = async (input: Input, client: MarketstackClient): Promise<Output> => { try { const { symbols, exchange, sort, date_from, date_to, limit, offset } = input; const apiRequestParams: MarketstackApiParams = { endpoint: 'eod', symbols, ...(exchange && { exchange }), // Include if exchange is provided ...(sort && { sort }), // Include if sort is provided ...(date_from && { date_from }), // Include if date_from is provided ...(date_to && { date_to }), // Include if date_to 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('getEndOfDayData tool error:', error); const message = error instanceof Error ? error.message : 'An unknown error occurred.'; throw new Error(`getEndOfDayData tool failed: ${message}`); } };
- Zod schema defining the input shape for the tool, including parameters like symbols, exchange, sort, date_from, date_to, limit, offset with descriptions and validations.const getEndOfDayDataInputSchemaShape = { symbols: z .string() .describe( 'Specify one or multiple comma-separated stock symbols (tickers) for your request, e.g. `AAPL` or `AAPL,MSFT`. Each symbol consumes one API request. Maximum: 100 symbols' ), exchange: z .string() .optional() .describe( 'Filter your results based on a specific stock exchange by specifying the MIC identification of a stock exchange. Example: `XNAS`' ), sort: z .enum(['DESC', 'ASC']) .optional() .default('DESC') .describe( 'By default, results are sorted by date/time descending. Use this parameter to specify a sorting order. Available values: `DESC` (Default), `ASC`.' ), date_from: z .string() .optional() .describe( 'Filter results based on a specific timeframe by passing a from-date in `YYYY-MM-DD` format. You can also specify an exact time in ISO-8601 date format, e.g. `2020-05-21T00:00:00+0000`.' ), date_to: z .string() .optional() .describe( 'Filter results based on a specific timeframe by passing an end-date in `YYYY-MM-DD` format. You can also specify an exact time in ISO-8601 date format, e.g. `2020-05-21T00:00:00+0000`.' ), 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.' ), // Note: The documentation also mentions /eod/[date] and /eod/latest, but the parameters section // seems to describe the /eod endpoint with query parameters. We'll implement the query parameter // approach for now as it's more flexible for date ranges. };
- src/tools/marketData/index.ts:18-23 (registration)MCP server registration of the get_end_of_day_data tool, using the tool definition's name, description, input schema, and wrapped handler.server.tool( getEndOfDayDataTool.name, getEndOfDayDataTool.description, getEndOfDayDataTool.inputSchemaShape, wrapToolHandler((input) => getEndOfDayDataTool.handler(input, client)) );