Skip to main content
Glama
BACH-AI-Tools

Finmap MCP Server

Rank stocks

rank_stocks

Analyze and rank stocks by market cap, price change, volume, or other metrics across global exchanges for specific dates to identify top performers.

Instructions

Rank stocks on an exchange by a chosen metric (marketCap, priceChangePct, volume, value, numTrades) for a specific date with order and limit.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stockExchangeYesStock exchange: amex, nasdaq, nyse, us-all, lse, moex, bist, hkex
yearNo
monthNo
dayNo
sortByYesSort by: marketCap, priceChangePct, volume, value, numTrades
orderNoSort order: asc or descdesc
limitNoNumber of results
sectorNoFilter by specific sector

Implementation Reference

  • The handler function that executes the 'rank_stocks' tool logic: fetches market data, filters stocks by sector if specified, sorts by chosen metric and order, applies limit, and formats the response.
    	async ({
    		stockExchange,
    		year,
    		month,
    		day,
    		sortBy,
    		order,
    		limit,
    		sector,
    	}: {
    		stockExchange: StockExchange;
    		year?: number;
    		month?: number;
    		day?: number;
    		sortBy: SortField;
    		order?: SortOrder;
    		limit?: number;
    		sector?: string;
    	}) => {
    		try {
    			const formattedDate = getDate(year, month, day);
    			const marketDataResponse = await fetchMarketData(
    				stockExchange,
    				formattedDate,
    			);
    
    			const stocks = marketDataResponse.securities.data
    				.filter(
    					(item: any[]) =>
    						item[INDICES.TYPE] !== "sector" && item[INDICES.SECTOR] !== "",
    				)
    				.filter((item: any[]) => !sector || item[INDICES.SECTOR] === sector)
    				.map((item: any[]) => ({
    					ticker: item[INDICES.TICKER],
    					name: item[INDICES.NAME_ENG],
    					sector: item[INDICES.SECTOR],
    					priceLastSale: item[INDICES.PRICE_LAST_SALE],
    					priceChangePct: item[INDICES.PRICE_CHANGE_PCT],
    					marketCap: item[INDICES.MARKET_CAP],
    					volume: item[INDICES.VOLUME],
    					value: item[INDICES.VALUE],
    					numTrades: item[INDICES.NUM_TRADES],
    				}))
    				.sort((a: any, b: any) => {
    					const aVal = a[sortBy],
    						bVal = b[sortBy];
    					return order === "desc" ? bVal - aVal : aVal - bVal;
    				})
    				.slice(0, limit);
    
    			return createResponse({
    				info: INFO,
    				charts: createCharts(stockExchange, formattedDate),
    				date: formattedDate,
    				exchange: stockExchange.toUpperCase(),
    				currency: EXCHANGE_INFO[stockExchange as StockExchange].currency,
    				sortBy,
    				order,
    				limit,
    				count: stocks.length,
    				stocks,
    			});
    		} catch (error) {
    			return createErrorResponse(error);
    		}
    	},
    );
  • Input schema for 'rank_stocks' tool using Zod-like validation for parameters: stockExchange, date components, sortBy (enum), order (default desc), limit (1-500, default 10), optional sector.
    inputSchema: {
    	stockExchange: exchangeSchema,
    	...dateSchema,
    	sortBy: z
    		.enum(SORT_FIELDS)
    		.describe(
    			"Sort by: marketCap, priceChangePct, volume, value, numTrades",
    		),
    	order: z
    		.enum(SORT_ORDERS)
    		.default("desc")
    		.describe("Sort order: asc or desc"),
    	limit: z
    		.number()
    		.int()
    		.min(1)
    		.max(500)
    		.default(10)
    		.describe("Number of results"),
    	sector: z.string().optional().describe("Filter by specific sector"),
    },
  • src/core.ts:682-682 (registration)
    Registration of the 'rank_stocks' tool in the registerFinmapTools function using server.registerTool.
    server.registerTool(
  • Type definitions for sortable fields and orders used in the rank_stocks tool.
    const SORT_FIELDS = [
    	"priceChangePct",
    	"marketCap",
    	"value",
    	"volume",
    	"numTrades",
    ] as const;
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions ranking functionality but lacks critical details: whether this is a read-only operation, if it requires authentication, rate limits, error handling, or what the output format looks like (e.g., list of stocks with ranks). For a tool with 8 parameters and no output schema, this is a significant gap.

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, efficient sentence that front-loads the core purpose. It avoids redundancy and wastes no words, though it could be slightly more structured (e.g., separating key constraints). Every element serves a purpose, making it appropriately concise for the tool's complexity.

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

Completeness2/5

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

Given the tool's complexity (8 parameters, no annotations, no output schema), the description is incomplete. It lacks behavioral context (e.g., safety, performance), output details, and guidance on parameter usage. While it states the purpose clearly, it doesn't provide enough information for an agent to confidently invoke the tool without additional assumptions.

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 63%, with 5 of 8 parameters having descriptions in the schema. The description adds minimal value beyond the schema: it lists the sortBy metrics (already in schema) and mentions date, order, and limit (implied by parameter names). It doesn't explain parameter interactions (e.g., how sector filtering combines with ranking) or provide usage examples, so it meets the baseline for moderate schema coverage.

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 tool's purpose: 'Rank stocks on an exchange by a chosen metric... for a specific date with order and limit.' It specifies the verb ('rank'), resource ('stocks'), and key parameters (exchange, metric, date, order, limit). However, it doesn't explicitly differentiate from sibling tools like 'get_stock_data' or 'search_companies', which might also involve stock data retrieval.

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 sibling tools or explain scenarios where ranking is preferred over other data retrieval methods. The agent must infer usage from the purpose alone, which is insufficient for optimal tool selection.

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