base_tableList
Lists all tables in a specified Teradata database to help users discover available data structures and plan queries.
Instructions
Lists all tables in a database.
Arguments: database_name - Database name
Returns: ResponseType: formatted response with query results + metadata
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database_name | No |
Implementation Reference
- The handler function that executes the base_tableList tool. It queries dbc.TablesV for tables (T,V,O,Q kinds), optionally filtered by database_name, formats results with metadata.def handle_base_tableList(conn: TeradataConnection, database_name: str | None = None, *args, **kwargs): """ Lists all tables in a database. Arguments: database_name - Database name Returns: ResponseType: formatted response with query results + metadata """ logger.debug(f"Tool: handle_base_tableList: Args: database_name: {database_name}") sql = "select TableName from dbc.TablesV tv where tv.TableKind in ('T','V', 'O', 'Q')" params = [] if database_name: sql += " and UPPER(tv.DatabaseName) = UPPER(?)" params.append(database_name) with conn.cursor() as cur: rows = cur.execute(sql, params) data = rows_to_json(cur.description, rows.fetchall()) metadata = { "tool_name": "base_tableList", "sql": sql.replace("?", f"'{database_name}'"), "columns": [ {"name": col[0], "type": col[1].__name__ if hasattr(col[1], '__name__') else str(col[1])} for col in cur.description ] if cur.description else [], "row_count": len(data) } logger.debug(f"Tool: handle_base_tableList: metadata: {metadata}") return create_response(data, metadata)
- src/teradata_mcp_server/app.py:273-281 (registration)Dynamic registration loop that discovers handle_* functions from loaded modules, extracts tool_name by stripping 'handle_', wraps the function, and registers it as an MCP tool if matching profile config.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}")