list_hg_tables_in_a_schema
Retrieve a list of all tables, views, and partitioned tables within a specified schema in a Hologres database using the MCP server.
Instructions
List all tables in a specific schema in the current Hologres database, including their types (table, view, foreign table, partitioned table).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| schema | Yes | Schema name to list tables from in Hologres database |
Implementation Reference
- Handler logic for 'list_hg_tables_in_a_schema' tool: validates schema input, constructs SQL query to list tables with types (view, foreign, partitioned), excludes system schemas and child partitions, then executes via handle_call_tool.elif name == "list_hg_tables_in_a_schema": schema = arguments.get("schema") if not schema: raise ValueError("Schema name is required") query = f""" SELECT tab.table_name, CASE WHEN tab.table_type = 'VIEW' THEN ' (view)' WHEN tab.table_type = 'FOREIGN' THEN ' (foreign table)' WHEN p.partrelid IS NOT NULL THEN ' (partitioned table)' ELSE '' END AS table_type_info FROM information_schema.tables AS tab LEFT JOIN pg_class AS cls ON tab.table_name = cls.relname LEFT JOIN pg_namespace AS ns ON tab.table_schema = ns.nspname LEFT JOIN pg_inherits AS inh ON cls.oid = inh.inhrelid LEFT JOIN pg_partitioned_table AS p ON cls.oid = p.partrelid WHERE tab.table_schema NOT IN ('pg_catalog', 'information_schema', 'hologres', 'hologres_statistic', 'hologres_streaming_mv') AND tab.table_schema = '{schema}' AND (inh.inhrelid IS NULL OR NOT EXISTS ( SELECT 1 FROM pg_inherits WHERE inh.inhrelid = pg_inherits.inhrelid )) ORDER BY tab.table_name; """
- src/hologres_mcp_server/server.py:512-527 (registration)Tool registration in list_tools(): defines name, description, and input schema requiring 'schema' parameter.# 新增 list_hg_tables_in_a_schema 工具 Tool( name="list_hg_tables_in_a_schema", description="List all tables in a specific schema in the current Hologres database, including their types (table, view, foreign table, partitioned table).", inputSchema={ "type": "object", "properties": { "schema": { "type": "string", "description": "Schema name to list tables from in Hologres database" } }, "required": ["schema"] } ), # 新增 show_hg_table_ddl 工具
- Input schema definition for the tool: object with required 'schema' string property.inputSchema={ "type": "object", "properties": { "schema": { "type": "string", "description": "Schema name to list tables from in Hologres database" } }, "required": ["schema"] } ),