jump to content

Paginate MCP tool results

Listing tools using the size and cursor fields, keep searches stable on pages and stop when next_cursor is absent.

Show as Markdown

If the input scheme of an instrument includes size and cursor, proceed through its results by passing the returned next_cursor in the next call.

  1. Call the listing tool without cursor.
  2. Read the items in the instrument-specific result field.
  3. If the result includes next_cursor, call the same tool again with the value cursor.
  4. Stop when next_cursor is absent.

Treat cursor values as opaque. Do not decode, edit or build them.

The first call includes the organization and, optional, a page size:

{
"organization_id": "organization-id",
"size": 50
}

listRisks returns its items in risks. When another page is available, the result also includes next_cursor:

{
"risks": [
{
"id": "risk-id",
"name": "Unauthorized production access"
}
],
"next_cursor": "cursor-value"
}

Use this value in the following call:

{
"organization_id": "organization-id",
"size": 50,
"cursor": "cursor-value"
}

Continue until the result no longer includes ___ZBT_I18N_RUNTIME_BLOCK_183__.

Keep the query unchanged

“Keep the query unchanged”

Keep page arrangement, filters, order and size unchanged when requesting the following page:

{
"organization_id": "organization-id",
"size": 50,
"filter": {
"query": "access"
},
"cursor": "cursor-value"
}

Check the tool input scheme in the clientMCP instead of assuming that each list tool supports the same fields.

Result fields differ by tool

“Result fields differ by tool”

For example, listRisks returns risks, while listThirdParties returns thirdParties. Use the server-published output scheme to determine the field for a specific tool.

For long-lasting tasks, process each page before requesting the next, instead of accumulating the full set result in memory.

Ultima actualizare: