PRACTICAL FIELD GUIDE

meta.count is the rows on this page, not the total

A returned count must be interpreted according to the API's response contract. Do not assume the number of returned records represents every matching row in the database.

MCPBackend editorial team · · Examples are illustrative

The short answer

A list request returns { data, meta: { limit, offset, count } }. count is data.length: the number of rows in this response. It is never larger than limit (25 by default, 50 at most), so a table with 4,000 matching rows still reports count: 25 on the first page. The API does not return a total count or a total-pages number.

So you can tell whether more rows exist (count equals limit), but not how many. To show "Showing 1-25 of N", either page to the end and count, or keep a counter your app maintains.

GET /v1/{projectId}/db/orders?status=paid&limit=25&offset=0

{
  "data": [ /* 25 rows */ ],
  "meta": { "limit": 25, "offset": 0, "count": 25 }
}

Page to the end and count the rows

When count is lower than limit you have reached the last page. Use the largest page size, a stable sort and the same filters on every request.

async function countRows(table, filters = {}) {
  let offset = 0, total = 0;
  for (;;) {
    const params = new URLSearchParams({ ...filters, sort: "id", limit: "50", offset: String(offset) });
    const res = await fetch(`${base}/v1/${projectId}/db/${table}?${params}`, {
      headers: { authorization: `Bearer ${token}` },
    });
    const { meta } = await res.json();
    total += meta.count;
    if (meta.count < meta.limit) return total; // short page: no more rows
    offset += meta.limit;
  }
}

What a total costs, and cheaper options

  • Each page is one API request, so counting 10,000 rows takes 200 requests from the monthly cap. Do it on a server, rarely, and cache the result.
  • For a pager, show "Next" while count equals limit instead of numbered pages. A full page followed by an empty one is normal when the total is an exact multiple of the page size.
  • For a live counter (open tickets, sign-ups), keep a stats row your app updates on create and delete, or update it from a webhook handler.
  • Owner-only tables count only the caller's rows, because the owner filter is applied before the page is taken.
  • Always pass sort. Without it the database returns rows in whatever order is cheapest, and offset pages can repeat or skip rows.

Put it into practice

  1. Inspect the generated response shape and the request's limit and offset.
  2. Compare a full page with a shorter final page using controlled data.
  3. Label UI totals only when the API supplies the required total or your application calculates it reliably.

What this looks like

ILLUSTRATIVE EXAMPLE

A response contains 25 records and count 25 because that page has 25 rows. The table may contain many more.

A boundary to keep clear

Do not build a last-page calculation from a page count without verifying that it is a total count.

MCPBackend context

Use get_project_api or the dashboard's generated OpenAPI contract for your project's exact data-plane routes. Machine keys and end-user tokens have different access models. Treat error status and JSON code together, keep credentials out of URLs, and test against disposable records before changing real data.

Take the next step

Inspect the current project contract, try the change with disposable data, and verify the result through the same credentials your app will use. Record the expected response and one denied-access case before release.

Frequently asked questions

Does the MCPBackend list API return a total count?

No. meta.count is the number of rows in the current response, capped by limit. There is no total or X-Total-Count header.

How do I know if there is another page?

If meta.count equals meta.limit there may be more rows; request the next offset. If count is lower than limit, this was the last page.

What is the maximum page size?

50 rows. limit defaults to 25 and values above 50 are capped at 50. You can page with offset or with a 1-based page parameter.

Sources and further reading

These references explain the underlying protocols and design principles. For supported MCPBackend operations and exact request shapes, inspect your project’s generated API contract.