Smart Compression

AI models do not need to parse thousands of raw database rows to answer structural questions. Doing so dilutes their context window and increases API billing. Bollard optimizes LLM token usage by compressing large query results under Smart Mode.

The Math: Why Compression Matters

In traditional database MCP gateways, running a query that returns 1,000 rows dumps the raw text directly into the LLM context:

  • Traditional Gateway: 1,000 rows $\times$ 5 columns $\times$ 8 tokens per cell = 40,000 tokens consumed.
  • Bollard Smart Mode: 10 sample rows + column aggregation metrics = ~1,200 tokens consumed.

This represents a 97% reduction in context window footprint. This optimization reduces query latency, mitigates model hallucinations, and cuts API inference costs.

Output Modes

You can configure the formatting profile globally per connection, or override it dynamically for a single query using the output_mode parameter in execute_query():

ModeTrigger ConditionOutput Format Returned to LLM
smartQuery results $\le$ 15 rows.Returns the full raw dataset in clean markdown.
smartQuery results > 15 rows.Returns 10 sample rows + column profile statistics + workspace CSV link.
analyticsAll queries.Returns zero raw database rows. Transmits column schemas and count statistics only.
rawAll queries.Disables compression. Returns all database rows in raw markdown text.

Automatic CSV Export

When a query is compressed under smart mode, the full dataset remains accessible to the developer. Bollard writes the complete results to a local file in your workspace:

-- File generated in workspace root:
query_result.csv

The server appends a clickable file-scheme link directly to the response returned to the editor:

*(Written to [query_result.csv](file:///c:/users/deepak/desktop/bollard-mcp/query_result.csv). The AI receives only this summary.)*

You can click this link inside your editor to immediately open the full dataset in a separate tab, keeping your chat interface clean and your LLM context thin.

Query ResultSMART MODE
1,247 rows returned — showing 10-row preview
idemailcreated_atstatus
1alice@acme.com2022-03-14active
2bob@corp.io2022-05-01active
3carol@dev.net2022-07-22pending
4dan@startup.co2022-09-09active
5eve@labs.ai2023-01-15inactive
6frank@mail.com2023-03-28active
7grace@apps.io2023-06-11pending
8hal@tech.dev2023-08-04active
9iris@data.co2023-11-19active
10jack@cloud.net2024-02-07inactive
• • • • •
id: integer, range 1–1247 | email: string, 1247 unique | created_at: timestamp, 2022-03 – 2024-06 | status: categorical, 4 distinct values
query_result_20240618.csv (full dataset, 1247 rows)