---
name: store-query-export
description: Query and count NiftyImages Data Store records via MCP or the v2 API. Use when a user asks how many rows match a filter, to list matching records, or to look up one record by unique key.
---

# Store Query

## Preferred path: MCP

MCP endpoint: `https://dev.niftyimages.com/store_mcp`

| User intent | Tool |
| --- | --- |
| What store / schema? | `store_access` (optional `storeId` for account keys) |
| Find store by name | `store_list` with `q` |
| How many…? | `store_query` with `mode: "count"` |
| Show / list matches | `store_query` with `mode: "search"` |
| One row by email/id | `store_get_record` with `key` |

## Credential rules

- Prefer a **Store API Key** for single-store work; `storeId` is optional then.
- Account keys must pass `storeId` after `store_list` / `store_access`.
- Never invent, log, or expose API keys.

## Filters

Filters are AND-combined. Example:

```json
{
  "mode": "count",
  "filters": [
    { "field": "status", "op": "eq", "value": "VIP" },
    { "field": "state", "op": "eq", "value": "CA" }
  ]
}
```

Ops: string `eq`/`ne`/`contains`/`startsWith`/`endsWith`/`empty`/`notEmpty`; number `eq`/`ne`/`gt`/`gte`/`lt`/`lte`; boolean `eq`; datetime `on`/`before`/`after`.

## Limits

- MCP search default limit 25, max 50. Prefer **count** for totals.
- Do not guess field names — load schema via `store_access`.

## HTTP alternative

- Count: `POST /v2/stores/{storeId}/records/count`
- Search: `POST /v2/stores/{storeId}/records/search`
- Lookup: `POST /v2/stores/{storeId}/records/lookup`
- Export (REST only, not on MCP): `GET /v2/stores/{storeId}/records/export`

## Do not

- Do not dump the whole store when the user asked “how many.”
- Do not delete records unless the user explicitly asks (deletes are REST-only; not on MCP).
