Skip to main content
Glama

list_nodit_data_apis

Discover available blockchain data operations to access normalized, multi-chain information for AI applications without handling complex node RPCs or raw event logs.

Instructions

Lists available Nodit Data API operations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The inline async handler function for the 'list_nodit_data_apis' tool. It processes the Nodit Data API OpenAPI spec to extract and list available POST operations with their operationId, description, path, and supported chains, formatting them into a text response.
      server.tool("list_nodit_data_apis", "Lists available Nodit Data API operations.", {}, async () => {
        const toolName = "list_nodit_data_apis";
        try {
          const apiList = Object.entries(noditDataApiSpec.paths)
            .filter(([, pathItem]) => pathItem?.post?.operationId)
            .map(([pathKey, pathItem]) => {
              let supportedChains: string[] = [];
              if (pathItem?.post?.parameters) {
                const chainParam = pathItem.post.parameters.find((param: any) => param.name === 'chain');
                if (chainParam?.schema?.enum) {
                  supportedChains = chainParam.schema.enum;
                }
              }
    
              return {
                operationId: pathItem!.post!.operationId!,
                description: normalizeDescription(pathItem!.post!.description),
                path: pathKey,
                supportedChains: supportedChains
              };
            });
    
          const formattedList = apiList
            .map(api => `  - operationId: ${api.operationId}, supported chains: [${api.supportedChains.join(',')}], description: ${api.description}`)
            .join("\n");
    
          const content = `Nodit Blockchain Context data api has endpoints with patterns like https://web3.nodit.io/v1/{chain}/{network}/getBlockByHashOrNumber. For example, Ethereum mainnet uses an endpoint like https://web3.nodit.io/v1/ethereum/mainnet/getBlockByHashOrNumber.
    The API list is as follows. You can use the get_nodit_api_spec tool to get more detailed API specifications.
    - baseUrl: ${noditDataApiSpec.servers[0].url}
    - Available Nodit API Operations:
    ${formattedList}
    `
          return { content: [{ type: "text", text: content }] };
        } catch (error) {
          return createErrorResponse(`Failed to list APIs: ${(error as Error).message}`, toolName);
        }
      });
  • The registerDataApiTools function registers the 'list_nodit_data_apis' tool on the MCP server using server.tool, including the handler inline.
    export function registerDataApiTools(server: McpServer) {
      const noditDataApiSpec: NoditOpenApiSpecType = loadNoditDataApiSpec();
      server.tool("list_nodit_data_apis", "Lists available Nodit Data API operations.", {}, async () => {
        const toolName = "list_nodit_data_apis";
        try {
          const apiList = Object.entries(noditDataApiSpec.paths)
            .filter(([, pathItem]) => pathItem?.post?.operationId)
            .map(([pathKey, pathItem]) => {
              let supportedChains: string[] = [];
              if (pathItem?.post?.parameters) {
                const chainParam = pathItem.post.parameters.find((param: any) => param.name === 'chain');
                if (chainParam?.schema?.enum) {
                  supportedChains = chainParam.schema.enum;
                }
              }
    
              return {
                operationId: pathItem!.post!.operationId!,
                description: normalizeDescription(pathItem!.post!.description),
                path: pathKey,
                supportedChains: supportedChains
              };
            });
    
          const formattedList = apiList
            .map(api => `  - operationId: ${api.operationId}, supported chains: [${api.supportedChains.join(',')}], description: ${api.description}`)
            .join("\n");
    
          const content = `Nodit Blockchain Context data api has endpoints with patterns like https://web3.nodit.io/v1/{chain}/{network}/getBlockByHashOrNumber. For example, Ethereum mainnet uses an endpoint like https://web3.nodit.io/v1/ethereum/mainnet/getBlockByHashOrNumber.
    The API list is as follows. You can use the get_nodit_api_spec tool to get more detailed API specifications.
    - baseUrl: ${noditDataApiSpec.servers[0].url}
    - Available Nodit API Operations:
    ${formattedList}
    `
          return { content: [{ type: "text", text: content }] };
        } catch (error) {
          return createErrorResponse(`Failed to list APIs: ${(error as Error).message}`, toolName);
        }
      });
    }
  • Top-level registration call in registerAllTools that invokes registerDataApiTools to register the tool.
    registerDataApiTools(server);
  • Helper function that loads the Nodit Data API OpenAPI specification YAML file, used by the tool handler to access the API paths and details.
    export function loadNoditDataApiSpec(): NoditOpenApiSpecType {
      const specPath = path.resolve(__dirname, '../spec/reference/web3-data-api.yaml');
      return loadOpenapiSpecFile(specPath) as NoditOpenApiSpecType;
    }
  • Helper function to clean and normalize operation descriptions by removing blockquote lines, used in the tool to format descriptions.
    export function normalizeDescription(description: string | undefined): string {
      if (!description) {
        return "No description available."
      }
    
      const lines = description.split('\n');
      const filteredLines = lines.filter(line => !line.trimStart().startsWith('>'));
    
      return filteredLines.join('\n').trim();
    }

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