Skip to main content
Glama
blitzstermayank

Teradata MCP Server

dba_userSqlList

Retrieve SQL queries executed by specific users or all users within a defined timeframe to monitor database activity and audit query history.

Instructions

Get a list of SQL run by a user in the last number of days if a user name is provided, otherwise get list of all SQL in the last number of days.

Arguments: user_name - user name no_days - number of days

Returns: ResponseType: formatted response with query results + metadata

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
user_nameYes
no_daysNo

Implementation Reference

  • Handler function executing the dba_userSqlList tool: retrieves SQL queries run by a specific user (or all if none specified) in the last N days from Teradata's DBC.QryLog views.
    def handle_dba_userSqlList(conn: TeradataConnection, user_name: str, no_days: int | None = 7,  *args, **kwargs):
        """
        Get a list of SQL run by a user in the last number of days if a user name is provided, otherwise get list of all SQL in the last number of days.
    
        Arguments:
          user_name - user name
          no_days - number of days
    
        Returns:
          ResponseType: formatted response with query results + metadata
        """
        logger.debug(f"Tool: handle_dba_userSqlList: Args: user_name: {user_name}")
    
        with conn.cursor() as cur:
            if user_name == "":
                logger.debug("No user name provided, returning all SQL queries.")
                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
                ORDER BY t1.CollectTimeStamp DESC;""")
            else:
                logger.debug(f"User name provided: {user_name}, returning SQL queries for this user.")
                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 t2.UserName = '{user_name}'
                ORDER BY t1.CollectTimeStamp DESC;""")
            data = rows_to_json(cur.description, rows.fetchall())
            metadata = {
                "tool_name": "dba_userSqlList",
                "user_name": user_name,
                "no_days": no_days,
                "total_queries": len(data)
            }
            logger.debug(f"Tool: handle_dba_userSqlList: metadata: {metadata}")
            return create_response(data, metadata)
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 of behavioral disclosure. It mentions the tool retrieves SQL lists based on user and time filters, but lacks details on permissions required, rate limits, pagination, error handling, or what 'formatted response with query results + metadata' entails. For a tool with no annotation coverage, this is a significant gap in transparency.

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 appropriately sized and front-loaded: the first sentence clearly states the purpose, followed by bullet points for arguments and returns. There is minimal waste, though the bullet points could be integrated more seamlessly. Overall, it is efficient and structured for quick comprehension.

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

Completeness2/5

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

Given the tool's complexity (filtering SQL by user/time), lack of annotations, and no output schema, the description is incomplete. It does not explain the return format beyond 'formatted response with query results + metadata', nor does it cover behavioral aspects like authentication needs or limitations. For a tool with 2 parameters and no structured support, more context is needed to ensure proper usage.

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 adds meaning by explaining that 'user_name' filters results by user (or if omitted, returns all SQL) and 'no_days' specifies the time window. However, it does not detail data types, constraints (e.g., valid ranges for 'no_days'), or default behavior beyond the schema's default of 7 days. This provides basic semantics but leaves gaps in parameter understanding.

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 a list of SQL run by a user in the last number of days if a user name is provided, otherwise get list of all SQL in the last number of days.' This specifies the verb ('Get a list'), resource ('SQL'), and scope ('by a user' or 'all'). However, it does not explicitly differentiate from sibling tools like 'dba_tableSqlList' or 'sql_Retrieve_Cluster_Queries', which may have overlapping functionality, so it falls short of a perfect score.

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 context by explaining the conditional logic: use with a user_name to filter by user, or without to get all SQL. However, it does not provide explicit guidance on when to choose this tool over alternatives like 'dba_tableSqlList' or 'sql_Retrieve_Cluster_Queries', nor does it mention prerequisites or exclusions. This leaves room for ambiguity in tool selection among siblings.

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/blitzstermayank/MCP'

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