Skip to content

Token overflow when exploring large databases

When trying to explore a database with many tables, or search for references to a SQL object, Claude would fail with:

Could not fully generate Claude’s response

FieldValue
Date2026-03-03
SeverityHigh (blocks exploration of large databases)
Status✅ Resolved

Three combined problems:

  1. executeSecureQuery had no row limit — it returned all results without a cap, generating JSON blobs of hundreds of KB that exceeded Claude’s context window.
  2. list_tables had no filter — on databases with more than 200 tables/views the result was massive.
  3. No direct object search tool — finding “which procedures reference X” required listing all objects and inspecting them one by one (extremely expensive in tokens).

All queries are now capped at 500 rows. If the result is truncated, the last element includes a _truncated warning so Claude knows to narrow the query with WHERE or TOP.

Data can now be filtered before fetching:

list_tables filter="Order" → only tables/views containing "Order"
list_tables filter="Truck" → only tables/views containing "Truck"

Direct search in two modes:

ModeUsageReturns
By name (default)search_objects pattern="OrderTruck"Tables, views, procs and functions whose name matches
By definitionsearch_objects pattern="OrderTruck" search_in="definition"Procs, functions and views that reference that text in their source code

All connectors expose exactly the same functions:

FunctionParameters
query_databasequery: string
get_database_info
exploretype?: string, filter?: string, schema?: string, pattern?: string, search_in?: string
inspecttable_name: string, schema?: string, detail?: string
execute_procedureprocedure_name: string, parameters?: string

To find references to PedidoCamioCarregaCamioAdmin with states 26/27:

-- 1. Search the object by name
search_objects pattern="PedidoCamioCarregaCamioAdmin"
-- 2. Find which procs/views reference it in their code
search_objects pattern="PedidoCamioCarregaCamioAdmin" search_in="definition"
-- 3. Direct query filtering by state
query_database query="SELECT * FROM PedidoCamioCarregaCamio WHERE Estado IN (26,27)"