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

Batching Tool Calls in MCP: Fewer Requests, Better Performance

Optimize MCP performance by batching tool calls effectively. This performance guide shows you how to list once then operate on subsets, reduce tool-call loops, and improve response times with efficient prompt templates.

What This Guide Covers

This guide teaches you batching strategies for better performance:

Key Topics

  • List once, operate many: Fetch data once, then work with subset
  • Reduce loops: Avoid iterating over items with tool calls
  • Batch operations: Group related operations together
  • Prompt templates: Efficient patterns that minimize calls
  • Performance benefits: Faster responses, lower latency

Strategy 1: List Once, Operate on Subset

Fetch data once, then work with a filtered subset:

Efficient Pattern

"List all tasks due this week. Then, for the top 3 highest-priority tasks, update their status to 'in_progress'."

What the AI does:

  1. Calls list_tasks once (with due_date filter)
  2. Selects top 3 from the results
  3. Calls update_task for each of the 3 tasks
  4. Total: 1 list call + 3 update calls = 4 calls

✓ Efficient: Single list call, then targeted updates

⚠️ Inefficient Pattern (Avoid)

"For each task due this week, get the task details, then update it."

What happens:

  1. AI calls list_tasks to get tasks
  2. For each task, calls get_task (unnecessary)
  3. For each task, calls update_task
  4. Total: 1 list + N get + N update = many calls

✗ Inefficient: Too many calls, slow performance

Strategy 2: Use Filters at Tool Level

Filter at the tool level, not in prompts:

Efficient: Filter in Tool Call

"List tasks with status 'blocked' and due this week. Then update the top 2 to status 'in_progress'."

What the AI does:

  1. Calls list_tasks with filters: status='blocked', due_date='this_week'
  2. Receives filtered results directly
  3. Updates only the top 2
  4. Total: 1 list call + 2 update calls = 3 calls

✓ Efficient: Server does filtering, fewer results

⚠️ Inefficient: Filter in Prompt

"List all tasks. Then filter for status 'blocked' and due this week. Then update those."

What happens:

  1. AI calls list_tasks (gets ALL tasks)
  2. AI filters in memory (unnecessary work)
  3. Then updates filtered subset
  4. Total: 1 large list call + N update calls

✗ Inefficient: Fetches more data than needed

Strategy 3: Avoid Tool-Call Loops

Don't ask AI to iterate—use tool filters instead:

Efficient: Single Query with Filters

"List tasks in project [Project ID] with status 'open' and due this week. Show me the top 5."

What the AI does:

  1. Calls list_tasks with all filters at once
  2. Receives filtered, sorted results
  3. Shows top 5
  4. Total: 1 call

✓ Efficient: Single call, server does all filtering

⚠️ Inefficient: Loop Pattern (Avoid)

"For each project, list tasks, then for each task check if it's due this week, then show those."

What happens:

  1. AI calls list_projects
  2. For each project, calls list_tasks
  3. For each task, checks due date (in memory)
  4. Total: 1 + N project calls = many calls

✗ Inefficient: Creates loop, many tool calls

Prompt Templates

Template 1: Batch Update Pattern

Efficient Batch Update

"List tasks with status 'open' and due this week. Then update the top 5 to status 'in_progress'. Show me which tasks were updated."

This pattern: List once → Select subset → Batch update

Template 2: Multi-Project Summary

Efficient Multi-Project Query

"List all projects. Then for each project, list tasks due this week. Show me a summary grouped by project."

This pattern: List projects → List tasks per project → Summarize

Note: This still requires multiple calls, but they're necessary for the use case

Template 3: Single Comprehensive Query

Most Efficient Pattern

"List tasks with status 'blocked' or 'in_progress', due this week, in project [Project ID]. Show me the top 10 with their assignees."

This pattern: Single call with all filters → Server does all work

Performance Benefits

Why Batching Matters

  • Faster responses: Fewer round trips = lower latency
  • Lower server load: Fewer requests = better scalability
  • Better user experience: Quicker results = happier users
  • Reduced rate limiting: Fewer calls = less likely to hit limits
  • Lower costs: Fewer API calls = lower usage costs

Best Practices

Batching Best Practices

  • Filter at tool level: Use tool filters, not prompt filtering
  • List once: Fetch data once, then work with subset
  • Avoid loops: Don't ask AI to iterate over items
  • Batch operations: Group related updates together
  • Use pagination: For large lists, use pagination instead of fetching all
  • Combine filters: Use multiple filters in single query

Troubleshooting

Slow Responses

Symptom: MCP operations take too long

Possible causes:

  • Too many tool calls in a loop
  • Fetching all data instead of filtering
  • Not batching operations

Fix: Use batching patterns, filter at tool level, list once then operate

Rate Limiting

Symptom: Getting 429 rate limit errors

Possible causes:

  • Making too many tool calls
  • Not batching operations
  • Looping over items with tool calls

Fix: Batch operations, reduce tool calls, use filters

Rate limiting guide →

Related Resources

Optimize Your MCP Performance

Use batching strategies to reduce tool calls and improve response times

Continue Reading

Prompts MCP pour contributeurs individuels

Bibliothèque de prompts IC : focus quotidien, clarifier les tâches, journaliser la progression, suivi du temps. Prompts...

Index dépannage MCP

Page index organisée par symptôme (connexion, auth, config, outils manquants, échecs d'appel, perf). Liens vers chaque a...