Skip to main content
Glama
BACH-AI-Tools

Finmap MCP Server

Stock data by ticker

get_stock_data

Retrieve historical stock market data including price, volume, market cap, and trades for specific tickers on global exchanges to support financial analysis.

Instructions

Get detailed market data for a specific ticker on an exchange and date, including price, change, volume, value, market cap, and trades.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stockExchangeYesStock exchange: amex, nasdaq, nyse, us-all, lse, moex, bist, hkex
yearNo
monthNo
dayNo
tickerYesStock ticker symbol (case-sensitive)

Implementation Reference

  • Handler function that implements the core logic of 'get_stock_data': fetches market data for the exchange and date, searches for the specific ticker, extracts and returns detailed stock metrics like price, change percentage, volume, market cap, etc.
    	async ({
    		stockExchange,
    		year,
    		month,
    		day,
    		ticker,
    	}: {
    		stockExchange: StockExchange;
    		year?: number;
    		month?: number;
    		day?: number;
    		ticker: string;
    	}) => {
    		try {
    			const formattedDate = getDate(year, month, day);
    			const marketDataResponse = await fetchMarketData(
    				stockExchange,
    				formattedDate,
    			);
    
    			const stockData = marketDataResponse.securities.data.find(
    				(item: any[]) =>
    					item[INDICES.TYPE] !== "sector" && item[INDICES.TICKER] === ticker,
    			);
    
    			if (!stockData) {
    				throw new Error(
    					`Ticker ${ticker} not found on ${stockExchange} for date ${formattedDate}`,
    				);
    			}
    
    			return createResponse({
    				info: INFO,
    				charts: createCharts(stockExchange, formattedDate),
    				exchange: stockData[INDICES.EXCHANGE],
    				country: stockData[INDICES.COUNTRY],
    				currency: EXCHANGE_INFO[stockExchange as StockExchange].currency,
    				sector: stockData[INDICES.SECTOR],
    				ticker: stockData[INDICES.TICKER],
    				nameEng: stockData[INDICES.NAME_ENG],
    				nameOriginal: stockData[INDICES.NAME_ORIGINAL],
    				priceOpen: stockData[INDICES.PRICE_OPEN],
    				priceLastSale: stockData[INDICES.PRICE_LAST_SALE],
    				priceChangePct: stockData[INDICES.PRICE_CHANGE_PCT],
    				volume: stockData[INDICES.VOLUME],
    				value: stockData[INDICES.VALUE],
    				numTrades: stockData[INDICES.NUM_TRADES],
    				marketCap: stockData[INDICES.MARKET_CAP],
    				listedFrom: stockData[INDICES.LISTED_FROM],
    				listedTill: stockData[INDICES.LISTED_TILL],
    			});
    		} catch (error) {
    			return createErrorResponse(error);
    		}
    	},
    );
  • Input schema for the 'get_stock_data' tool, defining parameters: stockExchange (enum), optional date components (year, month, day), and required ticker string.
    {
    	title: "Stock data by ticker",
    	description:
    		"Get detailed market data for a specific ticker on an exchange and date, including price, change, volume, value, market cap, and trades.",
    	inputSchema: {
    		stockExchange: exchangeSchema,
    		...dateSchema,
    		ticker: z.string().describe("Stock ticker symbol (case-sensitive)"),
    	},
    },
  • src/core.ts:613-680 (registration)
    Registration of the 'get_stock_data' tool via server.registerTool, including name, metadata/schema, and handler function.
    server.registerTool(
    	"get_stock_data",
    	{
    		title: "Stock data by ticker",
    		description:
    			"Get detailed market data for a specific ticker on an exchange and date, including price, change, volume, value, market cap, and trades.",
    		inputSchema: {
    			stockExchange: exchangeSchema,
    			...dateSchema,
    			ticker: z.string().describe("Stock ticker symbol (case-sensitive)"),
    		},
    	},
    	async ({
    		stockExchange,
    		year,
    		month,
    		day,
    		ticker,
    	}: {
    		stockExchange: StockExchange;
    		year?: number;
    		month?: number;
    		day?: number;
    		ticker: string;
    	}) => {
    		try {
    			const formattedDate = getDate(year, month, day);
    			const marketDataResponse = await fetchMarketData(
    				stockExchange,
    				formattedDate,
    			);
    
    			const stockData = marketDataResponse.securities.data.find(
    				(item: any[]) =>
    					item[INDICES.TYPE] !== "sector" && item[INDICES.TICKER] === ticker,
    			);
    
    			if (!stockData) {
    				throw new Error(
    					`Ticker ${ticker} not found on ${stockExchange} for date ${formattedDate}`,
    				);
    			}
    
    			return createResponse({
    				info: INFO,
    				charts: createCharts(stockExchange, formattedDate),
    				exchange: stockData[INDICES.EXCHANGE],
    				country: stockData[INDICES.COUNTRY],
    				currency: EXCHANGE_INFO[stockExchange as StockExchange].currency,
    				sector: stockData[INDICES.SECTOR],
    				ticker: stockData[INDICES.TICKER],
    				nameEng: stockData[INDICES.NAME_ENG],
    				nameOriginal: stockData[INDICES.NAME_ORIGINAL],
    				priceOpen: stockData[INDICES.PRICE_OPEN],
    				priceLastSale: stockData[INDICES.PRICE_LAST_SALE],
    				priceChangePct: stockData[INDICES.PRICE_CHANGE_PCT],
    				volume: stockData[INDICES.VOLUME],
    				value: stockData[INDICES.VALUE],
    				numTrades: stockData[INDICES.NUM_TRADES],
    				marketCap: stockData[INDICES.MARKET_CAP],
    				listedFrom: stockData[INDICES.LISTED_FROM],
    				listedTill: stockData[INDICES.LISTED_TILL],
    			});
    		} catch (error) {
    			return createErrorResponse(error);
    		}
    	},
    );
  • Key helper function used by the handler to fetch the market data JSON from GitHub raw for the given exchange and formatted date.
    async function fetchMarketData(
    	stockExchange: StockExchange,
    	formattedDate: string,
    ): Promise<{ securities: { data: any[][] } }> {
    	const country = EXCHANGE_TO_COUNTRY_MAP[stockExchange];
    	const date = formattedDate.replaceAll("-", "/");
    	const url = `${DATA_BASE_URL}/data-${country}/refs/heads/main/marketdata/${date}/${stockExchange}.json`;
    
    	const response = await fetch(url);
    	if (response.status === 404) {
    		throw new Error(
    			`Not found, try another date. The date must be on or after ${EXCHANGE_INFO[stockExchange].availableSince} for ${stockExchange}`,
    		);
    	}
    
    	return response.json();
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions what data is returned but doesn't describe error conditions (e.g., invalid ticker or date), rate limits, authentication needs, data freshness, or response format. For a data retrieval tool with 5 parameters and no annotations, this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, well-structured sentence that efficiently communicates the core function and data scope. It's appropriately sized for this tool type, though it could potentially benefit from a second sentence about limitations or context.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 5 parameters with only 40% schema coverage and no annotations or output schema, the description provides basic purpose but lacks sufficient context about behavior, error handling, and parameter details. It's minimally adequate for understanding what the tool does but leaves significant gaps for effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is only 40% (2 of 5 parameters have descriptions). The description adds context by mentioning 'on an exchange and date' which relates to stockExchange, year/month/day parameters, and specifies 'ticker' as the target. However, it doesn't provide additional details about parameter formats, constraints, or interactions beyond what's minimally implied.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Get' and resource 'detailed market data for a specific ticker', specifying what data is included (price, change, volume, etc.). It distinguishes from siblings like get_company_profile (company info) or get_market_overview (broad market data) by focusing on ticker-specific market data. However, it doesn't explicitly differentiate from all siblings (e.g., rank_stocks might also involve ticker data).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to choose this over get_company_profile (for company info) or search_companies (for finding companies). There's no context about prerequisites, limitations, or typical use cases beyond the basic function.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/BACH-AI-Tools/bach-finmap-mcp'

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