Skip to main content
Glama

get_index_data

Retrieve custom China A-share momentum indices using your API key. Choose between DA-MOMENTUM and QTG-MOMENTUM, or omit indexId for a summary.

Instructions

Get custom market indices — China A-share momentum and strategy-weighted momentum. Requires API key (get one free via register_trial).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
apiKeyYesYour API key from register_trial (starts with 'qtg_')
indexIdNoIndex ID. Omit to get summary of all indices.

Implementation Reference

  • src/index.ts:168-169 (registration)
    Registration of the 'get_index_data' tool via server.tool()
    server.tool(
      "get_index_data",
  • Input schema for the tool: apiKey (string) and optional indexId (enum of 'DA-MOMENTUM' or 'QTG-MOMENTUM')
    {
      apiKey: z.string().describe("Your API key from register_trial (starts with 'qtg_')"),
      indexId: z
        .enum(["DA-MOMENTUM", "QTG-MOMENTUM"])
        .optional()
        .describe("Index ID. Omit to get summary of all indices."),
    },
  • Handler function: validates API key, calls API 'getIndexData' in summary or detail mode, returns JSON result
      async ({ apiKey, indexId }) => {
        const auth = await validateApiKey(apiKey);
        if (!auth.valid) {
          return { content: [{ type: "text" as const, text: auth.message }] };
        }
    
        if (!indexId) {
          // Summary mode
          const res = (await callAPI("getIndexData", {
            action: "summary",
          })) as { code: number; data: Record<string, unknown>[] };
          if (res.code !== 0) {
            return {
              content: [{ type: "text" as const, text: "Failed to fetch indices" }],
            };
          }
          return {
            content: [
              { type: "text" as const, text: JSON.stringify(res.data, null, 2) },
            ],
          };
        }
    
        // Detail mode
        const res = (await callAPI("getIndexData", {
          action: "detail",
          indexId,
        })) as { code: number; data: Record<string, unknown> };
        if (res.code !== 0 || !res.data) {
          return {
            content: [
              { type: "text" as const, text: `Index '${indexId}' not found` },
            ],
          };
        }
    
        return {
          content: [
            { type: "text" as const, text: JSON.stringify(res.data, null, 2) },
          ],
        };
      }
    );
  • Helper function callAPI — makes POST requests to the external API endpoint
    async function callAPI(fn: string, body: Record<string, unknown> = {}): Promise<unknown> {
      const resp = await fetch(`${API_BASE}/${fn}`, {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify(body),
      });
      if (!resp.ok) throw new Error(`API ${fn} returned ${resp.status}`);
      return resp.json();
    }
  • Helper function validateApiKey — validates the API key before executing the tool
    async function validateApiKey(apiKey: string): Promise<{ valid: boolean; message: string }> {
      const res = (await callAPI("getApiStatus", { apiKey })) as {
        code: number;
        message: string;
      };
      if (res.code === 401) return { valid: false, message: "Invalid API key. Use register_trial with your email to get a valid key." };
      if (res.code === 403) return { valid: false, message: "Trial expired. Email admin@quanttogo.com to subscribe." };
      if (res.code !== 0) return { valid: false, message: res.message || "API key validation failed." };
      return { valid: true, message: "ok" };
    }
Behavior2/5

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

With no annotations, the description only discloses the API key requirement and its acquisition, but lacks details on error handling, rate limits, or idempotency. It does not mention that omitting indexId returns a summary (though this is in the schema). The behavioral disclosure is minimal.

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 concise, with two sentences front-loading the purpose followed by the prerequisite. It is efficient with no unnecessary words. A small addition about the summary mode would improve structure but it is otherwise well-organized.

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?

The tool has a simple input schema with no output schema. The description covers core purpose and the API key requirement, but it does not explain the two index types or the behavior when indexId is omitted. This leaves some gaps for a complete understanding, though the schema partially fills them.

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 100%, so the baseline is 3. The description adds no additional parameter meaning beyond what the schema already provides. It does not elaborate on the enum values or the summary behavior, but the schema descriptions are sufficient.

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 retrieves custom market indices, specifically China A-share momentum and strategy-weighted momentum, which differentiates it from sibling tools like get_signals or get_strategy_performance. However, it could be more explicit about the distinction between the two index 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 mentions the requirement for an API key and directs to register_trial, but it does not provide any guidance on when to use this tool versus alternatives (e.g., get_signals). No explicit when-not or comparison context is given.

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/QuantToGo/quanttogo-mcp'

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