Skip to content

Feature Request: Admin-Configurable Query Limits and Throttling #6

@amirhaghajani

Description

@amirhaghajani

Feature request

Type

  • - Enhancement - completely new feature

I'm deploying API Agent in a production factory environment where I have 500+ machines, and each machine can have hundreds of failure records. Currently, if a user asks, "Show me failures for all machines", the agent attempts to fetch all 500 machines and then calls the failures API for each one - potentially generating 500+ API calls in seconds. This overwhelms my backend APIs and risks downtime. As an admin, I have no way to prevent users from accidentally (or intentionally) making such broad queries that could crash our systems.

Add admin-configurable limits at the server level that automatically reject queries exceeding defined thresholds and return user-friendly guidance.

Configuration Options:

# Environment variables
API_AGENT_MAX_ITEMS_PER_QUERY=100        # Max records to process
API_AGENT_MAX_API_CALLS_PER_QUERY=50      # Max API calls per user query
API_AGENT_MAX_BATCH_SIZE=10                # Max items per batch operation

MCP Server Headers:

{
  "mcpServers": {
    "factory-api": {
      "url": "http://localhost:3000/mcp",
      "headers": {
        "X-Target-URL": "https://factory.internal/api",
        "X-API-Type": "rest",
        "X-Max-Items-Per-Query": "100",
        "X-Max-APICalls-Per-Query": "50",
        "X-Strict-Limits": "true"
      }
    }
  }
}

User Experience When Limit Exceeded:

User: "Show failures for all German machines"

Agent Response:
{
  "error": "Query too broad - would check 500 machines and make 501 API calls",
  "limit_info": {
    "max_allowed_items": 100,
    "max_allowed_calls": 50,
    "items_requested": 500,
    "calls_needed": 501,
    "suggestions": [
      "Add LIMIT 50 to your query",
      "Filter by specific machine types (CNC, Robotic Arms, etc.)",
      "Check only high-severity failures",
      "Limit to last 7 days of failures"
    ],
    "examples": [
      "Show failures for first 50 German machines",
      "Get high-severity failures for German CNC machines (limit 50)",
      "Show failure count for German machines grouped by type (top 10)"
    ]
  }
}

Additional context

When a user exceeds limits, they should see:

Example 1: Too many items requested

Your query would fetch failures for approximately 500 machines.

⚠️ This exceeds the maximum limit of 100 machines per query.

Please modify your question to be more specific. For example:
✅ "Show failures for the first 50 machines from Germany"
✅ "Get failures for machines with temperature > 50°C (limit 100)"
✅ "Show failure summary for the top 10 machines by operating hours"

Example 2: Too many API calls

Processing your request would require 5,001 API calls to our backend.

⚠️ This exceeds the maximum of 50 API calls per query.

Suggestions:
✅ Add a country filter: "Show failures for German machines only"
✅ Add a status filter: "Check failures for operational machines"
✅ Limit by date: "Show failures from the last 7 days"
✅ Combine filters: "First 10 Japanese machines with high temperature"

Example 3: Batch operation too large

You're trying to fetch failures for 100 machines in one request.

⚠️ Maximum batch size is 10 machines.

Please break this down:
✅ First batch: machines 1-10
✅ Second batch: machines 11-20
Or add more specific filters to reduce the set.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions