Skip to main content
Glama

get_nodit_aptos_indexer_api_spec

Retrieve GraphQL specifications for querying Aptos blockchain data through the Nodit Indexer API to understand available data structures and parameters.

Instructions

Returns the GraphQL specification for a specific query root in the Nodit Aptos Indexer API.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryRootYesThe name of the query root to get the specification for. Use list_nodit_aptos_indexer_api_query_root to see available query roots.

Implementation Reference

  • Executes the tool logic: loads API spec, finds table by queryRoot, builds GraphQLSpec with columns and relationships, returns JSON.
    async ({ queryRoot }) => { const toolName = "get_nodit_aptos_indexer_api_spec"; try { if (!noditAptosIndexerApiSpec || !noditAptosIndexerApiSpec.metadata || !noditAptosIndexerApiSpec.metadata.sources) { return createErrorResponse("Failed to load or parse the Aptos Indexer API schema", toolName); } type TableType = NonNullable<NonNullable<NonNullable<AptosIndexerApiSpec['metadata']>['sources']>[0]['tables']>[0]; let tableSpec: TableType | null = null; for (const source of noditAptosIndexerApiSpec.metadata.sources) { if (source.tables) { for (const tableInfo of source.tables) { if (tableInfo.configuration && tableInfo.configuration.custom_name === queryRoot) { tableSpec = tableInfo; break; } } } if (tableSpec) break; } if (!tableSpec) { return createErrorResponse(`Query root '${queryRoot}' not found in the Aptos Indexer API schema. Use list_nodit_aptos_indexer_api_query_root to see available query roots.`, toolName); } const spec: GraphQLSpec = { name: queryRoot, table: tableSpec.table, columns: tableSpec.select_permissions?.[0]?.permission?.columns || [], relationships: { object: [], array: [] } }; if (tableSpec.object_relationships) { spec.relationships.object = tableSpec.object_relationships.map((rel: Relationship) => { if (!rel || typeof rel !== 'object') return { name: 'unknown', remote_table: 'unknown', column_mapping: {} }; return { name: rel.name ?? 'unknown', remote_table: rel.using?.manual_configuration?.remote_table?.name ?? 'unknown', column_mapping: rel.using?.manual_configuration?.column_mapping ?? {} }; }); } if (tableSpec.array_relationships) { spec.relationships.array = tableSpec.array_relationships.map((rel: Relationship) => { if (!rel || typeof rel !== 'object') return { name: 'unknown', remote_table: 'unknown', column_mapping: {} }; return { name: rel.name ?? 'unknown', remote_table: rel.using?.manual_configuration?.remote_table?.name ?? 'unknown', column_mapping: rel.using?.manual_configuration?.column_mapping ?? {} }; }); } return { content: [{ type: "text", text: `GraphQL specification for query root '${queryRoot}':\n\n${JSON.stringify(spec, null, 2)}` }] }; } catch (error) { return createErrorResponse(`Error processing Aptos Indexer API schema: ${(error as Error).message}`, toolName); } }
  • Zod input schema defining the queryRoot parameter.
    queryRoot: z.string().describe("The name of the query root to get the specification for. Use list_nodit_aptos_indexer_api_query_root to see available query roots."), },
  • Registers the tool with MCP server, including name, description, input schema, and handler reference.
    server.tool( "get_nodit_aptos_indexer_api_spec", "Returns the GraphQL specification for a specific query root in the Nodit Aptos Indexer API.", { queryRoot: z.string().describe("The name of the query root to get the specification for. Use list_nodit_aptos_indexer_api_query_root to see available query roots."), }, async ({ queryRoot }) => { const toolName = "get_nodit_aptos_indexer_api_spec"; try { if (!noditAptosIndexerApiSpec || !noditAptosIndexerApiSpec.metadata || !noditAptosIndexerApiSpec.metadata.sources) { return createErrorResponse("Failed to load or parse the Aptos Indexer API schema", toolName); } type TableType = NonNullable<NonNullable<NonNullable<AptosIndexerApiSpec['metadata']>['sources']>[0]['tables']>[0]; let tableSpec: TableType | null = null; for (const source of noditAptosIndexerApiSpec.metadata.sources) { if (source.tables) { for (const tableInfo of source.tables) { if (tableInfo.configuration && tableInfo.configuration.custom_name === queryRoot) { tableSpec = tableInfo; break; } } } if (tableSpec) break; } if (!tableSpec) { return createErrorResponse(`Query root '${queryRoot}' not found in the Aptos Indexer API schema. Use list_nodit_aptos_indexer_api_query_root to see available query roots.`, toolName); } const spec: GraphQLSpec = { name: queryRoot, table: tableSpec.table, columns: tableSpec.select_permissions?.[0]?.permission?.columns || [], relationships: { object: [], array: [] } }; if (tableSpec.object_relationships) { spec.relationships.object = tableSpec.object_relationships.map((rel: Relationship) => { if (!rel || typeof rel !== 'object') return { name: 'unknown', remote_table: 'unknown', column_mapping: {} }; return { name: rel.name ?? 'unknown', remote_table: rel.using?.manual_configuration?.remote_table?.name ?? 'unknown', column_mapping: rel.using?.manual_configuration?.column_mapping ?? {} }; }); } if (tableSpec.array_relationships) { spec.relationships.array = tableSpec.array_relationships.map((rel: Relationship) => { if (!rel || typeof rel !== 'object') return { name: 'unknown', remote_table: 'unknown', column_mapping: {} }; return { name: rel.name ?? 'unknown', remote_table: rel.using?.manual_configuration?.remote_table?.name ?? 'unknown', column_mapping: rel.using?.manual_configuration?.column_mapping ?? {} }; }); } return { content: [{ type: "text", text: `GraphQL specification for query root '${queryRoot}':\n\n${JSON.stringify(spec, null, 2)}` }] }; } catch (error) { return createErrorResponse(`Error processing Aptos Indexer API schema: ${(error as Error).message}`, toolName); } } );
  • TypeScript interface defining the structure of the Aptos Indexer API spec loaded and used by the tool.
    export interface AptosIndexerApiSpec { metadata?: { sources?: Array<{ tables?: Array<{ table?: string; configuration?: { custom_name?: string; }; select_permissions?: Array<{ permission?: { columns?: string[]; }; }>; object_relationships?: Array<Relationship>; array_relationships?: Array<Relationship>; }>; }>; }; }
  • Helper function that loads the JSON schema file for the Nodit Aptos Indexer API, used to populate the spec data.
    export function loadNoditAptosIndexerApiSpec(): AptosIndexerApiSpec { const schemaPath = path.resolve(__dirname, '../nodit-aptos-indexer-api-schema.json'); return loadOpenapiSpecFile(schemaPath) as AptosIndexerApiSpec; }

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