Skip to main content

MCP Pagination CLI

Command-line interface for paginating through MCP server tools, resources, and prompts.

Commands Overview

CommandDescription
praisonai mcp list-toolsList tools with pagination
praisonai mcp list-resourcesList resources with pagination
praisonai mcp list-promptsList prompts with pagination

List Tools with Pagination

Basic Usage

# List first page of tools (default 50)
praisonai mcp list-tools

# Output:
# Available MCP Tools (50 of 75):
#   • praisonai.workflow.run
#     Execute a PraisonAI workflow
#   ...
# More results available. Use --cursor NTA

Options

OptionDescriptionDefault
--limit <n>Maximum tools per page50
--cursor <cursor>Pagination cursor from previous responseNone
--jsonOutput in JSON formatFalse

Pagination with Cursor

# Get first page with limit
praisonai mcp list-tools --limit 10

# Use cursor from previous response to get next page
praisonai mcp list-tools --cursor NTA --limit 10

JSON Output

# Get JSON output for programmatic use
praisonai mcp list-tools --json --limit 5
Output:
{
  "tools": [
    {
      "name": "praisonai.workflow.run",
      "description": "Execute a PraisonAI workflow",
      "inputSchema": {"type": "object"},
      "annotations": {
        "readOnlyHint": false,
        "destructiveHint": true
      }
    }
  ],
  "nextCursor": "NQ"
}

Iterate Through All Pages

#!/bin/bash
# Script to iterate through all tool pages

cursor=""
page=1

while true; do
    echo "=== Page $page ==="
    
    if [ -z "$cursor" ]; then
        result=$(praisonai mcp list-tools --json --limit 10)
    else
        result=$(praisonai mcp list-tools --json --limit 10 --cursor "$cursor")
    fi
    
    echo "$result" | jq '.tools[].name'
    
    cursor=$(echo "$result" | jq -r '.nextCursor // empty')
    
    if [ -z "$cursor" ]; then
        echo "No more pages"
        break
    fi
    
    page=$((page + 1))
done

List Resources with Pagination

# List resources
praisonai mcp list-resources

# With pagination
praisonai mcp list-resources --limit 20

# JSON output
praisonai mcp list-resources --json

List Prompts with Pagination

# List prompts
praisonai mcp list-prompts

# With pagination
praisonai mcp list-prompts --limit 20

# JSON output
praisonai mcp list-prompts --json

Exit Codes

CodeMeaning
0Success
1Error (invalid cursor, etc.)

Error Handling

Invalid Cursor

praisonai mcp list-tools --cursor "invalid!!!"
# Error: Invalid cursor: ...
# Exit code: 1

Out of Range Cursor

praisonai mcp list-tools --cursor "MTAwMA"  # Offset 1000 when only 50 tools
# Error: Invalid cursor: offset 1000 out of range
# Exit code: 1

Examples

Quick Tool Count

# Get total tool count
praisonai mcp list-tools --json --limit 1 | jq '.tools | length'

Export All Tools to File

# Export all tools to JSON file
praisonai mcp list-tools --json > tools.json

Filter by Annotation in Shell

# List only read-only tools (using jq)
praisonai mcp list-tools --json | \
  jq '.tools[] | select(.annotations.readOnlyHint == true) | .name'
# For more advanced filtering, use tools search
praisonai mcp tools search --read-only --json

See Also