list_nodit_aptos_indexer_api_query_root
Discover available query roots for accessing Aptos blockchain data through the Nodit Indexer GraphQL API, enabling structured data retrieval for AI applications.
Instructions
Lists all query roots available in the Nodit Aptos Indexer GraphQL API.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/aptos-indexer.ts:23-53 (handler)The handler function that loads the Nodit Aptos Indexer API specification, iterates over sources and tables to collect custom_name query roots, sorts them, and returns a formatted text list. Handles errors with createErrorResponse.async () => { const toolName = "list_nodit_aptos_indexer_api_query_root"; try { if (!noditAptosIndexerApiSpec || !noditAptosIndexerApiSpec.metadata || !noditAptosIndexerApiSpec.metadata.sources) { return createErrorResponse("Failed to load or parse the Aptos Indexer API schema", toolName); } const queryRoots: string[] = []; for (const source of noditAptosIndexerApiSpec.metadata.sources) { if (source.tables) { for (const tableInfo of source.tables) { if (tableInfo.configuration && tableInfo.configuration.custom_name) { queryRoots.push(tableInfo.configuration.custom_name); } } } } if (queryRoots.length === 0) { return createErrorResponse("No query roots found in the Aptos Indexer API schema", toolName); } queryRoots.sort(); const resultText = `Available Aptos Indexer API query roots:\n\n${queryRoots.join('\n')}`; return { content: [{ type: "text", text: resultText }] }; } catch (error) { return createErrorResponse(`Error processing Aptos Indexer API schema: ${(error as Error).message}`, toolName); } }
- src/tools/aptos-indexer.ts:19-54 (registration)Registers the tool with the MCP server using server.tool(), providing name, description, empty input schema, and the handler function.server.tool( "list_nodit_aptos_indexer_api_query_root", "Lists all query roots available in the Nodit Aptos Indexer GraphQL API.", {}, async () => { const toolName = "list_nodit_aptos_indexer_api_query_root"; try { if (!noditAptosIndexerApiSpec || !noditAptosIndexerApiSpec.metadata || !noditAptosIndexerApiSpec.metadata.sources) { return createErrorResponse("Failed to load or parse the Aptos Indexer API schema", toolName); } const queryRoots: string[] = []; for (const source of noditAptosIndexerApiSpec.metadata.sources) { if (source.tables) { for (const tableInfo of source.tables) { if (tableInfo.configuration && tableInfo.configuration.custom_name) { queryRoots.push(tableInfo.configuration.custom_name); } } } } if (queryRoots.length === 0) { return createErrorResponse("No query roots found in the Aptos Indexer API schema", toolName); } queryRoots.sort(); const resultText = `Available Aptos Indexer API query roots:\n\n${queryRoots.join('\n')}`; return { content: [{ type: "text", text: resultText }] }; } catch (error) { return createErrorResponse(`Error processing Aptos Indexer API schema: ${(error as Error).message}`, toolName); } } );
- src/tools/index.ts:15-15 (registration)Top-level registration call within registerAllTools that invokes the module-specific registration function.registerAptosIndexerTools(server);
- Helper utility that loads the static Aptos Indexer API schema JSON file, which is parsed and used by the tool handler to extract query roots.export function loadNoditAptosIndexerApiSpec(): AptosIndexerApiSpec { const schemaPath = path.resolve(__dirname, '../nodit-aptos-indexer-api-schema.json'); return loadOpenapiSpecFile(schemaPath) as AptosIndexerApiSpec; }
- Utility function used by the handler to format and return standardized error responses.export function createErrorResponse(message: string, toolName: string): { content: { type: "text"; text: string }[] } { log(`Tool Error (${toolName}): ${message}`); return { content: [{ type: "text" as const, text: `Tool Error: ${message}` }] }; }