Skip to content

Raise ValueError for RateLimitingMiddleware burst_capacity below 1 in FastMCP 5 #5295

Open

Description

@zzstoatzz

In FastMCP 5, RateLimitingMiddleware should raise a ValueError when burst_capacity is below 1.

A token bucket that holds less than one token can never admit a request. In 4.x, burst_capacity=0 silently falls back to the default (twice the rate), and negative or fractional values reject every request. 4.x keeps that behavior and emits a FastMCPDeprecationWarning that points to burst_capacity=1, which allows no bursting beyond the steady rate.

Context: #5292, #5288.

Deprecation PR: #5296

Activity

  1. added this to the Deprecations milestone on Sep 26, 2026
  2. added
    breaking change
    enhancement
    server
    on Sep 26, 2026
  3. BlueLi66 commented on Oct 9, 2026

    @BlueLi66
    Contributor

    I've reviewed the implementation and existing tests. The change would replace the warning for explicitly supplied burst_capacity < 1 with ValueError, while preserving burst_capacity=None, including the reject-all behavior when max_requests_per_second=0 and burst_capacity is omitted.

    Is this change welcome now? If so, which branch should a FastMCP 5 PR target?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking changeenhancementserver

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions