Option C Tools
Loading...
Searching...
No Matches
oct.mcp.server.RateLimiter Class Reference

Public Member Functions

None __init__ (self, int limit_per_minute=30)
bool consume (self)

Protected Member Functions

None _refill (self)

Protected Attributes

 _limit = max(1, limit_per_minute)
float _tokens = float(self._limit)
float _last_refill = time.monotonic()

Detailed Description

Simple token-bucket rate limiter (stdlib only).

One token is consumed per tool call. Tokens refill at the rate of
``limit_per_minute / 60`` tokens per second. The bucket starts full.

Thread safety: not needed for stdio Phase 5A (single-threaded).

Definition at line 84 of file server.py.

Constructor & Destructor Documentation

◆ __init__()

None oct.mcp.server.RateLimiter.__init__ ( self,
int limit_per_minute = 30 )

Definition at line 93 of file server.py.

Member Function Documentation

◆ _refill()

None oct.mcp.server.RateLimiter._refill ( self)
protected

Definition at line 98 of file server.py.

Here is the caller graph for this function:

◆ consume()

bool oct.mcp.server.RateLimiter.consume ( self)
Try to consume one token. Returns ``False`` if rate limit is exceeded.

Definition at line 107 of file server.py.

Here is the call graph for this function:

Member Data Documentation

◆ _last_refill

float oct.mcp.server.RateLimiter._last_refill = time.monotonic()
protected

Definition at line 96 of file server.py.

◆ _limit

oct.mcp.server.RateLimiter._limit = max(1, limit_per_minute)
protected

Definition at line 94 of file server.py.

◆ _tokens

float oct.mcp.server.RateLimiter._tokens = float(self._limit)
protected

Definition at line 95 of file server.py.


The documentation for this class was generated from the following file:
  • G:/PythonApps/Option_C/oct/oct/mcp/server.py