get_nodit_api_spec
Retrieve resolved API specification details for blockchain operations to understand available data structures and parameters.
Instructions
Gets the fully resolved spec details for a Nodit Blockchain Context API operationId. Returns details as a JSON string.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| operationId | Yes | The operationId to get the resolved specification for. |
Implementation Reference
- src/tools/get-nodit-api-spec.ts:26-54 (handler)Handler logic that identifies the API type based on operationId, retrieves spec details using helper functions, formats the response, and returns JSON string or error.async ({ operationId }) => { const toolName = "get_nodit_api_spec"; log(`Tool (${toolName}): Request for operationId: ${operationId}`); let apiInfo; if (isNodeApi(operationId)) { apiInfo = findNoditNodeApiDetails(operationId, noditNodeApiSpecMap); } else if (isWebhookApi(operationId)) { const postfix = "\nThis API cannot be invoked using the call_nodit_api tool." apiInfo = findNoditWebhookApiDetails(operationId, noditWebhookApiSpec); if (apiInfo && !apiInfo.details.description?.endsWith(postfix)) { apiInfo.details.description = apiInfo.details.description + postfix; } } else { apiInfo = findNoditDataApiDetails(operationId, noditDataApiSpec); } if (!apiInfo) { return createErrorResponse(`Spec for operationId '${operationId}' not found.`, toolName); } const finalSpecDetails = { operationId: operationId, path: apiInfo.path, method: apiInfo.method, details: apiInfo.details, }; return { content: [{ type: "text", text: JSON.stringify(finalSpecDetails, null, 2) }] }; }
- Zod input schema defining the operationId parameter.{ operationId: z.string().describe("The operationId to get the resolved specification for.") },
- src/tools/get-nodit-api-spec.ts:17-56 (registration)Function that registers the tool by loading API specs and calling server.tool with name, description, schema, and handler.export function registerGetNoditApiSpecTool(server: McpServer) { const noditNodeApiSpecMap: Map<string, NoditOpenApiSpecType> = loadNoditNodeApiSpecMap(); const noditDataApiSpec: NoditOpenApiSpecType = loadNoditDataApiSpec(); const noditWebhookApiSpec: NoditOpenApiSpecType = loadNoditWebhookApiSpec(); server.tool( "get_nodit_api_spec", "Gets the fully resolved spec details for a Nodit Blockchain Context API operationId. Returns details as a JSON string.", { operationId: z.string().describe("The operationId to get the resolved specification for.") }, async ({ operationId }) => { const toolName = "get_nodit_api_spec"; log(`Tool (${toolName}): Request for operationId: ${operationId}`); let apiInfo; if (isNodeApi(operationId)) { apiInfo = findNoditNodeApiDetails(operationId, noditNodeApiSpecMap); } else if (isWebhookApi(operationId)) { const postfix = "\nThis API cannot be invoked using the call_nodit_api tool." apiInfo = findNoditWebhookApiDetails(operationId, noditWebhookApiSpec); if (apiInfo && !apiInfo.details.description?.endsWith(postfix)) { apiInfo.details.description = apiInfo.details.description + postfix; } } else { apiInfo = findNoditDataApiDetails(operationId, noditDataApiSpec); } if (!apiInfo) { return createErrorResponse(`Spec for operationId '${operationId}' not found.`, toolName); } const finalSpecDetails = { operationId: operationId, path: apiInfo.path, method: apiInfo.method, details: apiInfo.details, }; return { content: [{ type: "text", text: JSON.stringify(finalSpecDetails, null, 2) }] }; } ); }
- src/tools/index.ts:16-16 (registration)Top-level call to register the get_nodit_api_spec tool during all tools registration.registerGetNoditApiSpecTool(server);
- Helper function to load Nodit node API specs into a map, used in the tool registration and handler.export function loadNoditNodeApiSpecMap(): Map<string, NoditOpenApiSpecType> { const noditApiSpecMap = new Map<string, NoditOpenApiSpecType>(); const specDir = path.resolve(__dirname, '../spec/reference'); try { const files = fs.readdirSync(specDir);