Skip to main content
Glama
getChartImgLink.ts964 B
import Client from "../../Client/index.js"; import bestEffortForJson from "../../utils/bestEffortForJson.js"; import { quickChartUrl } from "../../constants/index.js"; type Error = { message?: string; data?: { [name: string]: string }; }; export interface CodeInfo { code: string; description?: string; descriptionEn?: string; } export default async function getChartImgLink( agent: Client, json: any, ) { try { let jsonStr = '{}'; try { jsonStr = JSON.stringify(json || '{}'); } catch (e) { console.error(e); } if (jsonStr && (jsonStr?.includes('{') || jsonStr?.includes(',') || jsonStr?.includes('['))) { jsonStr = bestEffortForJson(jsonStr); jsonStr = encodeURIComponent(jsonStr); // check need to encodeURIComponent } const response = `${quickChartUrl}?c=${jsonStr || ''}`; return response; } catch (error: any) { throw new Error(`getChartImgLink failed: ${error.message}`); } }

Implementation Reference

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/datafe/quick-chart-mcp'

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