# MCP

One hosted Streamable-HTTP server at `https://api.butlrs.ai/mcp` (stateless, JSON responses) serves the eight tools below over the same handlers as REST, metered identically. Clients that want an installable package use the stdio shim: `BUTLRS_API_KEY=btl_… BUTLRS_MCP_URL=https://api.butlrs.ai/mcp butlrs-mcp` (a pure transport adapter, no tool logic).

## Conventions

Every result carries `meta` (request_id, plan_class, list_price_units, charged_units, evaluated_at, snapshot, coverage, next_cursor?). Every data tool needs an API key (POST /v1/keys/free issues one instantly: email + a client_nonce you keep for recovery). Pass `idempotency_key` (any string, ≤128 chars) to make a call replay-safe for 24 h: a repeat with the same key and arguments returns the stored result free; a different request under the same key is refused. Prices are units per call from GET /v1/price; the free plan has daily per-class allowances (429 allowance_exhausted names resets_at). Lists close a page early at 256 KiB: follow `meta.next_cursor` with the SAME arguments. Storefront defaults to `us` (the only deep-crawled storefront).

## Claude Desktop / Cursor

```json
{
  "mcpServers": {
    "butlrs": {
      "command": "butlrs-mcp",
      "env": {
        "BUTLRS_API_KEY": "btl_\u2026",
        "BUTLRS_MCP_URL": "https://api.butlrs.ai/mcp"
      }
    }
  }
}
```

## Tools


### `search_apps`

Find apps by name / bundle-id prefix and attribute filters (category, price band, IAP, rating floors, abandonment state, delisted). Sorted by rating_count (default), rating, last_observed or abandonment_score (crossed apps only). Returns app cards with the current abandonment state. Class `lookup` (1 unit). Keyset pages: a row whose sort key moves between pages may appear twice or not at all.

| argument | required | schema |
|---|---|---|
| `storefront` | no | `string maxLength=8 minLength=2 default=us pattern=^[a-z]{2,8}$` |
| `query` | no | `string maxLength=64 minLength=1` |
| `app_category` | no | `string maxLength=64 minLength=1` |
| `price_band` | no | `free | lt_1 | 1_5 | 5_20 | 20_plus` |
| `has_iap` | no | `boolean` |
| `min_rating` | no | `number minimum=0 maximum=5` |
| `min_rating_count` | no | `integer minimum=0 maximum=2000000000` |
| `abandonment_state` | no | `crossed | below | unknown` |
| `is_delisted` | no | `boolean` |
| `sort` | no | `rating_count | rating | last_observed | abandonment_score` |
| `limit` | no | `integer minimum=1 maximum=100 default=20` |
| `cursor` | no | `string maxLength=4096 minLength=1` |
| `idempotency_key` | no | `string maxLength=128` |


### `get_app`

One app card plus: the crawl tier, the latest weekly abandonment evaluation {state crossed|below|unknown, score, components, evaluated_at, reason} (unknown when older than 14 days), the review-velocity signal (a page-1 new-review ratio in [0,1], NOT reviews per week), and your open fetch_now request if any. Class `lookup` (1 unit). 404 app_not_found when the id is not in the corpus.

| argument | required | schema |
|---|---|---|
| `app_id` | yes | `string maxLength=64 minLength=1 pattern=^[ !#-\[\]-~]+$` |
| `storefront` | no | `string maxLength=8 minLength=2 default=us pattern=^[a-z]{2,8}$` |
| `idempotency_key` | no | `string maxLength=128` |


### `get_change_feed`

Served change events in ULID order for one app_id, one developer_id (its own events plus events of apps CURRENTLY under it), or corpus-wide with event_types required (+ optional app_category, evaluated against current attributes: a view, not a subscription). Each event is `served: ok` with a projected payload, or `served: withheld` with no payload and a withheld_reason. Poll with since_cursor from meta.next_cursor: unfiltered and event_types-filtered feeds never go backward, never miss and never re-serve an event. Class `feed` (2 units); limit ≤ 500.

