Skip to main content
Glama
data-apis.ts2.12 kB
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { createErrorResponse, normalizeDescription, loadNoditDataApiSpec, NoditOpenApiSpecType } from "../helper/nodit-apidoc-helper.js"; 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); } }); }

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