list_tables
Retrieve tables from a specified schema or all accessible schemas in an Oracle database, filtering by table name patterns using wildcards. Streamlines database introspection for efficient SQL query preparation.
Instructions
List tables from specified schema or all accessible schemas
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pattern | No | Table name pattern (supports % wildcards) | |
| schema | No | Schema name (optional, shows all accessible schemas if not specified) |
Implementation Reference
- src/index.js:345-379 (handler)The handler function for the 'list_tables' tool. Constructs a dynamic SQL query against ALL_TABLES view with optional schema and pattern filters, executes it using executeQuery, and returns the results as JSON-formatted text content.async handleListTables(args) { let query = ` SELECT owner AS schema_name, table_name, num_rows, last_analyzed FROM all_tables WHERE 1=1 `; const params = []; if (args.schema) { query += ` AND owner = :1`; params.push(args.schema.toUpperCase()); } if (args.pattern) { query += ` AND table_name LIKE :${params.length + 1}`; params.push(args.pattern.toUpperCase()); } query += ` ORDER BY owner, table_name`; const result = await this.executeQuery(query, params); return { content: [ { type: 'text', text: JSON.stringify(result.rows, null, 2) } ] }; }
- src/index.js:197-209 (schema)Input schema definition for the list_tables tool, defining optional 'schema' and 'pattern' parameters.inputSchema: { type: 'object', properties: { schema: { type: 'string', description: 'Schema name (optional, shows all accessible schemas if not specified)' }, pattern: { type: 'string', description: 'Table name pattern (supports % wildcards)' } } }
- src/index.js:194-210 (registration)Registration of the list_tables tool in the ListToolsRequestHandler response, including name, description, and input schema.{ name: 'list_tables', description: 'List tables from specified schema or all accessible schemas', inputSchema: { type: 'object', properties: { schema: { type: 'string', description: 'Schema name (optional, shows all accessible schemas if not specified)' }, pattern: { type: 'string', description: 'Table name pattern (supports % wildcards)' } } } },
- src/index.js:285-286 (registration)Dispatch to list_tables handler in the CallToolRequestHandler switch statement.case 'list_tables': return await this.handleListTables(args);