class RubyLLM::MCP::Transports::Support::RateLimit

def add

def add
  now = current_time
  @mutex.synchronize do
    purge_old(now)
    @timestamps << now
  end
end

def current_time

def current_time
  Process.clock_gettime(Process::CLOCK_MONOTONIC)
end

def exceeded?

def exceeded?
  now = current_time
  @mutex.synchronize do
    purge_old(now)
    @timestamps.size >= @limit
  end
end

def initialize(limit: 10, interval: 1000)

def initialize(limit: 10, interval: 1000)
  @limit = limit
  @interval = interval
  @timestamps = []
  @mutex = Mutex.new
end

def purge_old(now)

def purge_old(now)
  cutoff = now - @interval
  @timestamps.reject! { |t| t < cutoff }
end