qlty_columnSummary
Generate column summary statistics for a specified table in a Teradata database. Input database and table names to receive formatted results with metadata for analysis.
Instructions
Get the column summary statistics for a table.
Arguments: database_name - name of the database table_name - table name to analyze
Returns: ResponseType: formatted response with query results + metadata
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database_name | Yes | ||
| table_name | Yes |
Implementation Reference
- The core handler function that executes a TD_ColumnSummary query on the specified table (optionally qualified by database), converts results to JSON, adds metadata, and returns a formatted response using create_response.def handle_qlty_columnSummary(conn: TeradataConnection, database_name: str | None, table_name: str, *args, **kwargs): """ Get the column summary statistics for a table. Arguments: database_name - name of the database table_name - table name to analyze Returns: ResponseType: formatted response with query results + metadata """ logger.debug(f"Tool: handle_qlty_columnSummary: Args: table_name: {database_name}.{table_name}") if database_name is not None: table_name = f"{database_name}.{table_name}" with conn.cursor() as cur: rows = cur.execute(f"select * from TD_ColumnSummary ( on {table_name} as InputTable using TargetColumns ('[:]')) as dt") data = rows_to_json(cur.description, rows.fetchall()) metadata = { "tool_name": "qlty_columnSummary", "database_name": database_name, "table_name": table_name, "rows": len(data) } logger.debug(f"Tool: handle_qlty_columnSummary: Metadata: {metadata}") return create_response(data, metadata)
- Dynamic schema generation for the tool input parameters by inspecting the handler function signature, removing internal parameters (e.g., 'conn'), and creating a new signature for MCP tool registration.def make_tool_wrapper(func): """Create an MCP-facing wrapper for a handle_* function. - Removes internal parameters (conn, tool_name, fs_config) from the MCP signature while still injecting them into the underlying handler. - Preserves the handler's parameter names and types so MCP clients can render friendly forms. """ sig = inspect.signature(func) inject_kwargs = {} removable = {"conn", "tool_name"} if "fs_config" in sig.parameters: inject_kwargs["fs_config"] = fs_config removable.add("fs_config") params = [ p for name, p in sig.parameters.items() if name not in removable and p.kind in (inspect.Parameter.POSITIONAL_OR_KEYWORD, inspect.Parameter.KEYWORD_ONLY) ] new_sig = sig.replace(parameters=params) # Create executor function that will be run in thread def executor(**kwargs): return execute_db_tool(func, **kwargs) return create_mcp_tool( executor_func=executor, signature=new_sig, inject_kwargs=inject_kwargs, validate_required=False, tool_name=getattr(func, "__name__", "wrapped_tool"), tool_description=func.__doc__, )
- src/teradata_mcp_server/app.py:343-363 (registration)Dynamic registration of all 'handle_*' functions as MCP tools. For 'handle_qlty_columnSummary', it derives the tool name 'qlty_columnSummary', wraps the handler, and registers it with FastMCP if matching the profile configuration.# 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 wrapped = make_tool_wrapper(func) mcp.tool(name=tool_name, description=wrapped.__doc__)(wrapped) logger.info(f"Created tool: {tool_name}")