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():
| Mode | Trigger Condition | Output Format Returned to LLM |
|---|---|---|
smart | Query results $\le$ 15 rows. | Returns the full raw dataset in clean markdown. |
smart | Query results > 15 rows. | Returns 10 sample rows + column profile statistics + workspace CSV link. |
analytics | All queries. | Returns zero raw database rows. Transmits column schemas and count statistics only. |
raw | All 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.csvThe 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.
| id | created_at | status | |
|---|---|---|---|
| 1 | alice@acme.com | 2022-03-14 | active |
| 2 | bob@corp.io | 2022-05-01 | active |
| 3 | carol@dev.net | 2022-07-22 | pending |
| 4 | dan@startup.co | 2022-09-09 | active |
| 5 | eve@labs.ai | 2023-01-15 | inactive |
| 6 | frank@mail.com | 2023-03-28 | active |
| 7 | grace@apps.io | 2023-06-11 | pending |
| 8 | hal@tech.dev | 2023-08-04 | active |
| 9 | iris@data.co | 2023-11-19 | active |
| 10 | jack@cloud.net | 2024-02-07 | inactive |
