Skip to main content
Glama
FinamWeb

Finam MCP Server

by FinamWeb

market_data_get_bars

Retrieve historical market data as aggregated candlesticks for specified financial instruments within defined time periods and intervals to support analysis and decision-making.

Instructions

Получение исторических данных по инструменту (агрегированные свечи)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYessymbol в формате: SYMBOL@MIC (например, YDEX@MISX)
start_timeYes
end_timeYes
timeframeYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
barsYes
symbolYes

Implementation Reference

  • Handler function for the 'market_data_get_bars' tool. It uses type annotations for input validation (Symbol, AwareDatetime, TimeFrame) and returns BarsResponse. Proxies the call to FinamClient.get_bars via get_finam_client() utility.
    @market_data_mcp.tool(tags={"market_data"})
    async def get_bars(symbol: Symbol, start_time: AwareDatetime, end_time: AwareDatetime, timeframe: TimeFrame) -> BarsResponse:
        """Получение исторических данных по инструменту (агрегированные свечи)"""
        return await get_finam_client().get_bars(symbol, start_time, end_time, timeframe)
  • src/main.py:13-13 (registration)
    Registers the market_data_mcp FastMCP server with prefix 'market_data', making the get_bars tool available as 'market_data_get_bars'.
    finam_mcp.mount(market_data_mcp, prefix="market_data")
  • Pydantic type definition for the 'symbol' input parameter, with regex validation and examples.
    Symbol: type[str] = Annotated[
        str,
        Field(
            description="symbol в формате: SYMBOL@MIC (например, YDEX@MISX)",
            pattern=r"^[A-Z0-9]+@[A-Z]+$",  # Regex валидация
            examples=["YDEX@MISX", "SBER@TQBR"]
        )
    ]
  • Core implementation of get_bars in FinamClient, which makes the actual API request to Finam Trade API for bars data and parses into BarsResponse.
    async def get_bars(self, symbol: str, start_time: datetime, end_time: datetime,
                       timeframe: TimeFrame):
        market_client = self.client.instruments
        return BarsResponse(**await self._exec_request(market_client, BaseClient.RequestMethod.GET,
                                                       f"{market_client._url}/{symbol}/bars",
                                                       params={
                                                           "timeframe": timeframe.value,
                                                           "interval.start_time": start_time.isoformat(),
                                                           "interval.end_time": end_time.isoformat(),
                                                       }, ))
  • Utility function to retrieve the shared FinamClient instance from MCP context state.
    def get_finam_client() -> FinamClient:
        return get_context().get_state("finam_client")
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral context. It states it retrieves historical aggregated candles but doesn't disclose rate limits, authentication requirements, data freshness, whether it's a read-only operation, what happens with invalid time ranges, or pagination behavior. For a data retrieval tool with 4 parameters, this leaves significant behavioral uncertainty.

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

Conciseness5/5

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

The description is a single, efficient Russian sentence that directly states the tool's purpose without unnecessary words. It's appropriately sized for a data retrieval tool and front-loads the core functionality. Every word earns its place in conveying the essential action.

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 the tool has 4 parameters with low schema coverage (25%) and no annotations, but does have an output schema (which handles return values), the description is minimally adequate. It identifies the tool as historical data retrieval but lacks sufficient guidance on usage, parameters, and behavioral traits. The output schema reduces the need to describe return values, but other gaps remain significant.

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

Parameters2/5

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

Schema description coverage is only 25% (only the symbol parameter has a description), so the description must compensate but adds no parameter information. It mentions 'агрегированные свечи' (aggregated candles) which hints at the timeframe parameter's purpose, but doesn't explain start_time/end_time formats, symbol format requirements beyond the schema's pattern, or timeframe enum meanings. The description provides minimal value beyond what the sparse schema offers.

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 ('Получение' - getting/retrieving) and resource ('исторических данных по инструменту' - historical data for an instrument), specifying it provides aggregated candles. It distinguishes from siblings like market_data_get_last_quote (real-time quotes) and market_data_get_last_trades (recent trades). However, it doesn't explicitly mention it's for historical OHLC/bar data versus other historical data types.

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 market_data_get_last_quote for current prices, or assets_get for instrument metadata, or specify prerequisites like needing market data access. Usage is implied by the name but not explicitly stated.

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/FinamWeb/finam-mcp'

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