Overview
List all tables and views in a database with their schema, type, and comments. If the database parameter is not specified, the tool uses the current database. This tool helps discover available data structures before querying. Tables and views are queried using DuckDB’s system functions (duckdb_tables() and duckdb_views()) and returned in a structured format with metadata.
Parameters
Database name to list tables from. If not specified, defaults to the current database obtained via
current_database().Optional schema name to filter results. If not specified, tables and views from all schemas are returned.
Response
Indicates whether the operation completed successfully.
The database that was queried.
The schema filter applied. Returns “all” if no schema was specified.
Array of table and view objects. Each object contains:
schema(string): Schema name containing the table/viewname(string): Table or view nametype(string): Either “table” or “view”comment(string | null): User-defined comment, or null if not set
Number of tables in the results.
Number of views in the results.
Error message when success is false.
Type of error that occurred.
Examples
List Tables in Current Database
Request:List Tables in Specific Database
Request:List Tables in Specific Schema
Request:MotherDuck Database
Request:Empty Database
Request:Error Response
Request:Default Behavior
Current Database: When no
database parameter is provided, the tool automatically uses current_database() to determine which database to query. This is typically “main” for local DuckDB files, or your default MotherDuck database.All Schemas: When no
schema parameter is provided, tables and views from all schemas are returned. Most databases use the “main” schema by default, but you may see tables in other schemas like “information_schema”, “pg_catalog”, or custom schemas.Tool Annotations
This tool is always read-only with
readOnlyHint: true and destructiveHint: false, regardless of server mode.Related Tools
- Use list_databases to discover available databases first
- Use list_columns to see the structure of a specific table
- Use execute_query to query data from discovered tables