Rate Limiting
Per-user request rate limiting — window mechanism, configuration, and known limitations
Rate Limiting
Rate limiting protects the Odoo server from excessive MCP traffic by enforcing a per-user request cap on a sliding calendar-minute window.
How It Works
Window Mechanism
| Property | Value |
|---|---|
| Window type | Calendar minute (floor to current minute, no seconds) |
| Key | (user_id, endpoint='/mcp') per window |
| Counter | Atomic SQL UPDATE ... SET count = count + 1 |
| Storage | ai_connector.rate_limit table |
| Old window cleanup | cleanup_old_windows(hours=1) — called manually or on demand |
Configuration
| Setting | ir.config_parameter Key | Default | Description |
|---|---|---|---|
| Enable Rate Limiting | ai_integration.enable_rate_limiting | False | Master toggle for rate limiting |
| Requests per Minute | ai_integration.request_limit | 60 | Max requests per user per calendar minute. Set to 0 for unlimited. |
Configure in Settings → General Settings → MCP Server.
Exceeded Requests
When a user exceeds their limit:
- The request is rejected with HTTP 429.
- The JSON-RPC response contains error code
-32002(Rate Limited). - An
rate_limitentry is written toai_connector.audit_log. - The user must wait until the next calendar minute for the counter to reset.
Known Limitations
[!WARNING] Cleanup cron not scheduled:
cleanup_old_windows()exists in the model but no scheduled action calls it automatically. Old window rows accumulate inai_connector_rate_limitover time. Consider scheduling a manual cleanup or adding a cron via Settings → Technical → Automation.
[!NOTE] Rate limiting currently keys on user ID only — the IP address field is available in the model but
mcp_endpointdoes not passip_addresstois_rate_limited(). Unauthenticated or pre-auth paths are not rate-limited.
Manual Cleanup
To clean up old rate limit windows from the Odoo shell:
env['ai_connector.rate_limit'].cleanup_old_windows(hours=2)
# Deletes all rate_limit rows older than 2 hours