Skip to main content
Glama
nonnname

T-Invest MCP Server

by nonnname

get_order_book

Read-only

Retrieve real-time order book data for a specific ticker from T-Invest, showing bid and ask prices with customizable depth for market analysis.

Instructions

Получить стакан заявок (биржевой стакан) по тикеру из Т-Инвестиций

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tickerYesТикер инструмента
depthNoГлубина стакана (1–50)

Implementation Reference

  • The core handler function for the `get_order_book` tool, which fetches the instrument's order book and formats the data for the user.
    async ({ ticker, depth }) => {
      try {
        const item = await resolveTickerToInstrument(client, ticker);
        if (!item) {
          return { content: [{ type: 'text' as const, text: `Инструмент "${ticker}" не найден.` }], isError: true };
        }
    
        const response = await client.post<GetOrderBookResponse>(
          API_PATHS.MARKET_DATA.GET_ORDER_BOOK,
          { figi: item.figi, depth },
        );
    
        const fmt = (q: Parameters<typeof quotationToNumber>[0]) => quotationToNumber(q).toFixed(2);
    
        const lines: string[] = [
          `${ticker} — стакан (глубина ${depth})`,
          `Последняя цена: ${fmt(response.lastPrice)}`,
          `Цена закрытия: ${fmt(response.closePrice)}`,
        ];
    
        if (response.limitUp) lines.push(`Планка вверх: ${fmt(response.limitUp)}`);
        if (response.limitDown) lines.push(`Планка вниз: ${fmt(response.limitDown)}`);
    
        lines.push('\nПродажа (asks):');
        const asks = [...(response.asks ?? [])].reverse();
        for (const ask of asks) {
          lines.push(`  ${fmt(ask.price).padStart(12)} | ${ask.quantity} лот(ов)`);
        }
    
        lines.push('\nПокупка (bids):');
        for (const bid of response.bids ?? []) {
          lines.push(`  ${fmt(bid.price).padStart(12)} | ${bid.quantity} лот(ов)`);
        }
    
        return { content: [{ type: 'text' as const, text: lines.join('\n') }] };
      } catch (error) {
        return {
          content: [{ type: 'text' as const, text: `Ошибка: ${error instanceof Error ? error.message : String(error)}` }],
          isError: true,
        };
      }
    },
  • Registration function for the `get_order_book` tool.
    export function registerGetOrderBook(server: McpServer, client: TInvestClient): void {
      server.tool(
        'get_order_book',
        'Получить стакан заявок (биржевой стакан) по тикеру из Т-Инвестиций',
        {
          ticker: z.string().describe('Тикер инструмента'),
          depth: z.number().int().min(1).max(50).default(10).describe('Глубина стакана (1–50)'),
        },
        READ_ONLY,
        async ({ ticker, depth }) => {
          try {
            const item = await resolveTickerToInstrument(client, ticker);
            if (!item) {
              return { content: [{ type: 'text' as const, text: `Инструмент "${ticker}" не найден.` }], isError: true };
            }
    
            const response = await client.post<GetOrderBookResponse>(
              API_PATHS.MARKET_DATA.GET_ORDER_BOOK,
              { figi: item.figi, depth },
            );
    
            const fmt = (q: Parameters<typeof quotationToNumber>[0]) => quotationToNumber(q).toFixed(2);
    
            const lines: string[] = [
              `${ticker} — стакан (глубина ${depth})`,
              `Последняя цена: ${fmt(response.lastPrice)}`,
              `Цена закрытия: ${fmt(response.closePrice)}`,
            ];
    
            if (response.limitUp) lines.push(`Планка вверх: ${fmt(response.limitUp)}`);
            if (response.limitDown) lines.push(`Планка вниз: ${fmt(response.limitDown)}`);
    
            lines.push('\nПродажа (asks):');
            const asks = [...(response.asks ?? [])].reverse();
            for (const ask of asks) {
              lines.push(`  ${fmt(ask.price).padStart(12)} | ${ask.quantity} лот(ов)`);
            }
    
            lines.push('\nПокупка (bids):');
            for (const bid of response.bids ?? []) {
              lines.push(`  ${fmt(bid.price).padStart(12)} | ${bid.quantity} лот(ов)`);
            }
    
            return { content: [{ type: 'text' as const, text: lines.join('\n') }] };
          } catch (error) {
            return {
              content: [{ type: 'text' as const, text: `Ошибка: ${error instanceof Error ? error.message : String(error)}` }],
              isError: true,
            };
          }
        },
      );
    }
Behavior3/5

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

Annotations already declare readOnlyHint=true, confirming safe read-only access. Description adds valuable context by specifying the data source (T-Investments) and clarifying 'стакан заявок' means 'биржевой стакан' (exchange order book). However, lacks details on error handling for invalid tickers or rate limiting.

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?

Single efficient sentence with zero waste. Front-loaded with the action verb, parenthetical clarification immediately defines the financial instrument type, and source attribution is clear.

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?

Adequate for a simple read-only retrieval tool with two well-documented parameters. However, lacks description of the order book structure (bids/asks) that would be returned, which is relevant given no output schema exists.

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 coverage is 100% with clear descriptions for both ticker and depth parameters. Description mentions 'по тикеру' reinforcing the primary parameter, but adds no additional semantic information about the depth parameter or formatting constraints beyond the schema.

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?

Uses specific verb 'Получить' (Get) and resource 'стакан заявок' (order book), with scope 'по тикеру' (by ticker) from T-Investments. Implicitly distinguishes from sibling get_orders (user orders vs exchange order book) and get_last_prices (depth vs prices), though lacks explicit sibling contrast.

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?

Provides no guidance on when to use this tool versus alternatives like get_last_prices or get_candles, nor does it mention prerequisites such as requiring a valid ticker from T-Investments markets.

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/nonnname/t-invest-mcp-server'

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