Skip to main content

Server-Side Data Analysis

query_cache is one of the most powerful features of the MCP Server — it allows you to analyze data without consuming context window tokens.

The Problem

When you search for 50 LinkedIn profiles, all 50 results are returned into the LLM’s context. Filtering, sorting, or aggregating requires the LLM to process all data in-context — expensive and limited by context size.

The Solution: ClickHouse-Backed Cache

Every execute() call stores results in a ClickHouse cache (TTL: 7 days). The query_cache tool lets you query this cache server-side — only the filtered/aggregated results are returned to context.

Filtering

Use conditions to filter cached results by any field:
Multiple conditions are combined with AND logic.

Supported Filter Operators


Aggregation

Calculate summary statistics without loading individual records:

Supported Aggregation Functions


Group By

Combine aggregation with grouping to get breakdowns:
Result:

Sorting

Sort cached results by any field:
Returns only the top 10 results — the rest stay in cache, not in context.

Combined Example

A full workflow combining all features:
Key benefit: Step 1 makes a single API call to collect data. Steps 2-5 are cache operations at zero additional API cost — they don’t load all 200 profiles into context. Only the filtered/aggregated results are returned to the LLM.

Export Data

Download full cached datasets as files:
export_data always exports the full dataset stored under the cache_key, regardless of any filters applied via query_cache. Filters only affect what is returned to context — they do not modify the cached data.

Supported Formats

Returns a download URL. Data stays cached for 7 days.

Best Practices

Use Large Counts

Fetch more data with execute() (count: 100-200), then filter with query_cache. Cheaper than multiple small requests.

Filter Before Reading

Always use query_cache to narrow results before loading them into context. Saves tokens and improves response quality.

Aggregate Server-Side

Use aggregation functions instead of asking the LLM to calculate averages, counts, or sums from raw data.

Export for External Use

Use export_data when you need the full dataset outside of the AI conversation (spreadsheets, databases, reports).