# MCP tool pagination for large results

> Our MCP tool for listing profiles took no limit, so one call put 800 profiles in a model's context. MCP pages its own lists; tool results are yours to page.

Source: https://mosaicbrowser.com/blog/mcp-list-sent-eight-hundred-rows

## Our MCP list tool sent 800 profiles into one context window

Our MCP tool for listing profiles took no limit, so one call put 800 profiles in a model's context. MCP pages its own lists; tool results are yours to page.

![800: One tool call, every profile in the library, beside a screenshot: the Mosaic MCP server: let an AI assistant manage profiles, proxies and launches](https://mosaicbrowser.com/covers/mcp-list-sent-eight-hundred-rows.webp)

MCP has pagination, but only for the protocol's own lists. The specification gives `tools/list`, `resources/list`, `resources/templates/list` and `prompts/list` an opaque cursor and a `nextCursor` field. What a tool sends back from `tools/call` is the tool author's business. So a tool that lists things needs its own paging arguments, and ours did not have them: `list_profiles` on Mosaic's MCP server returned every profile in the library in one answer. On a library of eight hundred profiles, that was eight hundred rows dropped into a model's context window by a single call.

## How the REST route got paging and the tool did not

Mosaic has three ways in over one store: the window, a local REST API and an MCP server. We had already written down that every collection answers as `{ total, <items> }`, and `/profiles` had grown `limit` and `offset` (the reasons are in [why every list in our API answers in one shape](https://mosaicbrowser.com/blog/every-list-one-shape)). A check called `check:api-behaviour` held REST to that rule.

Nothing held MCP to it. Then somebody pointed the check at both surfaces at once: the running app, one library, one minute. Seven list tools came back as bare arrays, where REST had answered with an object:

```
tool                REST                       MCP
list_projects       { total, projects }        bare array
list_profiles       { total, profiles }        bare array, and no paging
list_proxies        { total, proxies }         bare array
list_folders        { total, folders }         bare array
list_scenarios      { total, scenarios }       bare array
list_engines        { total, engines }         bare array
list_running        -                          bare array

```

For six of the seven, that was cosmetic, at least for now: an array has no slot for a count, so any client built on it breaks on the day we add one. `list_profiles` was different, because it cost tokens. Ask it for five profiles and it sent all 800, and the model had to dig its five out of its own context. And with `total` missing, a model paging by hand couldn't tell the last page from a short one.

Mosaic is a desktop app

Email yourself the link and open it on your computer.

[How it works: MCP server](https://mosaicbrowser.com/features/mcp-server)

## What a list tool returns to a model now

`list_profiles` takes the same filters it always did (`projectId`, `search`, `tag`, `os`) plus four arguments that exist for paging:

- `limit`: how many to return, default 100, maximum 500
- `offset`: how many to skip
- `sort`: one of the profile sort keys, applied to the whole result before it is cut into a page
- `order`: `asc` or `desc`

The answer is `{ total, profiles }`, and `total` counts every row that matched the filters, not the rows on this page. A model loops while `offset + limit < total` and stops.

Three choices in there are about the reader being a model rather than a script.

The default is a page. On REST, a request with no `limit` still returns the whole collection (up to 1,000 rows), because changing that would have broken scripts that already read `/profiles` whole. A model has no such history, and the cost of "everything" lands in its context. So on MCP the absent case is 100 rows.

We sort before we cut the page, and the tool's description tells the model as much. Otherwise "my five most recently used profiles" would mean pulling every page and sorting 800 rows in its head. With `sort: lastRunAt` and `limit: 5` it takes one call.

Each row is a summary, not the whole profile. A list row carries the name, note, tags, platform, browser version, proxy label, dates and the live run state. The fingerprint, the full proxy and the privacy settings come from `get_profile`, one id at a time. A model that wants the GPU of one profile asks for that profile, and the other 799 never enter the conversation.

We chose `total` over a cursor because the store is a file on the same computer, and counting a few thousand profiles in memory costs nothing. A cursor is the better answer when counting is expensive or the data moves under you between pages. The specification's own guidance for its list methods (treat the cursor as opaque, a missing `nextCursor` means the end) is a sensible model to copy if you go that way.

![Mosaic Settings, MCP section, showing the local MCP server switch and the connection details for an AI assistant](https://mosaicbrowser.com/shots/settings-mcp.png)
*The MCP server lives in Settings › MCP*

## The check that walks both surfaces

Changing seven handlers was the easy part. What stops it happening again is the check. `check:api-behaviour` used to ask only REST whether a list answers `{ total, ... }`; it now asks fourteen MCP tools too, and it checks paging on both. It calls `list_profiles` once bare and once with `limit: 1`. The `total` has to match, and the second answer has to hold one row.

A check nobody has seen fail proves nothing, so we broke the code on purpose, one fault per run. With `list_engines` returning a bare array again, it printed:

```
MCP list_engines returns a bare array; every collection returns { total, engines }.

```

Removing `limit` from `list_profiles` printed:

```
MCP list_profiles limit=1 returned 40 profiles.

```

A rule enforced on one surface is enforced nowhere, because the surface nobody checks is the one that drifts, and a caller reading the rule cannot tell which half of it is true. One more case came out of the same pass: `list_warmup_presets` had drifted on both surfaces at once, so there was no correct copy to compare it against. Both now carry `total`.

## MCP tool pagination for large results, in five rules

What we'd tell anyone building a list tool, after getting it wrong ourselves:

1. Return an object with a count or a next cursor, never a bare array.
2. Give it a default page size that fits in a context window, and a maximum.
3. Let the model sort and filter on the server, so it never has to fetch everything to find five rows.
4. Return summaries in the list and the full record from a separate get tool.
5. Test the tool itself as well as the REST route it mirrors. A tool schema is read by something that cannot ask what was meant.

Mosaic's [MCP server](https://mosaicbrowser.com/features/mcp-server) is a Pro feature and binds to `127.0.0.1` like the REST API. Whether an assistant needs it when a REST API already exists is a separate question, answered in [do you need MCP if you have an API](https://mosaicbrowser.com/blog/do-you-need-mcp-if-you-have-an-api). For an agent working across many profiles at once, [running an AI agent with multiple browser profiles](https://mosaicbrowser.com/guides/ai-agent-with-multiple-browser-profiles) shows the tool calls end to end.

## Sources

1. [Model Context Protocol specification (2025-06-18): Pagination](https://modelcontextprotocol.io/specification/2025-06-18/server/utilities/pagination), read November 3, 2026

## Questions

### Does MCP paginate tool call results?

No. The specification defines cursor pagination for its own list methods, such as tools/list and resources/list, with a nextCursor field. What a tool returns from tools/call is up to the tool, so a tool that can return many rows needs its own limit and offset or cursor arguments.

### Should a tool return a total count or a next cursor?

Either, as long as the model can tell whether there is another page. Ours return total, the count of rows that matched, since the store sits on the same computer and counting it is free. If counting is slow, or rows move between pages, use a cursor.

### What default page size should an MCP tool use?

Smaller than the collection, and small enough to leave the model room to think. Our list_profiles sends 100 rows if you give no limit and never more than 500. The REST route kept its old default of everything, capped at 1,000, because scripts already rely on it.

### How do you stop MCP tools drifting from the REST API?

Check both surfaces with the same assertions. Mosaic's check calls each list tool and its REST route against the running app and fails when one answers a bare array or ignores limit.

## Related

[Why every list in our API answers in one shape](https://mosaicbrowser.com/blog/every-list-one-shape): /projects, /tags and /proxies returned bare arrays in version 1. Now every list carries total, and it says 344 when the page holds 50.

[An anti-detect browser MCP server for your AI assistant](https://mosaicbrowser.com/features/mcp-server): Mosaic's anti-detect browser MCP server lets Claude or any MCP client create, launch and drive your profiles. 150+ tools, off by default, key-gated.

[We have a REST API and an MCP server, and they do different jobs](https://mosaicbrowser.com/blog/do-you-need-mcp-if-you-have-an-api): Use REST when your code decides the next call and MCP when a model does. On MCP the tool description is the whole contract, so it has to be exactly true.

[AI agent with multiple browser profiles: how to set it up](https://mosaicbrowser.com/guides/ai-agent-with-multiple-browser-profiles): An AI agent with multiple browser profiles keeps one persistent profile per account, so its cookies, IP and fingerprint never mix. How to structure it.

[Anti-detect browser REST API: profiles from your scripts](https://mosaicbrowser.com/features/rest-api): Mosaic's anti-detect browser REST API runs on 127.0.0.1 with API keys. Create and start profiles, then attach Puppeteer or Playwright over CDP.







[Three MCP tool descriptions that told a model something untrue](https://mosaicbrowser.com/blog/tool-description-is-the-contract): Auditing 47 MCP tools found a field that did not exist, a trash called irreversible and a device list with no phones. A description is the model's contract.

## Mosaic, on your own computer

The browser this blog is about: its own Chromium, fingerprints from real machines and a proxy IP per profile. Free covers 3 profiles with no card, and Pro is $25 a month for any number of them.

Mosaic is a desktop app

Email yourself the link and open it on your computer.
