Skip to main content
Glama
blitzstermayank

Teradata MCP Server

dba_tableSpace

Retrieve table space usage for specific tables or entire databases in Teradata to monitor storage allocation and optimize database performance.

Instructions

Get table space used for a table if table name is provided or get table space for all tables in a database if a database name is provided."

Arguments: database_name - database name table_name - table name

Returns: ResponseType: formatted response with query results + metadata

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
database_nameNo
table_nameNo

Implementation Reference

  • The core handler function for the 'dba_tableSpace' tool. It queries the DBC.AllSpaceV view to retrieve current and peak permanent space usage, skew percentage for specified table(s) in a database or all tables, based on optional database_name and table_name parameters. Returns formatted JSON data with metadata.
    def handle_dba_tableSpace(conn: TeradataConnection, database_name: str | None = None, table_name: str | None = None, *args, **kwargs):
        """
        Get table space used for a table if table name is provided or get table space for all tables in a database if a database name is provided."
    
        Arguments:
          database_name - database name
          table_name - table name
    
        Returns:
          ResponseType: formatted response with query results + metadata
        """
        logger.debug(f"Tool: handle_dba_tableSpace: Args: database_name: {database_name}, table_name: {table_name}")
    
        with conn.cursor() as cur:
            if not database_name and not table_name:
                logger.debug("No database or table name provided, returning all tables and space information.")
                rows = cur.execute("""SELECT DatabaseName, TableName, SUM(CurrentPerm) AS CurrentPerm1, SUM(PeakPerm) as PeakPerm
                ,CAST((100-(AVG(CURRENTPERM)/MAX(NULLIFZERO(CURRENTPERM))*100)) AS DECIMAL(5,2)) as SkewPct
                FROM DBC.AllSpaceV
                GROUP BY DatabaseName, TableName
                ORDER BY CurrentPerm1 desc;""")
            elif not database_name:
                logger.debug(f"No database name provided, returning all space information for table: {table_name}.")
                rows = cur.execute(f"""SELECT DatabaseName, TableName, SUM(CurrentPerm) AS CurrentPerm1, SUM(PeakPerm) as PeakPerm
                ,CAST((100-(AVG(CURRENTPERM)/MAX(NULLIFZERO(CURRENTPERM))*100)) AS DECIMAL(5,2)) as SkewPct
                FROM DBC.AllSpaceV
                WHERE TableName = '{table_name}'
                GROUP BY DatabaseName, TableName
                ORDER BY CurrentPerm1 desc;""")
            elif not table_name:
                logger.debug(f"No table name provided, returning all tables and space information for database: {database_name}.")
                rows = cur.execute(f"""SELECT TableName, SUM(CurrentPerm) AS CurrentPerm1, SUM(PeakPerm) as PeakPerm
                ,CAST((100-(AVG(CURRENTPERM)/MAX(NULLIFZERO(CURRENTPERM))*100)) AS DECIMAL(5,2)) as SkewPct
                FROM DBC.AllSpaceV
                WHERE DatabaseName = '{database_name}'
                GROUP BY TableName
                ORDER BY CurrentPerm1 desc;""")
            else:
                logger.debug(f"Database name: {database_name}, Table name: {table_name}, returning space information for this table.")
                rows = cur.execute(f"""SELECT DatabaseName, TableName, SUM(CurrentPerm) AS CurrentPerm1, SUM(PeakPerm) as PeakPerm
                ,CAST((100-(AVG(CURRENTPERM)/MAX(NULLIFZERO(CURRENTPERM))*100)) AS DECIMAL(5,2)) as SkewPct
                FROM DBC.AllSpaceV
                WHERE DatabaseName = '{database_name}' AND TableName = '{table_name}'
                GROUP BY DatabaseName, TableName
                ORDER BY CurrentPerm1 desc;""")
    
            data = rows_to_json(cur.description, rows.fetchall())
            metadata = {
                "tool_name": "dba_tableSpace",
                "database_name": database_name,
                "table_name": table_name,
                "total_tables": len(data)
            }
            logger.debug(f"Tool: handle_dba_tableSpace: metadata: {metadata}")
            return create_response(data, metadata)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4/5.0
Behavior3/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 states the tool retrieves table space based on parameters, implying a read operation, but does not mention permissions, performance impact, or side effects. The description is accurate but minimal.

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 a single sentence that conveys the entire functionality without any extraneous words. It is efficient and front-loaded, making it easy for the agent to parse.

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

Completeness4/5

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

The description includes a return type line ('formatted response with query results + metadata'), providing basic context on output. Given the tool's simplicity and the absence of an output schema, this is adequate. However, for a database tool, additional context on what 'table space' means could be beneficial.

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 0%, so the description must compensate. It provides context for when each parameter is used ('if table name is provided' and 'if a database name is provided'), but does not specify format, constraints, or expected values. This partial compensation warrants a 3.

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

Purpose5/5

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

Description clearly states the verb 'Get' and the resource 'table space'. It distinguishes between two modes: retrieving space for a specific table when table name is provided, or for all tables in a database when database name is provided. This differentiates it from sibling tools like base_tablePreview or dba_tableUsageImpact.

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

Usage Guidelines4/5

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

The description explicitly says when to provide table name versus database name, guiding the agent on parameter usage. However, it does not mention when not to use this tool, alternatives, or prerequisites, so it falls short of a 5.

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