Skip to main content
Glama
Teradata

Teradata MCP Server

Official
by Teradata

dba_tableSpace

Analyze and retrieve table space usage for a specific table or all tables within a specified database in Teradata. Supports efficient database management by providing formatted query results and metadata.

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_nameYes
table_nameYes

Implementation Reference

  • The handler function that implements the core logic of the 'dba_tableSpace' tool. It executes SQL queries against DBC.AllSpaceV to retrieve table space usage (CurrentPerm, PeakPerm, SkewPct) based on optional database_name and/or table_name parameters, formats the results, and returns a structured response.
    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)
  • Dynamic registration of Python handler functions as MCP tools. Functions named 'handle_*' are automatically discovered via module_loader, wrapped with DB connection injection and QueryBand support, and registered with the MCP server under the tool name derived from the function name (e.g., 'handle_dba_tableSpace' -> 'dba_tableSpace'). The input schema is generated from the function signature.
    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 wrapped = make_tool_wrapper(func) mcp.tool(name=tool_name, description=wrapped.__doc__)(wrapped) logger.info(f"Created tool: {tool_name}")

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