Corcava logoLe seul outil métier dont vous avez besoinCorcava
Menu

Pagination et filtrage dans MCP : moins d'appels, résultats plus rapides

Design efficient prompts and tool usage to avoid giant lists. This guide covers pagination strategies, narrowing filters, and summarization techniques—with practical examples for listing tasks and comments in Corcava.

Why Pagination Matters

Large lists cause performance issues:

Problems with Giant Lists

  • Slow responses: Fetching thousands of tasks takes time
  • High memory usage: Large responses consume resources
  • Rate limiting: Large queries may hit API limits
  • Poor user experience: Long waits for results
  • Unnecessary data: You often only need a subset

Strategy 1: Use Filters at Tool Level

Filter data at the source, not in prompts:

Efficient: Filter in Tool Call

"List tasks with status 'open' and due this week from Corcava. Show me the top 10."

What the AI does:

  1. Calls list_tasks with filters: status='open', due_date='this_week'
  2. Receives filtered, smaller result set
  3. Shows top 10 from results
  4. Total: 1 call, small response

✓ Efficient: Server does filtering, minimal data transfer

⚠️ Inefficient: Filter in Prompt

"List all tasks from Corcava, then filter for status 'open' and due this week, then show top 10."

What happens:

  1. Calls list_tasks (gets ALL tasks)
  2. AI filters in memory (unnecessary)
  3. Shows top 10
  4. Total: 1 call, but fetches way more data than needed

✗ Inefficient: Fetches unnecessary data

Strategy 2: Use Pagination

Request data in pages rather than all at once:

Pagination Pattern

"List tasks from Corcava, 20 at a time. Start with the first page. If I need more, I'll ask for the next page."

What the AI does:

  1. Calls list_tasks with limit=20, offset=0
  2. Returns first 20 tasks
  3. Shows results
  4. Waits for request for next page

✓ Efficient: Small, manageable chunks

Pagination Example

Multi-Page Request Pattern

"List tasks in project '[Project ID]' from Corcava: 1. First, get page 1 (limit 20, offset 0) 2. Show me the first 20 tasks 3. If there are more, tell me how many total tasks exist 4. I'll ask for page 2 if needed"

This pattern: Fetches in pages, shows progress, allows on-demand loading

Strategy 3: Summarization

Ask for summaries instead of full lists:

Summarization Pattern

"Summarize my Corcava tasks due this week: total count, breakdown by status, top 5 priorities. Don't list all tasks—just give me the summary."

What the AI does:

  1. Calls list_tasks with filters
  2. Processes results to create summary
  3. Returns summary instead of full list
  4. Much smaller response

✓ Efficient: Summary is much smaller than full list

Examples: Tasks and Comments

Example 1: Paginated Task List

Efficient Paginated Request

"List tasks in project '[Project ID]' from Corcava: - Use pagination: limit 25, offset 0 - Show me the first 25 tasks - Include total count if available - Format as a paginated list"

This pattern: Fetches manageable chunks, shows progress

Example 2: Filtered Comment List

Efficient Filtered Comments

"List comments on task '[Task ID]' from Corcava: - Limit to last 10 comments - Show most recent first - Don't fetch all comments—just the recent ones"

This pattern: Limits results, focuses on recent activity

Example 3: Summarized Task Overview

Efficient Summary Request

"Give me a summary of my Corcava tasks: - Total tasks by status (open, in_progress, done, blocked) - Tasks due this week (count only) - Top 5 priorities - Don't list all tasks—just the summary metrics"

This pattern: Gets summary metrics without full task lists

Narrowing Filters

Effective Filter Combinations

  • Project + Status: project_id + status narrows significantly
  • Date Range: due_date: "this_week" limits to recent
  • Assignee + Status: assignee + status finds specific work
  • Multiple Filters: Combine filters for precise results

Filter Combination Example

Highly Filtered Request

"List tasks in project '[Project ID]' with status 'open' or 'in_progress', assigned to '[Name]', due this week. Limit to 20 results."

Filters applied:

  • Project filter
  • Status filter (multiple values)
  • Assignee filter
  • Date filter
  • Limit filter

✓ Very efficient: Multiple filters narrow results significantly

Best Practices

Pagination and Filtering Best Practices

  • Always use filters: Filter at tool level, not in prompts
  • Set reasonable limits: Use limit parameter (e.g., 20-50 items)
  • Paginate large lists: Request pages rather than all data
  • Summarize when possible: Ask for summaries instead of full lists
  • Combine filters: Use multiple filters to narrow results
  • Specify what you need: Be explicit about data requirements

Performance Tips

Optimization Strategies

  • Start small: Request 10-20 items first, then expand if needed
  • Use date filters: Limit to recent data (this week, this month)
  • Project-specific: Filter by project to reduce scope
  • Status filters: Focus on specific statuses (open, in_progress)
  • Avoid "all": Never request all tasks without filters

Related Resources

Optimize Your MCP Queries

Use pagination and filtering to speed up results and reduce API calls