Skip to main content
Glama
qqzhangyanhua

MCP Stock Assistant

get-market-index

Retrieve real-time overview of major Chinese market indices like the Shanghai and Shenzhen Composite to monitor current market performance.

Instructions

获取大盘指数概览信息,包括上证指数和深证成指等主要指数的实时数据

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • src/index.ts:113-140 (registration)
    MCP server.tool registration for 'get-market-index', with description, empty input schema, and inline handler that fetches and formats index data.
    server.tool(
      "get-market-index",
      "获取大盘指数概览信息,包括上证指数和深证成指等主要指数的实时数据",
      {},
      async () => {
        const indexData = await fetchMarketIndex();
    
        if (!indexData || indexData.length === 0) {
          return {
            content: [
              {
                type: "text",
                text: "无法获取大盘指数数据,请稍后重试。",
              },
            ],
          };
        }
    
        return {
          content: [
            {
              type: "text",
              text: formatIndexInfo(indexData),
            },
          ],
        };
      }
    );
  • Core helper function fetchMarketIndex that makes API request to INDEX_API for Shanghai (000001) and Shenzhen (399001) indices, parses response, and maps to IndexData array.
    export async function fetchMarketIndex(): Promise<IndexData[] | null> {
      try {
        const params = {
          fltt: "2",
          invt: "2",
          fields: "f1,f2,f3,f4,f12,f13,f14",
          secids: "1.000001,0.399001",
        };
    
        const response = await makeRequest(INDEX_API, params);
        const data = (await response.json()) as IndexResponse;
    
        if (data.rc !== 0 || !data.data || !data.data.diff) {
          throw new Error(data.msg || "获取指数数据失败");
        }
    
        const indexData: IndexData[] = data.data.diff.map((item) => ({
          code: item.f12,
          name: item.f14,
          price: item.f2,
          changePercent: item.f3,
          change: item.f4,
          volume: 0,
          amount: 0,
          time: new Date().toLocaleTimeString(),
        }));
    
        return indexData;
      } catch (error) {
        console.error("Error fetching market index:", error);
        return null;
      }
    }
  • Helper function to format IndexData array into a human-readable markdown table with emojis and statistics.
    export function formatIndexInfo(data: IndexData[]): string {
      let result = `
    📊 大盘指数信息
    
    `;
    
      result += "指数名称      当前点位    涨跌幅     涨跌点    成交量(手)   成交额(万)\n";
      result += "─".repeat(70) + "\n";
    
      for (const index of data) {
        const changeColor = index.changePercent >= 0 ? "📈" : "📉";
        const changeSign = index.change >= 0 ? "+" : "";
        result += `${index.name.padEnd(10)} ${formatPrice(index.price).padStart(8)} ${changeColor}${index.changePercent.toFixed(2)}%`.padEnd(20);
        result += ` ${changeSign}${formatPrice(index.change).padStart(7)} ${formatVolume(index.volume).padStart(10)} ${formatVolume(index.amount).padStart(10)}\n`;
      }
    
      result += `\n🕐 更新时间: ${data[0]?.time || new Date().toLocaleTimeString()}`;
    
      return result;
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. The description mentions '实时数据' (real-time data), which is useful behavioral context about freshness. However, it doesn't disclose other important traits: whether this is a read-only operation, authentication requirements, rate limits, error conditions, or what format the data returns. For a data retrieval tool with zero annotation coverage, this is insufficient.

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 Chinese sentence that states exactly what the tool does. Every word earns its place: it specifies the action (获取 - get), the resource (大盘指数概览信息 - market index overview information), and the scope (上证指数和深证成指等主要指数的实时数据 - real-time data for Shanghai Composite, Shenzhen Component and other major indices). No wasted words.

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's simplicity (0 parameters, no output schema, no annotations), the description is reasonably complete for a basic data retrieval tool. It tells what data is returned and that it's real-time. However, without annotations or output schema, it should ideally mention more about the return format, data fields, or authentication requirements to be fully complete.

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

Parameters4/5

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

The tool has 0 parameters with 100% schema description coverage. The description appropriately doesn't discuss parameters since none exist. It does mention the scope ('大盘指数概览信息' - market index overview information) which helps understand what data will be returned, adding value beyond the empty 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?

The description clearly states the tool's purpose: '获取大盘指数概览信息' (get market index overview information) with specific resources mentioned ('上证指数和深证成指等主要指数' - Shanghai Composite Index, Shenzhen Component Index, and other major indices). It distinguishes from sibling tools (get-stock-history, get-stock-info) by focusing on market indices rather than individual stocks. However, it doesn't explicitly contrast with siblings in the description text.

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. While it's clear this tool is for market indices rather than individual stocks (implied differentiation from siblings), there's no explicit 'when-to-use' or 'when-not-to-use' guidance, nor any mention of prerequisites or context for usage.

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/qqzhangyanhua/mcp-stock'

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