list_schemas
Retrieve all available schemas within a specified database, enabling users to manage and analyze database structures effectively through DataPilot MCP Server.
Instructions
List all schemas in a database
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database | Yes |
Implementation Reference
- src/main.py:122-136 (handler)The MCP tool handler for 'list_schemas'. Decorated with @mcp.tool(), it handles the tool execution by acquiring a Snowflake client and delegating to its list_schemas method, with context logging and error handling.@mcp.tool() async def list_schemas(database: str, ctx: Context) -> List[str]: """List all schemas in a database""" await ctx.info(f"Retrieving schemas for database: {database}") try: client = await get_snowflake_client() schemas = await client.list_schemas(database) await ctx.info(f"Found {len(schemas)} schemas in {database}") return schemas except Exception as e: logger.error(f"Error listing schemas: {str(e)}") await ctx.error(f"Failed to list schemas: {str(e)}") return []
- src/snowflake_client.py:130-133 (helper)Core helper method in the SnowflakeClient class that executes the 'SHOW SCHEMAS IN DATABASE' SQL query and extracts schema names from the result.async def list_schemas(self, database: str) -> List[str]: """List all schemas in a database""" result = await self.execute_query(f"SHOW SCHEMAS IN DATABASE {database}") return [row.get('name', '') for row in result.data if result.success]
- src/main.py:122-122 (registration)The @mcp.tool() decorator registers the list_schemas function as an MCP tool.@mcp.tool()
- src/main.py:123-123 (schema)Type hints define the input schema (database: str, ctx: Context) and output schema (List[str]) for the tool.async def list_schemas(database: str, ctx: Context) -> List[str]: