Rate Limiting
Odoo AI MCP Server

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

Rendering diagram…

Window Mechanism

PropertyValue
Window typeCalendar minute (floor to current minute, no seconds)
Key(user_id, endpoint='/mcp') per window
CounterAtomic SQL UPDATE ... SET count = count + 1
Storageai_connector.rate_limit table
Old window cleanupcleanup_old_windows(hours=1) — called manually or on demand

Configuration

Settingir.config_parameter KeyDefaultDescription
Enable Rate Limitingai_integration.enable_rate_limitingFalseMaster toggle for rate limiting
Requests per Minuteai_integration.request_limit60Max 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:

  1. The request is rejected with HTTP 429.
  2. The JSON-RPC response contains error code -32002 (Rate Limited).
  3. An rate_limit entry is written to ai_connector.audit_log.
  4. 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 in ai_connector_rate_limit over 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_endpoint does not pass ip_address to is_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