Skip to content
Back to skills

3065 006 Gateway Tool Rate Limiting Bb786b5a

ASecurity

- *Status:* Accepted - *Date:* 2025-02-21 - *Deciders:* Core Engineering Team

  • 9 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 11, 2026
databasestestingdatabasebackend

Works with

  • cli

Security analysis

A100/100

Scanned October 11, 2026

npx -y skills add tools-only/X-Skills --skill 3065-006-gateway-tool-rate-limiting_bb786b5a --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 3065 006 Gateway Tool Rate Limiting Bb786b5a?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 3065 006 Gateway Tool Rate Limiting Bb786b5a
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tools-only-3065-006-gateway-tool-rate-limiting-bb786b5a/badge)](https://www.skillsdirectory.com/skills/tools-only-3065-006-gateway-tool-rate-limiting-bb786b5a)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

SKILL.md
# ADR-0006: Gateway & Tool-Level Rate Limiting

- *Status:* Accepted
- *Date:* 2025-02-21
- *Deciders:* Core Engineering Team

## Context

ContextForge may serve hundreds of concurrent clients accessing multiple tools.
Without protection, a single client or misbehaving tool could monopolize resources or overwhelm upstream services.

The configuration includes:

- `TOOL_RATE_LIMIT`: default limit in requests/min per tool/client
- Planned support for Redis-based or database-backed counters

Current implementation is an in-memory token bucket.

## Decision

Implement a **rate limiter at the tool invocation level**, keyed by:

- Tool name
- Authenticated user / client identity (JWT or Basic)
- Time window (per-minute by default)

Backend options:

- **Memory** (default for dev / single instance)
- **Redis** (planned for clustering / shared limits)
- **Database** (eventually consistent fallback)

## Consequences

- ✅ Prevents abuse, controls cost, and provides predictable fairness
- 📉 Failed requests return `429 Too Many Requests` with retry headers
- ❌ Memory backend does not scale across instances; Redis required for HA
- 🔄 Optional override of limits via config/env for testing

## Alternatives Considered

| Option | Why Not |
|--------|---------|
| **No rate limiting** | Leaves gateway and tools vulnerable to overload or accidental DoS. |
| **Global rate limit only** | Heavy tools can starve lightweight tools; no fine-grained control. |
| **Proxy-level throttling (e.g. NGINX, Envoy)** | Can't distinguish tools or users inside payload; lacks granularity. |

## Status

Rate limiting is implemented for tool routes, with `TOOL_RATE_LIMIT` as the default policy.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.