Skip to main content
Glama

describe_table

Retrieve column details and schema information for a specified table in a database, supporting Snowflake databases via the DataPilot MCP Server.

Instructions

Get detailed information about a table's columns

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseNo
schemaNo
table_nameYes

Implementation Reference

  • The MCP tool handler for 'describe_table', decorated with @mcp.tool(). It fetches the column information using the SnowflakeClient and formats it for JSON response.
    @mcp.tool() async def describe_table(table_name: str, database: Optional[str] = None, schema: Optional[str] = None, ctx: Context = None) -> List[Dict[str, Any]]: """Get detailed information about a table's columns""" await ctx.info(f"Describing table: {table_name}") try: client = await get_snowflake_client() columns = await client.describe_table(table_name, database, schema) # Convert to dict for JSON serialization result = [] for col in columns: result.append({ "column_name": col.column_name, "data_type": col.data_type, "is_nullable": col.is_nullable, "default_value": col.default_value, "comment": col.comment }) await ctx.info(f"Table {table_name} has {len(result)} columns") return result except Exception as e: logger.error(f"Error describing table: {str(e)}") await ctx.error(f"Failed to describe table: {str(e)}") return []
  • Core implementation of describe_table in SnowflakeClient class. Executes 'DESCRIBE TABLE' SQL query and parses results into ColumnInfo objects.
    async def describe_table(self, table_name: str, database: Optional[str] = None, schema: Optional[str] = None) -> List[ColumnInfo]: """Get detailed information about a table's columns""" full_table_name = table_name if database and schema: full_table_name = f"{database}.{schema}.{table_name}" elif schema: full_table_name = f"{schema}.{table_name}" result = await self.execute_query(f"DESCRIBE TABLE {full_table_name}") columns = [] for row in result.data: if result.success: columns.append(ColumnInfo( column_name=row.get('name', ''), data_type=row.get('type', ''), is_nullable=row.get('null?', 'Y') == 'Y', default_value=row.get('default'), comment=row.get('comment') )) return columns
  • Pydantic model defining the structure of column information used in the describe_table tool output.
    class ColumnInfo(BaseModel): """Information about a table column""" column_name: str data_type: str is_nullable: bool default_value: Optional[str] = None comment: Optional[str] = None

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/rickyb30/datapilot-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server