search_objects tool provides a unified interface for searching and listing database objects (schemas, tables, columns, procedures, functions, indexes) with progressive disclosure to optimize token usage.
Progressive Disclosure Design
The tool uses adetail_level parameter to control how much information is returned:
names- Returns only object names (minimal tokens) - ideal for initial discoverysummary- Includes names plus metadata (row counts, column counts, etc.)full- Returns complete structure details including columns, indexes, parameters, etc.
Parameters
Type of database object to search for.Options:
schema- Database schemas/namespacestable- Tables and viewscolumn- Table columnsprocedure- Stored proceduresfunction- User-defined functionsindex- Table indexes
SQL LIKE pattern for matching object names. Uses standard SQL wildcards:
%- Matches any sequence of characters_- Matches exactly one character
"%user%"- Contains “user” anywhere"user_%"- Starts with “user_”"%_id"- Ends with “_id”"%"- Matches everything (default, for listing all objects)
Filter results to a specific schema. Required when using
table parameter.Example: "public" or "dbo"Filter results to a specific table. Only valid for
object_type="column" or object_type="index". Requires schema parameter.Example: "users"Controls the amount of detail returned.Options:
names- Minimal: just object names (most token-efficient)summary- Metadata: names + row counts, column counts, etc.full- Complete: full structure including columns, indexes, parameters
Maximum number of results to return. Range: 1-1000.
Optional database identifier for multi-database configurations.
Response Format
The type of objects returned (echoes the request parameter).
The pattern used for matching (echoes the request parameter).
The schema filter applied (if any).
The table filter applied (if any).
The detail level returned (echoes the request parameter).
Number of results returned.
Array of matching objects. Structure varies by
object_type and detail_level.True if results were limited by the
limit parameter (more results exist).Examples by Object Type
List All Schemas
Request:Search for Tables Containing “user”
Request:Get Full Schema for a Specific Table
Request:Search for Columns Named “email”
Request:List All Columns in a Specific Table
Request:Find Stored Procedures Starting with “get_”
Request:List All Indexes for a Table
Request:Error Handling
SCHEMA_REQUIRED
Occurs whentable parameter is provided without schema:
INVALID_TABLE_FILTER
Occurs whentable parameter is used with incompatible object_type:
SCHEMA_NOT_FOUND
Occurs when specified schema doesn’t exist:SEARCH_ERROR
Occurs when the search operation fails:Token Efficiency Strategy
The tool is designed to minimize token usage through progressive disclosure:- Start with
names- Get a quick overview with minimal tokens - Refine with
summary- Add metadata when you need context - Drill down with
full- Get complete details only when necessary
Example Workflow
Implementation Details
- Source:
src/tools/search-objects.ts - Pattern matching: Converts SQL LIKE patterns to JavaScript regex
- Row counts: Uses database statistics (e.g.,
pg_class.reltuples) when available - Performance: Skips inaccessible schemas/tables gracefully
- Database support: PostgreSQL, MySQL, MariaDB, SQL Server, SQLite
Best Practices
- Use
namesdetail level for initial discovery to minimize tokens - Specify schema filters when possible to reduce search scope
- Use specific patterns instead of
%to limit results - Set appropriate limits based on expected result sizes
- Progress from names → summary → full as you narrow your focus
- Use table filters for column/index searches to improve performance