show_catalog_tree
Display hierarchical tree views of Trino catalogs, schemas, and tables to visualize and navigate database structures.
Instructions
Show a hierarchical tree view of catalogs, schemas, and tables
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/trino_client.py:325-349 (handler)The actual implementation of show_catalog_tree that builds a hierarchical tree view of all catalogs, schemas, and tables by executing SHOW CATALOGS, SHOW SCHEMAS, and SHOW TABLES queries and formatting them with indentation.
def show_catalog_tree(self) -> str: """Show a hierarchical tree view of all catalogs, schemas, and tables. Returns: A formatted string showing the catalog > schema > table hierarchy. """ tree = [] catalogs = [row["Catalog"] for row in json.loads(self.execute_query("SHOW CATALOGS"))] for catalog in sorted(catalogs): tree.append(f"{catalog}") try: schemas = [row["Schema"] for row in json.loads(self.execute_query(f"SHOW SCHEMAS FROM {catalog}"))] for schema in sorted(schemas): tree.append(f"{schema}") try: tables = [ row["Table"] for row in json.loads(self.execute_query(f"SHOW TABLES FROM {catalog}.{schema}")) ] tree.extend(f" {table}" for table in sorted(tables)) except (trino.dbapi.TrinoQueryError, KeyError): tree.append(" Unable to list tables") except (trino.dbapi.TrinoQueryError, KeyError): tree.append("Unable to list schemas") return "\n".join(tree) if tree else "No catalogs found" - src/server.py:237-244 (registration)MCP tool registration using @mcp.tool() decorator with description. This registers the show_catalog_tree tool with the MCP server.
@mcp.tool(description="Show a hierarchical tree view of catalogs, schemas, and tables") def show_catalog_tree() -> str: """Get a hierarchical tree view showing the full structure of catalogs, schemas, and tables. Returns: str: A formatted string showing the catalog > schema > table hierarchy with visual indicators """ return client.show_catalog_tree() - src/server.py:238-244 (helper)Wrapper function that acts as the MCP tool handler, receiving the tool call and delegating to the TrinoClient's show_catalog_tree method.
def show_catalog_tree() -> str: """Get a hierarchical tree view showing the full structure of catalogs, schemas, and tables. Returns: str: A formatted string showing the catalog > schema > table hierarchy with visual indicators """ return client.show_catalog_tree()