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
What the AI does:
- Calls
list_taskswith filters: status='open', due_date='this_week' - Receives filtered, smaller result set
- Shows top 10 from results
- Total: 1 call, small response
✓ Efficient: Server does filtering, minimal data transfer
⚠️ Inefficient: Filter in Prompt
What happens:
- Calls
list_tasks(gets ALL tasks) - AI filters in memory (unnecessary)
- Shows top 10
- 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
What the AI does:
- Calls
list_taskswith limit=20, offset=0 - Returns first 20 tasks
- Shows results
- Waits for request for next page
✓ Efficient: Small, manageable chunks
Pagination Example
Multi-Page Request Pattern
This pattern: Fetches in pages, shows progress, allows on-demand loading
Strategy 3: Summarization
Ask for summaries instead of full lists:
Summarization Pattern
What the AI does:
- Calls
list_taskswith filters - Processes results to create summary
- Returns summary instead of full list
- Much smaller response
✓ Efficient: Summary is much smaller than full list
Examples: Tasks and Comments
Example 1: Paginated Task List
Efficient Paginated Request
This pattern: Fetches manageable chunks, shows progress
Example 2: Filtered Comment List
Efficient Filtered Comments
This pattern: Limits results, focuses on recent activity
Example 3: Summarized Task Overview
Efficient Summary Request
This pattern: Gets summary metrics without full task lists
Narrowing Filters
Effective Filter Combinations
- Project + Status:
project_id + statusnarrows significantly - Date Range:
due_date: "this_week"limits to recent - Assignee + Status:
assignee + statusfinds specific work - Multiple Filters: Combine filters for precise results
Filter Combination Example
Highly Filtered Request
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
Batching Guide
Reduce tool calls
Timeout Issues
Fix slow responses
Rate Limiting
Reduce API calls
Tool Reference
Available filters
Optimize Your MCP Queries
Use pagination and filtering to speed up results and reduce API calls
