show_create_view
Retrieve the CREATE VIEW statement for a specific Trino view by providing catalog, schema, and view name parameters.
Instructions
Show the CREATE VIEW statement for a specific view
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| catalog | Yes | catalog name | |
| schema_name | Yes | schema name | |
| view | Yes | The name of the view |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/trino_client.py:194-219 (handler)The core implementation of show_create_view that executes the SQL query against Trino. It validates catalog/schema, constructs the SHOW CREATE VIEW query, executes it, and extracts the result.
def show_create_view( self, catalog: str, schema: str, view: str, ) -> str: """Show the CREATE VIEW statement for a view. Args: catalog (str): The catalog name. If None, uses configured default. schema (str): The schema name. If None, uses configured default. view (str): The name of the view. Returns: str: The CREATE VIEW statement for the specified view. Raises: CatalogSchemaError: If either catalog or schema is not specified and not configured. """ catalog = catalog or self.config.catalog schema = schema or self.config.schema if not catalog or not schema: raise CatalogSchemaError query = f"SHOW CREATE VIEW {catalog}.{schema}.{view}" result = json.loads(self.execute_query(query)) return result[0]["Create View"] if result else "" - src/server.py:109-125 (registration)MCP tool registration using @mcp.tool() decorator. Wraps the client.show_create_view() call and defines the tool interface with Pydantic Field descriptions for parameters.
@mcp.tool(description="Show the CREATE VIEW statement for a specific view") def show_create_view( catalog: str = Field(description="catalog name "), schema_name: str = Field(description="schema name "), view: str = Field(description="The name of the view"), ) -> str: """Show the CREATE VIEW statement for a view. Args: catalog: catalog name schema_name: schema name view: The name of the view Returns: str: The CREATE VIEW statement """ return client.show_create_view(catalog, schema_name, view)