Skip to main content
Glama
Teradata

Teradata MCP Server

Official
by Teradata

qlty_missingValues

Identify columns with missing values in Teradata tables to assess data quality and ensure completeness for analysis.

Instructions

Get the column names that having missing values in a table.

Arguments: database_name - name of the database table_name - table name to analyze

Returns: ResponseType: formatted response with query results + metadata

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
database_nameYes
table_nameYes

Implementation Reference

  • Handler function that executes a Teradata SQL query using TD_ColumnSummary to retrieve columns with missing values (NullCount and NullPercentage), formats results using helper utilities, and returns a standardized response.
    def handle_qlty_missingValues(conn: TeradataConnection, database_name: str | None, table_name: str, *args, **kwargs):
        """
        Get the column names that having missing values in a table.
    
        Arguments:
          database_name - name of the database
          table_name - table name to analyze
    
        Returns:
          ResponseType: formatted response with query results + metadata
        """
        logger.debug(f"Tool: handle_qlty_missingValues: Args: table_name: {database_name}.{table_name}")
    
        if database_name is not None:
                table_name = f"{database_name}.{table_name}"
        with conn.cursor() as cur:
            rows = cur.execute(f"select ColumnName, NullCount, NullPercentage from TD_ColumnSummary ( on {table_name} as InputTable using TargetColumns ('[:]')) as dt ORDER BY NullCount desc")
            data = rows_to_json(cur.description, rows.fetchall())
            metadata = {
                "tool_name": "qlty_missingValues",
                "database_name": database_name,
                "table_name": table_name,
                "rows": len(data)
            }
            logger.debug(f"Tool: handle_qlty_missingValues: Metadata: {metadata}")
            return create_response(data, metadata)
  • Dynamic registration loop that discovers handle_qlty_missingValues via module loader, derives tool name 'qlty_missingValues' by stripping 'handle_' prefix, wraps the handler for MCP compatibility (injects conn, adapts signature), and registers it as an 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:
  • Imports utility functions create_response (formats data+metadata into MCP response) and rows_to_json (converts cursor results to JSON). These are used in the handler to process and return results.
    from teradata_mcp_server.tools.utils import create_response, rows_to_json
    
    logger = logging.getLogger("teradata_mcp_server")
    
    #------------------ Tool  ------------------#
    # Missing Values tool
    
    def handle_qlty_missingValues(conn: TeradataConnection, database_name: str | None, table_name: str, *args, **kwargs):
        """
        Get the column names that having missing values in a table.
    
        Arguments:
          database_name - name of the database
          table_name - table name to analyze
    
        Returns:
          ResponseType: formatted response with query results + metadata
        """
        logger.debug(f"Tool: handle_qlty_missingValues: Args: table_name: {database_name}.{table_name}")
    
        if database_name is not None:
                table_name = f"{database_name}.{table_name}"
        with conn.cursor() as cur:
            rows = cur.execute(f"select ColumnName, NullCount, NullPercentage from TD_ColumnSummary ( on {table_name} as InputTable using TargetColumns ('[:]')) as dt ORDER BY NullCount desc")
            data = rows_to_json(cur.description, rows.fetchall())
            metadata = {
                "tool_name": "qlty_missingValues",
                "database_name": database_name,
                "table_name": table_name,
                "rows": len(data)
            }
            logger.debug(f"Tool: handle_qlty_missingValues: Metadata: {metadata}")
            return create_response(data, metadata)

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