Skip to main content
Glama

create-table

Generate table images from structured data with customizable styling, then retrieve the image URL or save it directly to a file for use in reports and visualizations.

Instructions

Create table images using QuickChart - get table image URL or save table image to file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesWhether to get table URL or save as file
outputPathNoPath where to save the file (only used with action=save_file)
dataYesTable data with title, columns, and dataSource
optionsNoTable styling options

Implementation Reference

  • The main handler function that executes the create-table tool: validates inputs, generates table URL and image using QuickChart API, handles base64 image and optional file saving.
    export async function handleTableTool(args: any): Promise<any> {
      const data = args.data as any;
      const action = args.action as string;
      
      validateTableData(data);
      validateAction(action);
      validateOutputPath(args.outputPath, action);
    
      const config = buildTableConfig(data, args.options);
      const tableUrl = buildTableUrl(data);
    
      const result: any = {
        content: [
          {
            type: "text",
            text: "Below is the table URL:",
          },
          {
            type: "text",
            text: tableUrl,
          },
        ],
        metadata: {
          tableType: "data",
          generatedAt: new Date().toISOString(),
          tableUrl: tableUrl,
        },
      };
    
      let pngData: any = null;
      try {
        pngData = await fetchTableContent(config);
        const pngBase64 = Buffer.from(pngData).toString("base64");
    
        result.content.push(
          {
            type: "text",
            text: "Below is the PNG image:",
          },
          {
            type: "image",
            data: pngBase64,
            mimeType: "image/png",
          }
        );
        result.metadata.pngBase64 = pngBase64;
      } catch (error) {
        result.content.unshift({
          type: "text",
          text: "⚠️ Failed to fetch table image",
        });
        result.content.push({
          type: "text",
          text: `Error: ${error instanceof Error ? error.message : String(error)}`,
        });
        result.metadata.error =
          error instanceof Error ? error.message : String(error);
      }
    
      if (action === "get_url") {
        return result;
      }
    
      const outputPath = getDownloadPath(
        args.outputPath as string | undefined,
        "png"
      );
    
      try {
        const dir = path.dirname(outputPath);
        if (!fs.existsSync(dir)) {
          fs.mkdirSync(dir, { recursive: true });
        }
    
        // If pngData is null, fetch it again for file saving
        const dataToSave = pngData || await fetchTableContent(config);
        fs.writeFileSync(outputPath, dataToSave);
    
        result.metadata.savedPath = outputPath;
        result.content.push({
          type: "text",
          text: "Below is the saved file path:",
        });
        result.content.push({
          type: "text",
          text: outputPath,
        });
        return result;
      } catch (error) {
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to save table image: ${
            error instanceof Error ? error.message : String(error)
          }`
        );
      }
    }
  • Defines the Tool object with inputSchema for validating parameters of create-table tool, including action, data (title, columns, dataSource), outputPath, and styling options.
    export const CREATE_TABLE_TOOL: Tool = {
      name: "create-table",
      description:
        "Create table images using QuickChart - get table image URL or save table image to file",
      inputSchema: {
        type: "object",
        properties: {
          action: {
            type: "string",
            enum: ["get_url", "save_file"],
            description: "Whether to get table URL or save as file",
          },
          outputPath: {
            type: "string",
            description:
              "Path where to save the file (only used with action=save_file)",
          },
          data: {
            type: "object",
            description: "Table data with title, columns, and dataSource",
            properties: {
              title: {
                type: "string",
                description: "Table title",
              },
              columns: {
                type: "array",
                items: {
                  type: "object",
                  properties: {
                    title: {
                      type: "string",
                      description: "Column header title",
                    },
                    dataIndex: {
                      type: "string",
                      description: "Data property key",
                    },
                    width: {
                      type: "integer",
                      description: "Column width",
                    },
                    align: {
                      type: "string",
                      enum: ["left", "center", "right"],
                      description: "Text alignment",
                    },
                  },
                  required: ["title", "dataIndex"],
                },
                description: "Column definitions",
              },
              dataSource: {
                type: "array",
                items: {
                  type: "object",
                  description:
                    "Row data object with keys matching column dataIndex values",
                },
                description: "Table data rows",
              },
            },
            required: ["columns", "dataSource"],
          },
          options: {
            type: "object",
            description: "Table styling options",
            properties: {
              cellWidth: {
                type: "integer",
                description: "Cell width in pixels",
              },
              cellHeight: {
                type: "integer",
                description: "Cell height in pixels",
              },
              offsetLeft: {
                type: "integer",
                description: "Left offset in pixels",
              },
              offsetRight: {
                type: "integer",
                description: "Right offset in pixels",
              },
              fontFamily: {
                type: "string",
                description: "Font family",
              },
              backgroundColor: {
                type: "string",
                description: "Background color",
              },
              fontSize: {
                type: "integer",
                description: "Font size",
              },
              borderColor: {
                type: "string",
                description: "Border color",
              },
              headerColor: {
                type: "string",
                description: "Header background color",
              },
            },
          },
        },
        required: ["action", "data"],
      },
    };
  • Registers the create-table tool handler (handleTableTool) in the central tool handlers mapping.
    "create-table": { handler: handleTableTool, toolName: ToolNames.TABLE },
  • Adds the CREATE_TABLE_TOOL to the list of all available tools, associated with ToolNames.TABLE.
    { tool: CREATE_TABLE_TOOL, name: ToolNames.TABLE },
  • Provides documentation, examples, and usage information for the create-table tool.
    "create-table": {
      name: "create-table",
      description:
        "Convert data to table images - get table image URL or save table image to file",
      documentation: "https://quickchart.io/documentation/apis/table-image-api/",
      additionalResources: {
        apiReference: "https://quickchart.io/documentation/apis/table-image-api/",
      },
      promptExamples: [
        'Financial Reports: "Convert quarterly earnings data into professional table"',
        'Comparison Charts: "Create feature comparison table for products"',
        'Summary Reports: "Generate formatted tables for executive presentations"',
      ],
      usageExample: {
        action: "save_file",
        data: {
          title: "Q4 Sales Report",
          columns: [
            { title: "Product", dataIndex: "product" },
            { title: "Revenue", dataIndex: "revenue" },
          ],
          dataSource: [
            { product: "Product A", revenue: "$50,000" },
            { product: "Product B", revenue: "$75,000" },
          ],
        },
      },
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the two action types but doesn't describe what happens when each is selected (e.g., what format the URL returns, where files are saved, error conditions, or performance characteristics). For a tool with file system interaction and external service dependency (QuickChart), this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise (one sentence) and front-loaded with the core functionality. Every word earns its place: 'Create table images using QuickChart' establishes the what and how, while '- get table image URL or save table image to file' efficiently describes the two primary actions. No wasted words or redundant information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 4 parameters (including complex nested objects), no annotations, and no output schema, the description is inadequate. It doesn't explain what the tool returns (URL format? file path? success confirmation?), doesn't mention QuickChart integration requirements or limitations, and provides no error handling context. The single sentence description leaves too many operational questions unanswered.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds minimal value beyond the schema - it mentions 'table images' which hints at the data parameter's purpose, but doesn't provide additional context about parameter relationships or usage patterns. This meets the baseline expectation when schema coverage is complete.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Create table images using QuickChart' with two specific actions (get URL or save to file). It distinguishes from most siblings by focusing on tables rather than charts, barcodes, or other visualizations. However, it doesn't explicitly differentiate from all possible table-related tools that might exist elsewhere.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to choose QuickChart over other charting tools in the sibling list, nor does it provide context about appropriate use cases for table images versus other visualization formats. The agent receives no usage context beyond the tool's basic functionality.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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/TakanariShimbo/quickchart-mcp-server'

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