Skip to main content
Glama
BACH-AI-Tools

Finmap MCP Server

list_sectors

Retrieve business sectors for a specific stock exchange on a given date, including item counts for financial analysis.

Instructions

List available business sectors for an exchange on a specific date, including item counts.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stockExchangeYesStock exchange: amex, nasdaq, nyse, us-all, lse, moex, bist, hkex
yearNo
monthNo
dayNo

Implementation Reference

  • src/core.ts:275-324 (registration)
    Registration of the 'list_sectors' tool using server.registerTool, including title, description, input schema, and handler function.
    server.registerTool(
    	"list_sectors",
    	{
    		title: "List sectors",
    		description:
    			"List available business sectors for an exchange on a specific date, including item counts.",
    		inputSchema: { stockExchange: exchangeSchema, ...dateSchema },
    	},
    	async ({
    		stockExchange,
    		year,
    		month,
    		day,
    	}: {
    		stockExchange: StockExchange;
    		year?: number;
    		month?: number;
    		day?: number;
    	}) => {
    		try {
    			const formattedDate = getDate(year, month, day);
    			const marketDataResponse = await fetchMarketData(
    				stockExchange,
    				formattedDate,
    			);
    
    			const sectorCounts: Record<string, number> = {};
    			marketDataResponse.securities.data.forEach((item: any[]) => {
    				if (item[INDICES.TYPE] !== "sector" && item[INDICES.SECTOR]) {
    					sectorCounts[item[INDICES.SECTOR]] =
    						(sectorCounts[item[INDICES.SECTOR]] || 0) + 1;
    				}
    			});
    
    			const sectors = Object.entries(sectorCounts).map(([name, count]) => ({
    				name,
    				itemsPerSector: count,
    			}));
    			return createResponse({
    				info: INFO,
    				date: formattedDate,
    				exchange: stockExchange.toUpperCase(),
    				currency: EXCHANGE_INFO[stockExchange as StockExchange].currency,
    				sectors,
    			});
    		} catch (error) {
    			return createErrorResponse(error);
    		}
    	},
    );
  • The handler function that fetches market data for the given exchange and date, counts the number of items per sector, and returns a list of sectors with their item counts.
    async ({
    	stockExchange,
    	year,
    	month,
    	day,
    }: {
    	stockExchange: StockExchange;
    	year?: number;
    	month?: number;
    	day?: number;
    }) => {
    	try {
    		const formattedDate = getDate(year, month, day);
    		const marketDataResponse = await fetchMarketData(
    			stockExchange,
    			formattedDate,
    		);
    
    		const sectorCounts: Record<string, number> = {};
    		marketDataResponse.securities.data.forEach((item: any[]) => {
    			if (item[INDICES.TYPE] !== "sector" && item[INDICES.SECTOR]) {
    				sectorCounts[item[INDICES.SECTOR]] =
    					(sectorCounts[item[INDICES.SECTOR]] || 0) + 1;
    			}
    		});
    
    		const sectors = Object.entries(sectorCounts).map(([name, count]) => ({
    			name,
    			itemsPerSector: count,
    		}));
    		return createResponse({
    			info: INFO,
    			date: formattedDate,
    			exchange: stockExchange.toUpperCase(),
    			currency: EXCHANGE_INFO[stockExchange as StockExchange].currency,
    			sectors,
    		});
    	} catch (error) {
    		return createErrorResponse(error);
    	}
    },
  • Input schema definition for the 'list_sectors' tool, including title, description, and Zod-based input schema referencing exchangeSchema and dateSchema.
    {
    	title: "List sectors",
    	description:
    		"List available business sectors for an exchange on a specific date, including item counts.",
    	inputSchema: { stockExchange: exchangeSchema, ...dateSchema },
    },

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