Feedback

Chat Icon

Practical MCP with FastMCP & LangChain

Engineering the Agentic Experience

Primitives, Capabilities & Utilities in MCP
13%

Pagination (Server Side)

Pagination in MCP is a way to handle long lists safely and efficiently. It prevents the server from sending thousands of items in a single response. The core idea is simple: instead of returning everything at once, the server sends results in chunks. If more data exists, it provides a cursor. The client uses that cursor to request the next chunk.

The cursor is not a page number. It is not “page 2” or “offset 50.” It is an opaque token. The client does neither inspect it nor decode it. It simply passes it back to the server to continue where it left off.

This design avoids assumptions about how the server stores or retrieves data. The server might be querying a database, reading from a filesystem, or calling an external API. The cursor represents internal state.

Now let’s focus on some concrete examples to illustrate how pagination works in practice:

Imagine an MCP server connected to a large code repository. The client asks for a list of resources representing project files.

The project contains 12,000 files. Returning them all in one response would:

  • Increase latency
  • Consume memory
  • Potentially exceed transport limits

Instead, the server returns the first batch, perhaps 200 files, and includes a nextCursor. The format of the message might look like this:

{
  "jsonrpc": "2.0",
  "id": "20",
  "result": {
    "resources": [
      {"id": "file1", "name": "README.md", "uri": "mcp://repo/files/README.md"},
      {"id": "file2", "name": "auth.js", "uri": "mcp://repo/files/auth.js"},
      // ...

Practical MCP with FastMCP & LangChain

Engineering the Agentic Experience

Enroll now to unlock current content and receive all future updates for free. Your purchase supports the author and fuels the creation of more exciting content. Act fast, as the price will rise as the course nears completion!