steampipe_table_list
List all Steampipe tables with optional schema and filter parameters to refine results. Ideal for efficiently managing and querying table data across schemas.
Instructions
List all available Steampipe tables. Use schema and filter parameters to narrow down results.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filter | No | Optional filter pattern to match against table names. Use ILIKE syntax, including % as a wildcard. | |
| schema | No | Optional schema name to filter tables by. If not provided, lists tables from all schemas. |
Implementation Reference
- src/tools/steampipe_table_list.ts:22-96 (handler)The main handler function that queries the database to list available Steampipe tables, optionally filtered by schema and table name pattern using ILIKE.handler: async (db: DatabaseService, args?: { schema?: string; filter?: string }) => { if (!db) { return { content: [{ type: "text", text: "Database not available. Please ensure Steampipe is running and try again." }], isError: true }; } try { // Check if schema exists if specified if (args?.schema) { const schemaQuery = ` SELECT schema_name FROM information_schema.schemata WHERE schema_name = $1 `; const schemaResult = await db.executeQuery(schemaQuery, [args.schema]); if (schemaResult.length === 0) { return { content: [{ type: "text", text: `Schema '${args.schema}' not found` }], isError: true }; } } // Build the query based on provided arguments let query = ` SELECT DISTINCT table_schema as schema, table_name as name, obj_description(format('%I.%I', table_schema, table_name)::regclass::oid, 'pg_class') as description FROM information_schema.tables WHERE table_schema NOT IN ('information_schema', 'pg_catalog') `; const params: any[] = []; let paramIndex = 1; if (args?.schema) { query += ` AND table_schema = $${paramIndex}`; params.push(args.schema); paramIndex++; } if (args?.filter) { query += ` AND table_name ILIKE $${paramIndex}`; params.push(args.filter); // Use the filter pattern as-is since it already includes wildcards } query += " ORDER BY table_schema, table_name"; const result = await db.executeQuery(query, params); return { content: [{ type: "text", text: JSON.stringify({ tables: result }) }] }; } catch (err) { logger.error("Error listing tables:", err); return { content: [{ type: "text", text: `Failed to list tables: ${err instanceof Error ? err.message : String(err)}` }], isError: true }; } }
- Input schema defining optional 'schema' and 'filter' parameters for the tool.inputSchema: { type: "object", additionalProperties: false, properties: { schema: { type: "string", description: "Optional schema name to filter tables by. If not provided, lists tables from all schemas." }, filter: { type: "string", description: "Optional filter pattern to match against table names. Use ILIKE syntax, including % as a wildcard." } } },
- src/tools/index.ts:24-30 (registration)Registers the steampipe_table_list tool (imported as tableListTool) in the central tools map used for server request handling.export const tools = { steampipe_query: queryTool as DbTool, steampipe_table_list: tableListTool as DbTool, steampipe_table_show: tableShowTool as DbTool, steampipe_plugin_list: pluginListTool as DbTool, steampipe_plugin_show: pluginShowTool as DbTool, } as const;