Skip to main content
Glama
Teradata

Teradata MCP Server

Official
by Teradata

plot_line_chart

Generate line charts from Teradata data to visualize trends and relationships between specified columns and labels for analysis.

Instructions

Function to generate a line plot for labels and columns. Columns mentioned in labels are used for x-axis and columns are used for y-axis.

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

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

RETURNS: dict

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_nameYes
labelsYes
columnsYes

Implementation Reference

  • The main handler function for the 'plot_line_chart' MCP tool. It validates inputs, ensures labels is a string column name, and delegates to the get_plot_json_data helper to query the Teradata table and format Chart.js line chart data.
    def handle_plot_line_chart(conn: TeradataConnection, table_name: str, labels: str, columns: str|List[str]):
        """
        Function to generate a line plot for labels and columns.
        Columns mentioned in labels are used for x-axis and columns are used for y-axis.
    
        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
    
            columns:
                Required Argument.
                Specifies the column to be used for generating the line plot.
                Types: List[str]
    
        RETURNS:
            dict
        """
        # Labels must be always a string which represents a column.
        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, columns)
  • Supporting utility that constructs SQL query, executes it on the connection, processes results into Chart.js-compatible JSON structure with labels and datasets, handles colors, and wraps in a standardized response format.
    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
            })
  • Dynamic registration code that loads modules via ModuleLoader, discovers functions starting with 'handle_', derives tool name by removing 'handle_' prefix (e.g., handle_plot_line_chart -> plot_line_chart), wraps the handler with MCP adapter (injects DB connection, QueryBand, etc.), and registers it as an MCP tool using mcp.tool.
    # Register code tools via module loader
    module_loader = td.initialize_module_loader(config)
    if module_loader:
        all_functions = module_loader.get_all_functions()
        for name, func in all_functions.items():
            if not (inspect.isfunction(func) and name.startswith("handle_")):
                continue
            tool_name = name[len("handle_"):]
            if not any(re.match(p, tool_name) for p in config.get('tool', [])):
                continue
            # Skip template tools (used for developer reference only)
            if tool_name.startswith("tmpl_"):
                logger.debug(f"Skipping template tool: {tool_name}")
                continue
            # Skip BAR tools if BAR functionality is disabled
            if tool_name.startswith("bar_") and not enableBAR:
                logger.info(f"Skipping BAR tool: {tool_name} (BAR functionality disabled)")
                continue
            # Skip chat completion tools if chat completion functionality is disabled
            if tool_name.startswith("chat_") and not enableChat:
                logger.info(f"Skipping chat completion tool: {tool_name} (chat completion functionality disabled)")
                continue
            wrapped = make_tool_wrapper(func)
            mcp.tool(name=tool_name, description=wrapped.__doc__)(wrapped)
            logger.info(f"Created tool: {tool_name}")
            logger.debug(f"Tool Docstring: {wrapped.__doc__}")
    else:
  • Package init file that imports plot_tools and plot_utils, making the handle_plot_line_chart handler and helpers available for discovery by the module loader.
    from .plot_resources import *
    from .plot_tools import *
    from .plot_utils import *
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions generating a plot and returns a dict, but lacks critical behavioral details: it doesn't specify what the dict contains (e.g., image data, plot metadata), whether this is a read-only or mutating operation, any permissions required, or error handling. The description adds minimal value beyond the basic action.

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

Conciseness3/5

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

The description is structured with sections for function, parameters, and returns, which is clear. However, it includes redundant or confusing elements: the function section mentions 'donut plot' incorrectly, and parameter descriptions are brief but not fully informative. It's moderately concise but could be more efficient and error-free.

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?

Given the complexity (a plotting tool with 3 parameters), no annotations, no output schema, and 0% schema coverage, the description is incomplete. It lacks details on return values (beyond 'dict'), behavioral traits, error cases, and how to interpret parameters in context. For a tool that likely generates visualizations, this is inadequate.

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. It lists parameters with brief explanations, but these are insufficient: 'labels' is described as 'Specifies the labels to be used for the line plot' without clarifying if these are x-axis labels or data labels, and 'columns' as 'Specifies the column to be used for generating the line plot' contradicts the schema's List[str] type by using singular 'column'. The description adds some meaning but fails to fully document the parameters.

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 the tool 'generate[s] a line plot for labels and columns' and mentions x-axis and y-axis usage, which clarifies the basic purpose. However, it's somewhat vague about what 'labels' and 'columns' specifically represent in the context of a line chart, and it doesn't distinguish this tool from sibling plotting tools like 'plot_pie_chart' or 'plot_radar_chart' beyond the chart type name.

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 on when to use this tool versus alternatives. The description doesn't mention sibling tools (e.g., other plot types like 'plot_pie_chart'), prerequisites, or specific contexts where a line chart is preferred. Usage is implied only by the tool name and basic function, with no explicit when/when-not statements.

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