# Class McpRateLimiter

Token bucket rate limiter implementation.

The token bucket algorithm allows for bursting up to the capacity, while maintaining a steady-state rate equal to the refill rate.

#### Example

    const limiter = new RateLimiter({
      capacity: 100,
      refillRate: 10,
      refillIntervalMs: 1000,
    });

    if (limiter.tryAcquire()) {
      // Proceed with operation
    } else {
      // Rate limited, reject or queue
    }

- Defined in packages/nexus-agents/src/mcp/middleware/rate-limiter.ts:66

##### Index

### Constructors

constructor

### Methods

tryAcquire
getState
reset

## Constructors

### constructor

- new McpRateLimiter(config: McpRateLimiterConfig): McpRateLimiter

  #### Parameters

  - config: McpRateLimiterConfig

  #### Returns McpRateLimiter

  - Defined in packages/nexus-agents/src/mcp/middleware/rate-limiter.ts:75

## Methods

### tryAcquire

- tryAcquire(count?: number): boolean

  Attempts to acquire a token.

  #### Parameters

  - count: number = 1

    Number of tokens to acquire (default: 1)

  #### Returns boolean

  True if tokens were acquired, false if rate limited

  - Defined in packages/nexus-agents/src/mcp/middleware/rate-limiter.ts:120

### getState

- getState(): RateLimiterState

  Gets the current state of the rate limiter.

  #### Returns RateLimiterState

  The current rate limiter state

  - Defined in packages/nexus-agents/src/mcp/middleware/rate-limiter.ts:144

### reset

- reset(): void

  Resets the rate limiter to full capacity. Useful for testing or after configuration changes.

  #### Returns void

  - Defined in packages/nexus-agents/src/mcp/middleware/rate-limiter.ts:161