Skip to main content
Glama
jsonata.ts1.15 kB
/** * JSONata expression evaluation */ import jsonata from "jsonata"; import { logger } from "../logger.js"; export async function evaluateJsonata( expression: string, context: Record<string, unknown> ): Promise<unknown> { try { const expr = jsonata(expression); const result = await expr.evaluate(context); // Log for debugging logger.debug(`JSONata expression: ${expression}`); logger.debug(`JSONata context keys: ${Object.keys(context).join(", ")}`); if (typeof context.list_directory_node === "string") { logger.debug(`list_directory_node value (first 100 chars): ${(context.list_directory_node as string).substring(0, 100)}`); logger.debug(`list_directory_node has actual newlines: ${(context.list_directory_node as string).includes("\n")}`); } logger.debug(`JSONata result: ${JSON.stringify(result)}`); return result; } catch (error) { logger.error(`JSONata evaluation error: ${error instanceof Error ? error.message : String(error)}`); logger.error(`Expression: ${expression}`); logger.error(`Context: ${JSON.stringify(context, null, 2)}`); throw error; } }

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/TeamSparkAI/mcpGraph'

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