Skip to main content
Glama

call_nodit_aptos_indexer_api

Query Aptos blockchain data via Nodit's normalized API to access real-time transaction, account, and smart contract information for AI applications.

Instructions

Calls a Nodit Aptos Indexer API. Returns the API response. Before making the call, it's recommended to verify the detailed API specifications using the 'get_nodit_aptos_indexer_api_spec' tool. Please note that using this tool will consume your API quota.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
networkYesNodit network to call. e.g. 'mainnet' or 'testnet'.
requestBodyYesGraphql request body matching the API's spec.

Implementation Reference

  • The complete server.tool registration block defining the 'call_nodit_aptos_indexer_api' tool, including its name, description, Zod input schema, and the full handler function that executes the GraphQL API call to the Nodit Aptos Indexer with authentication, timeout handling, detailed error responses for common status codes, and JSON response parsing.
    server.tool(
      "call_nodit_aptos_indexer_api",
      "Calls a Nodit Aptos Indexer API. Returns the API response. Before making the call, it's recommended to verify the detailed API specifications using the 'get_nodit_aptos_indexer_api_spec' tool. Please note that using this tool will consume your API quota.",
      {
          network: z.string().describe("Nodit network to call. e.g. 'mainnet' or 'testnet'."),
          requestBody: z.record(z.any()).describe("Graphql request body matching the API's spec."),
      },
      async ({ network, requestBody }) => {
        const toolName = "call_nodit_aptos_indexer_api";
        const apiKey = process.env.NODIT_API_KEY;
        if (!apiKey) {
          return createErrorResponse(`NODIT_API_KEY environment variable is not set. It is required to call nodit api. Please check your mcp server configuration.`, toolName);
        }
    
        const apiUrl = `https://aptos-${network}.nodit.io/v1/graphql`;
        const { signal, cleanup } = createTimeoutSignal(TIMEOUT_MS);
    
        try {
          const apiOptions: RequestInit = {
            method: 'POST',
            headers: {
              'X-API-KEY': apiKey,
              'Accept': 'application/json',
              'Content-Type': 'application/json',
              'User-Agent': 'nodit-mcp-server',
            },
            body: JSON.stringify(requestBody),
            signal,
          };
    
          log(`Calling Aptos Indexer GraphQL API: ${apiUrl}, apiOptions: ${JSON.stringify(apiOptions, null, 2)}`);
    
          const response = await fetch(apiUrl, apiOptions);
          const responseBodyText = await response.text();
    
          if (!response.ok) {
            const statusMessages: Record<number, string> = {
              400: `${responseBodyText}. Help the user identify what went wrong in their request. Explain the likely issue based on the error message, and provide a corrected example if possible.`,
              403: `${responseBodyText}. Let the user know that this API is only available to paid plan users. Explain that their current plan does not include access, and suggest upgrading to a paid tier via https://nodit.io/pricing .`,
              404: `${responseBodyText}. Let the user know that no data was found for the provided ID or address. This usually means the resource doesn't exist or hasn't been indexed yet. Suggest double-checking the input or trying again later.`,
              429: `${responseBodyText}. Inform the user that they've reached their current plan's usage limit. Recommend reviewing their usage or upgrading via https://nodit.io/pricing. Optionally mention the Referral Program: https://developer.nodit.io/docs/referral-program.`,
              500: `${responseBodyText}. This is not the user's fault. Let them know it's likely a temporary issue. Suggest retrying soon or contacting support at https://developer.nodit.io/discuss if the problem continues.`,
              503: `${responseBodyText}. Inform the user that the service may be under maintenance or experiencing high load. Suggest retrying shortly, and checking the Notice section in the Nodit Developer Portal (https://developer.nodit.io).`
            };
    
            if (statusMessages[response.status]) {
              return createErrorResponse(statusMessages[response.status], toolName);
            }
    
            let errorDetails = `Raw error response: ${responseBodyText}`;
            try {
              const errorJson = JSON.parse(responseBodyText);
              errorDetails = `Error Details (JSON):\n${JSON.stringify(errorJson, null, 2)}`;
            } catch (e) { /* ignore parsing error, use raw text */ }
            return createErrorResponse(`API Error (Status ${response.status}). ${errorDetails}`, toolName);
          }
    
          try {
            JSON.parse(responseBodyText);
            log(`Tool (${toolName}): API Success (${response.status})`);
            return { content: [{ type: "text", text: responseBodyText }] };
          } catch (parseError) {
            return createErrorResponse(`API returned OK status but body was not valid JSON. Raw response: ${responseBodyText}`, toolName);
          }
    
        } catch (error) {
          let message = (error as Error).message;
          if (error instanceof Error && error.name === 'AbortError') {
            message = `The request took longer than expected and has been terminated. This may be due to high server load or because the requested data is taking longer to process. Please try again later.`;
          }
          return createErrorResponse(`Network/fetch error calling API: ${message}`, toolName);
        } finally {
          cleanup()
        }
      }
    );
  • Zod schema defining the input parameters for the tool: 'network' (string, e.g., 'mainnet' or 'testnet') and 'requestBody' (arbitrary record for GraphQL query/mutation).
    {
        network: z.string().describe("Nodit network to call. e.g. 'mainnet' or 'testnet'."),
        requestBody: z.record(z.any()).describe("Graphql request body matching the API's spec."),
    },
  • Registration call within registerAllTools that invokes registerAptosIndexerTools(server), thereby registering the 'call_nodit_aptos_indexer_api' tool among others.
    registerAptosIndexerTools(server);
  • src/index.ts:16-16 (registration)
    Top-level server registration call to registerAllTools(server), which chains to the aptos indexer tools registration including the target tool.
    registerAllTools(server);
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It adds valuable context: 'Please note that using this tool will consume your API quota,' which informs about rate limits or resource usage—a key behavioral trait not covered elsewhere. However, it lacks details on error handling, response formats, or authentication needs, which are important for a tool making API calls. The description doesn't contradict any annotations, as none are given.

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 appropriately sized and front-loaded: the first sentence states the core purpose, the second provides usage guidance, and the third adds a critical behavioral note. Every sentence earns its place by adding distinct value without redundancy. It's concise and well-structured for quick comprehension.

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 complexity of an API-calling tool with no annotations and no output schema, the description is moderately complete. It covers purpose, usage prerequisites, and quota consumption, but lacks details on response handling, error cases, or how it differs from siblings like 'call_nodit_api'. For a tool that interacts with external systems, more behavioral context would be beneficial to fully guide an agent.

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?

The schema description coverage is 100%, meaning the input schema fully documents the two parameters ('network' and 'requestBody'). The description doesn't add any parameter-specific details beyond what the schema provides (e.g., it doesn't explain 'requestBody' further or give examples). Since the schema does the heavy lifting, the baseline score is 3, as the description offers no extra semantic value for parameters.

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: 'Calls a Nodit Aptos Indexer API. Returns the API response.' It specifies the verb ('calls') and resource ('Nodit Aptos Indexer API'), distinguishing it from siblings like 'get_nodit_aptos_indexer_api_spec' (which retrieves specifications) and 'call_nodit_api' (which is more general). However, it doesn't explicitly differentiate from all siblings, such as 'list_nodit_aptos_indexer_api_query_root', which might be related but not directly comparable.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear guidance on when to use this tool: 'Before making the call, it's recommended to verify the detailed API specifications using the 'get_nodit_aptos_indexer_api_spec' tool.' This establishes a prerequisite and suggests an alternative tool for preparation. However, it doesn't explicitly state when not to use it or compare it to other siblings like 'call_nodit_api', leaving some ambiguity about tool selection in broader contexts.

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/noditlabs/nodit-mcp-server'

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