describe_table
Retrieve table structure details including columns, data types, and constraints to understand database schema organization and relationships.
Instructions
Get detailed information about a table including columns, data types, and constraints
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| owner | No | Schema owner (optional) | |
| table_name | Yes | Name of the table to describe |
Implementation Reference
- src/oracle_mcp_server/server.py:781-798 (handler)Handler for describe_table tool: extracts arguments, calls DatabaseInspector.get_table_columns, formats and returns JSON result.elif name == "describe_table": table_name = arguments.get("table_name") owner = arguments.get("owner") columns = await self.inspector.get_table_columns(table_name, owner) result = { "table_name": table_name, "owner": owner, "columns": columns, "column_count": len(columns), } return [ TextContent( type="text", text=json.dumps(result, indent=2, default=str) ) ]
- src/oracle_mcp_server/server.py:648-666 (registration)Registration of describe_table tool in list_tools handler, including name, description, and input schema.Tool( name="describe_table", description="Get detailed information about a table including columns, data types, and constraints", inputSchema={ "type": "object", "properties": { "table_name": { "type": "string", "description": "Name of the table to describe", }, "owner": { "type": "string", "description": "Schema owner (optional)", "default": None, }, }, "required": ["table_name"], }, ),
- Core helper method DatabaseInspector.get_table_columns that queries Oracle's all_tab_columns and all_col_comments to retrieve detailed column information, applies whitelists, and returns structured data.async def get_table_columns( self, table_name: str, owner: Optional[str] = None ) -> List[Dict[str, Any]]: """Get detailed column information for a table""" conn = await self.connection_manager.get_connection() try: cursor = conn.cursor() query = """ SELECT c.column_name, c.data_type, c.data_length, c.data_precision, c.data_scale, c.nullable, c.data_default, cc.comments as column_comment, c.column_id FROM all_tab_columns c LEFT JOIN all_col_comments cc ON c.owner = cc.owner AND c.table_name = cc.table_name AND c.column_name = cc.column_name WHERE c.table_name = :table_name """ params = [table_name] if owner: query += " AND c.owner = :owner" params.append(owner) query += " ORDER BY c.column_id" cursor.execute(query, params) columns = [] for row in cursor: # Apply column whitelist if configured full_column_name = f"{table_name}.{row[0]}" if COLUMN_WHITE_LIST and COLUMN_WHITE_LIST != [""]: if full_column_name not in COLUMN_WHITE_LIST: continue columns.append( { "column_name": row[0], "data_type": row[1], "data_length": row[2], "data_precision": row[3], "data_scale": row[4], "nullable": row[5], "data_default": row[6], "column_comment": row[7], "column_id": row[8], } ) return columns finally: conn.close()