| argument | required | schema |
|---|---|---|
| `storefront` | no | `string maxLength=8 minLength=2 default=us pattern=^[a-z]{2,8}$` |
| `app_id` | no | `string maxLength=64 minLength=1` |
| `developer_id` | no | `string maxLength=64 minLength=1` |
| `event_types` | no | `array maxItems=20 items=string` |
| `app_category` | no | `string maxLength=64 minLength=1` |
| `since_cursor` | no | `string maxLength=4096 minLength=1` |
| `limit` | no | `integer minimum=1 maximum=500 default=100` |
| `idempotency_key` | no | `string maxLength=128` |


### `get_rank_history`

Observed chart ranks (chart_type + chart_category) or search positions (keyword) for one app over 7d|30d|90d|all: OBSERVED POINTS ONLY, an absent day is an absent observation, never a rank. Pages are pinned to one snapshot (meta.snapshot.iceberg). Class `series` (3 units); limit ≤ 1000; 400 plan_too_large asks for a shorter range.

| argument | required | schema |
|---|---|---|
| `app_id` | yes | `string maxLength=64 minLength=1 pattern=^[ !#-\[\]-~]+$` |
| `storefront` | no | `string maxLength=8 minLength=2 default=us pattern=^[a-z]{2,8}$` |
| `chart` | no | `any` |
| `keyword` | no | `string maxLength=128 minLength=1` |
| `range` | no | `7d | 30d | 90d | all` |
| `limit` | no | `integer minimum=1 maximum=1000 default=200` |
| `cursor` | no | `string maxLength=4096 minLength=1` |
| `idempotency_key` | no | `string maxLength=128` |


### `get_developer`

A developer's name, first/last observed, portfolio stats {app_count, delisted_count, abandoned_count, unknown_count} and a paged portfolio of app cards (portfolio_cursor). Class `lookup` (1 unit).

| argument | required | schema |
|---|---|---|
| `developer_id` | yes | `string maxLength=64 minLength=1 pattern=^[ !#-\[\]-~]+$` |
| `storefront` | no | `string maxLength=8 minLength=2 default=us pattern=^[a-z]{2,8}$` |
| `portfolio_limit` | no | `integer minimum=1 maximum=100 default=20` |
| `portfolio_cursor` | no | `string maxLength=4096 minLength=1` |
| `idempotency_key` | no | `string maxLength=128` |


### `fetch_now`

Ask for a priority re-fetch of one app. Phase 3 runs the channel in dry mode: the request is recorded (receipt {request_id, mode, status accepted, poll_after_s}) and never executed; class `live_dry` (0 units, 20/day). 409 fetch_duplicate names the open request; 429 fetch_quota_exhausted names resets_at. Never send `mode`.

| argument | required | schema |
|---|---|---|
| `app_id` | yes | `string maxLength=64 minLength=1 pattern=^[ !#-\[\]-~]+$` |
| `storefront` | no | `string maxLength=8 minLength=2 default=us pattern=^[a-z]{2,8}$` |
| `idempotency_key` | no | `string maxLength=128` |


### `query_corpus`

