feat: add table filter to search_objects tool (#172)#177
Conversation
Add optional table parameter to search_objects tool for filtering columns and indexes by specific table name. This addresses performance issues when searching in large databases with thousands of columns. Changes: - Add table parameter (exact match, requires schema) - Optimize searchColumns() to only query specified table - Optimize searchIndexes() to only query specified table - Add validation: table requires schema parameter - Add validation: table only applies to column/index object types - Clarify that schema parameter is exact match (not pattern) - Add comprehensive test coverage Closes #172 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR adds a table filter parameter to the search_objects tool to optimize performance when searching for columns and indexes in large databases. The feature allows users to specify a table name to narrow their search, avoiding the need to query all tables in a schema when looking for specific column or index information.
Key changes:
- Adds optional
tableparameter with exact match semantics, requiringschemato be specified - Optimizes
searchColumns()andsearchIndexes()to query only the specified table when table filter is provided - Adds validation to ensure table parameter only applies to column and index object types
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/tools/search-objects.ts | Adds table parameter to schema, updates searchColumns and searchIndexes functions to support table filtering, and implements validation logic |
| src/tools/tests/search-objects.test.ts | Adds comprehensive test coverage for table filtering functionality including validation tests for different object types |
| // Validate table parameter | ||
| if (table) { | ||
| if (!schema) { | ||
| return createToolErrorResponse( | ||
| "The 'table' parameter requires 'schema' to be specified", | ||
| "SCHEMA_REQUIRED" | ||
| ); | ||
| } | ||
| if (!["column", "index"].includes(object_type)) { | ||
| return createToolErrorResponse( | ||
| `The 'table' parameter only applies to object_type 'column' or 'index', not '${object_type}'`, | ||
| "INVALID_TABLE_FILTER" | ||
| ); | ||
| } | ||
| } |
There was a problem hiding this comment.
When a table filter is provided, there's no validation that the table actually exists in the specified schema. This could lead to silent failures where users get zero results without any indication that the table name is incorrect. Consider adding validation using the connector's tableExists method (similar to the schema validation at lines 496-504), which would provide helpful feedback if the table doesn't exist. This would improve the user experience by catching typos or incorrect table names early.
Add optional table parameter to search_objects tool for filtering columns and indexes by specific table name. This addresses performance issues when searching in large databases with thousands of columns.
Changes:
Closes #172
🤖 Generated with Claude Code