Skip to main content
Glama
Teradata

Teradata MCP Server

Official
by Teradata

plot_pie_chart

Generate pie charts from Teradata data by specifying table, labels, and value columns to visualize categorical distributions.

Instructions

Function to generate a pie chart plot for labels and columns. Columns mentioned in labels are used as labels and column is used to plot.

PARAMETERS: table_name: Required Argument. Specifies the name of the table to generate the donut plot. Types: str

labels:
    Required Argument.
    Specifies the labels to be used for the line plot.
    Types: str

column:
    Required Argument.
    Specifies the column to be used for generating the line plot.
    Types: str

RETURNS: dict

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_nameYes
labelsYes
columnYes

Implementation Reference

  • Handler function that implements the core logic for the 'plot_pie_chart' tool. It validates input, queries the Teradata table, and returns Chart.js compatible JSON data for a pie chart.
    def handle_plot_pie_chart(conn: TeradataConnection, table_name: str, labels: str, column: str):
        """
        Function to generate a pie chart plot for labels and columns.
        Columns mentioned in labels are used as labels and column is used to plot.
    
        PARAMETERS:
            table_name:
                Required Argument.
                Specifies the name of the table to generate the donut plot.
                Types: str
    
            labels:
                Required Argument.
                Specifies the labels to be used for the line plot.
                Types: str
    
            column:
                Required Argument.
                Specifies the column to be used for generating the line plot.
                Types: str
    
        RETURNS:
            dict
        """
        if not isinstance(labels, str):
            raise ValueError("labels must be a string representing the column name for x-axis.")
    
        return get_plot_json_data(conn, table_name, labels, column, 'pie')
  • Supporting utility function called by the pie chart handler (and others) to execute SQL query on the table, fetch data, format it into Chart.js datasets with colors, and wrap in a response structure.
    def get_plot_json_data(conn, table_name, labels, columns, chart_type='line'):
        """
        Helper function to fetch data from a Teradata table and formats it for plotting.
        Right now, designed only to support line plots from chart.js .
        """
        # Define the colors first.
        colors = ['rgb(75, 192, 192)', '#99cbba', '#d7d0c4', '#fac778', '#e46c59', '#F9CB99', '#280A3E', '#F2EDD1', '#689B8A']
        # Chart properties. Every chart needs different property for colors.
        chart_properties = {'line': 'borderColor', 'polar': 'backgroundColor', 'pie': 'backgroundColor'}
    
        columns = [columns] if isinstance(columns, str) else columns
        sql = "select {labels}, {columns} from {table_name} order by {labels}".format(
              labels=labels, columns=','.join(columns), table_name=table_name)
    
        # Prepare the statement.
        with conn.cursor() as cur:
            recs = cur.execute(sql).fetchall()
    
        # Define the structure of the chart data. Below is the structure expected by chart.js
        # {
        #     labels: labels,
        #     datasets: [{
        #         label: 'My First Dataset',
        #         data: [65, 59, 80, 81, 56, 55, 40],
        #         fill: false,
        #         borderColor: 'rgb(75, 192, 192)',
        #         tension: 0.1
        #     }]
        # }
        labels = []
        datasets = [[] for _ in range(len(columns))]
        for rec in recs:
            labels.append(rec[0])
            for i_, val in enumerate(rec[1:]):
                datasets[i_].append(val)
    
        # Prepare the datasets for chart.js
        datasets_ = []
        for i, dataset in enumerate(datasets):
            datasets_.append({
                'label': columns[i],
                'data': dataset,
                'borderColor': colors[i],
                'fill': False
            })
    
        # For polar plot, every dataset needs different colors.
        if chart_type in ('polar', 'pie'):
            for i, dataset in enumerate(datasets_):
                # Remove borderColor and add backgroundColor
                dataset.pop('borderColor', None)
                dataset['backgroundColor'] = colors
    
        chart_data = {"labels": [str(l) for l in labels],
                      "datasets": datasets_}
        logger.debug("Chart data: %s", json.dumps(chart_data, indent=2))
    
        return create_response(data=chart_data, metadata={
                "tool_description": "chart js {} plot data".format(chart_type),
                "table_name": table_name,
                "labels": labels,
                "columns": columns
            })
Behavior1/5

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

With no annotations provided, the description carries full burden but provides minimal behavioral information. It doesn't disclose what the tool actually returns (just says 'dict' without explaining the structure), whether it creates a file or displays the chart, error conditions, or any side effects. The description contains internal contradictions that confuse behavior understanding (mentions 'donut plot' and 'line plot' while claiming to generate a pie chart).

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

Conciseness2/5

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

The structure is poor with redundant sections that don't add value. The PARAMETERS and RETURNS sections repeat schema information without providing additional insight. The description contains multiple contradictions and inconsistencies that create confusion rather than clarity. While brief, it's not effectively concise due to these quality issues.

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

Completeness1/5

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

For a data visualization tool with 3 parameters, 0% schema description coverage, no annotations, and no output schema, the description is completely inadequate. It doesn't explain what the tool actually produces, how parameters relate to each other, what the output contains, or any behavioral characteristics. The contradictions in the text further undermine completeness.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate but provides inadequate parameter semantics. The parameters section repeats basic information already in the schema (names, types, required status) without adding meaningful context. It doesn't explain what 'labels' and 'column' represent in relation to each other, what format they should be in, or how they interact with 'table_name'. The description also contains confusing contradictions (mentions 'line plot' in parameter descriptions).

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

Purpose3/5

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

The description states 'generate a pie chart plot for labels and columns' which provides a basic purpose, but it's vague about what exactly the tool does. It mentions 'labels and columns' but doesn't clearly explain the relationship between them or what the resulting visualization represents. The description also contains inconsistencies (mentions 'donut plot' and 'line plot' which contradict the pie chart purpose).

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?

No guidance is provided about when to use this tool versus alternatives. There are multiple sibling visualization tools (plot_line_chart, plot_polar_chart, plot_radar_chart) but the description doesn't explain when a pie chart is appropriate versus these other chart types. No context about prerequisites or typical use cases is given.

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/Teradata/teradata-mcp-server'

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