Aggregate the corpus with vocabulary v1: one dataset per call (apps, review_velocity, review_observations on Postgres; change_events, chart_observations, serp_observations, rating_trend on DuckDB), metrics[], optional dimensions[] (incl. day|week|month on windowed datasets), filters[{field, op eq|in|gte|lte|between|prefix, value}], sort (prefix - for descending), limit ≤ 1000, time_range {from, to} REQUIRED on windowed datasets and rejected on current-state ones (≤ 400 days). High-cardinality dimensions (developer_id, keyword) need an `in` filter ≤ 50 on the same field. Priced by shape: query.s 5 / query.m 20 / query.l 80 units (DuckDB > 90 days or a high-cardinality dimension). No continuation: `truncated` says to narrow. Rejections name the incompatible pair and the nearest valid alternative. Attribution is current (meta.attribution, meta.snapshot.apps_attr_as_of).
Datasets (engine; time column; metrics; dimensions; filter fields):
- apps (pg; current state, no time_range): metrics count, avg_rating, median_rating_count, sum_rating_count, share_with_iap, share_delisted, share_abandoned, unknown_count, median_days_since_observed; dimensions storefront, app_category, price_band, has_iap, is_delisted, abandonment_state, developer_id; filters storefront, entity_id, app_category, price_band, has_iap, is_delisted, abandonment_state, developer_id, rating_count, rating_average, price_cents, first_seen_at, last_observed_at
- review_velocity (pg; current state, no time_range): metrics apps_with_signal, avg_change_rate, share_change_rate_gte; dimensions storefront, app_category, price_band, has_iap, is_delisted, abandonment_state, developer_id; filters storefront, entity_id, app_category, price_band, has_iap, is_delisted, abandonment_state, developer_id, rating_count, rating_average, price_cents, first_seen_at, last_observed_at
- review_observations (pg; time_range required on day): metrics reviews_observed, avg_rating_observed, share_rating_le_2, share_rating_ge_4, apps_with_observations, apps_with_fold; dimensions storefront, app_category, price_band, has_iap, is_delisted, abandonment_state, developer_id, day, week, month; filters storefront, entity_id, app_category, price_band, has_iap, is_delisted, abandonment_state, developer_id, rating_count, rating_average, price_cents, first_seen_at, last_observed_at
- change_events (duckdb; time_range required on observed_at): metrics event_count, distinct_entities, events_per_entity; dimensions storefront, event_type, detector, entity_type, app_category, price_band, has_iap, is_delisted, abandonment_state, developer_id, day, week, month; filters storefront, entity_id, event_type, detector, entity_type, app_category, price_band, has_iap, is_delisted, abandonment_state, developer_id, rating_count, rating_average, price_cents, first_seen_at, last_observed_at
- chart_observations (duckdb; time_range required on observed_at): metrics observation_count, distinct_entities, best_rank, avg_rank, days_on_chart; dimensions storefront, chart_type, chart_category, rank_band, app_category, price_band, has_iap, is_delisted, abandonment_state, developer_id, day, week, month; filters storefront, entity_id, chart_type, chart_category, rank_band, app_category, price_band, has_iap, is_delisted, abandonment_state, developer_id, rating_count, rating_average, price_cents, first_seen_at, last_observed_at
- serp_observations (duckdb; time_range required on observed_at): metrics observation_count, distinct_entities, best_position, avg_position, days_in_top10; dimensions storefront, keyword, rank_band, app_category, price_band, has_iap, is_delisted, abandonment_state, developer_id, day, week, month; filters storefront, entity_id, keyword, rank_band, app_category, price_band, has_iap, is_delisted, abandonment_state, developer_id, rating_count, rating_average, price_cents, first_seen_at, last_observed_at
- rating_trend (duckdb; time_range required on captured_at): metrics avg_rating, avg_rating_count, delisted_share, apps_in_grid; dimensions storefront, app_category, price_band, has_iap, is_delisted, abandonment_state, developer_id, week; filters storefront, entity_id, app_category, price_band, has_iap, is_delisted, abandonment_state, developer_id, rating_count, rating_average, price_cents, first_seen_at, last_observed_at
Price rules for query_corpus, first match wins:
- {"engine":"duckdb","any_of":[{"days_gt":90},{"high_card":true}]} -> query.l (80 units)
- {"engine":"duckdb"} -> query.m (20 units)
- {"engine":"pg","dataset":"review_observations","days_gt":90} -> query.m (20 units)
- {"engine":"pg","limit_gt":100} -> query.m (20 units)
- {"engine":"pg"} -> query.s (5 units)
(days = ceil(time_range span / 1 day); high_card = a developer_id or keyword dimension; limit_gt = the request limit.)

| argument | required | schema |
|---|---|---|
| `dataset` | yes | `string maxLength=64 minLength=1` |
| `metrics` | yes | `array maxItems=8 items=string` |
| `dimensions` | no | `array maxItems=6 items=string` |
| `filters` | no | `array maxItems=12 items=any` |
| `sort` | no | `string maxLength=65 minLength=1` |
| `limit` | no | `integer minimum=1 maximum=1000 default=100` |
| `time_range` | no | `any` |
| `vocab_version` | no | `string` |
| `params` | no | `object` |
| `idempotency_key` | no | `string maxLength=128` |


### `get_coverage_report`

The trust artifact: per-table serving-export freshness (cursor, generation, last success), corpus size estimates, the projection epoch, W3-4 coverage rows when present. Class `report` (0 units; the gateway keys every MCP request, while over REST GET /v1/coverage is unkeyed).
