Skip to main content
Glama

get_api_endpoint_schema

Retrieve the schema for an API endpoint in Hive Intelligence to structure and validate API calls using the call_api_endpoint tool.

Instructions

Get the schema for an endpoint in the HIVE API. You can use the schema returned by this tool to call an endpoint with the call_api_endpoint tool.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
endpointYesThe name of the endpoint to get the schema for.

Implementation Reference

  • The main handler function for the 'get_api_endpoint_schema' tool. It validates the input args using the Zod schema to extract the endpoint name, searches for the matching endpoint in the provided endpoints list, and returns the endpoint schema formatted as text content using the asTextContentResult helper.
    handler: async (args: Record<string, unknown> | undefined) => { if (!args) { throw new Error('No endpoint provided'); } const endpointName = getEndpointSchema.parse(args).endpoint; // First, look in the original endpoints array let endpoint = endpoints.find((e) => e.name === endpointName); if (!endpoint) { throw new Error(`Endpoint ${endpointName} not found`); } return asTextContentResult(endpoint); },
  • Zod schema defining the input for the tool: an object with a required 'endpoint' string field describing the endpoint name.
    const getEndpointSchema = z.object({ endpoint: z.string().describe('The name of the endpoint to get the schema for.'), });
  • The registration of the tool as getEndpointTool object, including metadata, tool definition with name, description, inputSchema, and the handler. This object is returned by dynamicTools() and registered in the MCP server.
    const getEndpointTool = { metadata: { resource: 'dynamic_tools', operation: 'read' as const, tags: [], }, tool: { name: 'get_api_endpoint_schema', description: 'Get the schema for an endpoint in the HIVE API. You can use the schema returned by this tool to call an endpoint with the `call_api_endpoint` tool.', inputSchema: zodToInputSchema(getEndpointSchema), }, handler: async (args: Record<string, unknown> | undefined) => { if (!args) { throw new Error('No endpoint provided'); } const endpointName = getEndpointSchema.parse(args).endpoint; // First, look in the original endpoints array let endpoint = endpoints.find((e) => e.name === endpointName); if (!endpoint) { throw new Error(`Endpoint ${endpointName} not found`); } return asTextContentResult(endpoint); }, };
  • Helper function to format the result as MCP text content, with intelligent truncation for large responses to respect token limits.
    export function asTextContentResult(result: Object): any { // return {data: result} // Estimate token count (roughly 4 chars per token) const MAX_TOKENS = 25000; const CHARS_PER_TOKEN = 4; const maxChar = MAX_TOKENS * CHARS_PER_TOKEN; // ~100,000 chars for 25k tokens const jsonString = JSON.stringify(result, null, 2); if (jsonString.length > maxChar) { // Try to intelligently truncate if it's an array if (Array.isArray(result)) { const truncatedArray = result.slice(0, Math.floor(result.length * maxChar / jsonString.length)); const truncatedJson = JSON.stringify({ results: truncatedArray, truncated: true, originalLength: result.length, returnedLength: truncatedArray.length, message: "Response truncated due to size limits. Consider using pagination." }, null, 2); return { content: [ { type: 'text', text: truncatedJson, }, ], }; } // For objects with results array if (typeof result === 'object' && result !== null && 'results' in result && Array.isArray((result as any).results)) { const originalResults = (result as any).results; const estimatedItemSize = jsonString.length / originalResults.length; const maxItems = Math.floor(maxChar / estimatedItemSize); const truncatedResult = { ...result, results: originalResults.slice(0, maxItems), truncated: true, originalCount: originalResults.length, returnedCount: maxItems, message: "Response truncated due to size limits. Use pagination parameters (limit/offset) for more results." }; return { content: [ { type: 'text', text: JSON.stringify(truncatedResult, null, 2), }, ], }; } // Fallback to simple truncation const truncated = jsonString.substring(0, maxChar) + '\n... [TRUNCATED DUE TO SIZE LIMITS]'; return { content: [ { type: 'text', text: truncated, }, ], }; } return { content: [ { type: 'text', text: jsonString, }, ], }; }

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/hive-intel/hive-crypto-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server