Skip to main content
Glama

GetChartImgLink

Generate chart images by providing Quick Chart API parameters in JSON format. Create and retrieve chart visualization links for data representation.

Instructions

To draw chart and get chart image link by parameters, and parameter grammar follows Quick Chart API (quickchart.io).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
jsonNoquick chart api's (quickchart.io) parameters and format is JSON object. The object does not include any functions, only values.

Implementation Reference

  • Core handler function implementing the logic to generate a QuickChart image link from the provided JSON chart configuration.
    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}`); } }
  • Wrapper handler for the GetChartImgLink MCP tool that extracts input, calls the core getChartImgLink function, handles errors, and returns a standardized response.
    handler: async (agent: Client, input: Record<string, any>) => { try { const { json } = input || {}; const response = await getChartImgLink(agent, json); return { status: "success", message: response, }; } catch (error: any) { // Handle specific error types if (error.response) { const { status, data } = error.response; if (status === 429) { return { status: "error", message: "Rate limit exceeded. Please try again later.", }; } return { status: "error", message: `error: ${data.error?.message || error.message}`, }; } return { status: "error", message: `Failed to get information: ${error.message}`, }; } },
  • Zod schema defining the input structure for the GetChartImgLink tool: a JSON object for QuickChart parameters.
    schema: z.object({ json: z.any().describe("quick chart api's (quickchart.io) parameters and format is JSON object. The object does not include any functions, only values."), }),
  • Registers the GetChartImgLink ActionTool in the ACTIONS map, which is used by the MCP server to expose tools.
    const ACTIONS: any = { [EnumAction.GET_CHART_IMG_LINK]: getChartImgLink, }
  • Defines the string name 'GetChartImgLink' for the tool in EnumAction.
    'GET_CHART_IMG_LINK' = 'GetChartImgLink', 'INSTALL_QUICK_CHART' = 'InstallQuickChart',

Other Tools

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