Skip to main content
Glama
blitzstermayank

Teradata MCP Server

dba_tableSqlList

Retrieve SQL queries executed against a specific Teradata table within a defined time period to monitor usage and analyze database activity.

Instructions

Get a list of SQL run against a table in the last number of days.

Arguments: table_name - table name no_days - number of days

Returns: ResponseType: formatted response with query results + metadata

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_nameYes
no_daysNo

Implementation Reference

  • The core handler function that implements the dba_tableSqlList tool. It queries the Teradata DBC.QryLogSqlV view to retrieve SQL statements referencing the specified table in the recent period, formats the results as JSON, and returns a standardized response with metadata.
    def handle_dba_tableSqlList(conn: TeradataConnection, table_name: str, no_days: int | None = 7,  *args, **kwargs):
        """
        Get a list of SQL run against a table in the last number of days.
    
        Arguments:
          table_name - table name
          no_days - number of days
    
        Returns:
          ResponseType: formatted response with query results + metadata
        """
        logger.debug(f"Tool: handle_dba_tableSqlList: Args: table_name: {table_name}, no_days: {no_days}")
    
        with conn.cursor() as cur:
            if table_name == "":
                logger.debug("No table name provided")
            else:
                logger.debug(f"Table name provided: {table_name}, returning SQL queries for this table.")
                rows = cur.execute(f"""SELECT t1.QueryID, t1.ProcID, t1.CollectTimeStamp, t1.SqlTextInfo, t2.UserName
                FROM DBC.QryLogSqlV t1
                JOIN DBC.QryLogV t2
                ON t1.QueryID = t2.QueryID
                WHERE t1.CollectTimeStamp >= CURRENT_TIMESTAMP - INTERVAL '{no_days}' DAY
                AND t1.SqlTextInfo LIKE '%{table_name}%'
                ORDER BY t1.CollectTimeStamp DESC;""")
    
            data = rows_to_json(cur.description, rows.fetchall())
            metadata = {
                "tool_name": "dba_tableSqlList",
                "table_name": table_name,
                "no_days": no_days,
                "total_queries": len(data)
            }
            logger.debug(f"Tool: handle_dba_tableSqlList: metadata: {metadata}")
            return create_response(data, metadata)
  • Dynamic registration of all handle_* functions as MCP tools. The function handle_dba_tableSqlList is automatically registered as the tool 'dba_tableSqlList' if its module is loaded and the tool name matches the active profile configuration.
    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
            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/blitzstermayank/MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server