Skip to main content
Glama
Teradata

Teradata MCP Server

Official
by Teradata

dba_databaseSpace

Retrieve database space allocations for a specific database or all databases to monitor storage usage and manage capacity in Teradata systems.

Instructions

Get database space if database name is provided, otherwise get all databases space allocations.

Arguments: database_name - database name

Returns: ResponseType: formatted response with query results + metadata

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
database_nameYes

Implementation Reference

  • Handler function implementing the dba_databaseSpace tool. Queries DBC.DiskSpaceV to compute space metrics (allocated, used, free in GB, percent used) for a specific database or all databases.
    def handle_dba_databaseSpace(conn: TeradataConnection, database_name: str | None | None, *args, **kwargs):
        """
        Get database space if database name is provided, otherwise get all databases space allocations.
    
        Arguments:
          database_name - database name
    
        Returns:
          ResponseType: formatted response with query results + metadata
        """
        logger.debug(f"Tool: handle_dba_databaseSpace: Args: database_name: {database_name}")
    
        database_name_filter = f"AND objectdatabasename = '{database_name}'" if database_name else ""
    
        with conn.cursor() as cur:
            if not database_name:
                logger.debug("No database name provided, returning all databases and space information.")
                rows = cur.execute("""
                    SELECT
                        DatabaseName,
                        CAST(SUM(MaxPerm)/1024/1024/1024 AS DECIMAL(10,2)) AS SpaceAllocated_GB,
                        CAST(SUM(CurrentPerm)/1024/1024/1024 AS DECIMAL(10,2)) AS SpaceUsed_GB,
                        CAST((SUM(MaxPerm) - SUM(CurrentPerm))/1024/1024/1024 AS DECIMAL(10,2)) AS FreeSpace_GB,
                        CAST((SUM(CurrentPerm) * 100.0 / NULLIF(SUM(MaxPerm),0)) AS DECIMAL(10,2)) AS PercentUsed
                    FROM DBC.DiskSpaceV
                    WHERE MaxPerm > 0
                    GROUP BY 1
                    ORDER BY 5 DESC;
                """)
            else:
                logger.debug(f"Database name: {database_name}, returning space information for this database.")
                rows = cur.execute(f"""
                    SELECT
                        DatabaseName,
                        CAST(SUM(MaxPerm)/1024/1024/1024 AS DECIMAL(10,2)) AS SpaceAllocated_GB,
                        CAST(SUM(CurrentPerm)/1024/1024/1024 AS DECIMAL(10,2)) AS SpaceUsed_GB,
                        CAST((SUM(MaxPerm) - SUM(CurrentPerm))/1024/1024/1024 AS DECIMAL(10,2)) AS FreeSpace_GB,
                        CAST((SUM(CurrentPerm) * 100.0 / NULLIF(SUM(MaxPerm),0)) AS DECIMAL(10,2)) AS PercentUsed
                    FROM DBC.DiskSpaceV
                    WHERE MaxPerm > 0
                    AND DatabaseName = '{database_name}'
                    GROUP BY 1;
                """)
    
            data = rows_to_json(cur.description, rows.fetchall())
            metadata = {
                "tool_name": "dba_databaseSpace",
                "database_name": database_name,
                "total_databases": len(data)
            }
            logger.debug(f"Tool: handle_dba_databaseSpace: metadata: {metadata}")
            return create_response(data, metadata)
  • Dynamic registration code that discovers handle_* functions via module_loader, wraps them for MCP (injecting DB connection, QueryBand, etc.), and registers as tools if matching profile patterns. Registers handle_dba_databaseSpace as dba_databaseSpace.
    # 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__}")
  • Imports dba_tools.py into the dba module, making its functions available for dynamic discovery and loading by the module_loader.
    from .dba_resources import *
    from .dba_tools import *
  • Imports and logger setup used by the dba_databaseSpace handler.
    import logging
    
    from teradatasql import TeradataConnection
    
    from teradata_mcp_server.tools.utils import create_response, rows_to_json
    
    logger = logging.getLogger("teradata_mcp_server")
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 the tool returns a 'formatted response with query results + metadata', which gives some behavioral insight. However, it lacks details on permissions needed, whether it's read-only or has side effects, rate limits, or error handling. For a tool with no annotations, this leaves significant gaps in understanding its behavior.

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

Conciseness4/5

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

The description is concise and well-structured: it starts with the core functionality, then lists arguments and returns in a clear format. Every sentence adds value, with no redundant information. It could be slightly more front-loaded by integrating the conditional logic into the first sentence, but overall it's efficient.

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

Completeness3/5

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

Given the tool's moderate complexity (conditional querying), no annotations, no output schema, and low schema coverage, the description is somewhat complete but has gaps. It covers the basic purpose and parameter usage but lacks details on output format, error cases, or integration with sibling tools. It's adequate as a minimum viable description but could be more comprehensive.

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?

The description adds minimal semantics: it states that 'database_name' is the database name and explains the conditional logic (if provided vs. not provided). With 0% schema description coverage and 1 parameter, this compensates somewhat but doesn't provide format examples, constraints, or default behaviors beyond the basic explanation. The baseline is adjusted to 3 due to low schema coverage and partial compensation.

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: 'Get database space if database name is provided, otherwise get all databases space allocations.' It specifies the verb ('Get') and resource ('database space'), and distinguishes between single-database vs. all-database queries. However, it doesn't explicitly differentiate from sibling tools like 'dba_systemSpace' or 'dba_tableSpace', which appear related to space monitoring.

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

Usage Guidelines3/5

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

The description implies usage guidelines by stating the conditional behavior based on whether a database name is provided. It suggests using this tool for space allocation queries, but doesn't explicitly say when to use it versus alternatives like 'dba_systemSpace' or 'dba_tableSpace', nor does it mention any prerequisites or exclusions.

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