Kalpana MCP

Security & Rate Limits

Edge protection, multi-tiered rate limiters, token privacy, and boundary defenses in Kalpana MCP.

The Kalpana MCP gateway acts as an isolated security perimeter between public LLM clients and Kalpana's internal rendering microservices. It enforces strict rate limiting, cryptographic token privacy, payload quotas, and workspace boundary checks.


Multi-Tier Edge Rate Limiting

The Cloudflare Worker deployment utilizes five independent rate-limiting namespaces to isolate traffic and prevent resource starvation:

Limiter NamespaceTargetLimitWindowKey Strategy
REGISTRATION_RATE_LIMITERDynamic Client Registration10 requests1 minuteSource IP address
AUTHORIZATION_RATE_LIMITERAuthorization redirect & consent60 requests1 minuteSource IP address
TOKEN_RATE_LIMITERToken code exchange & refresh60 requests1 minuteSource IP address
MCP_EDGE_RATE_LIMITERAll edge MCP traffic300 requests1 minuteSource IP address
MCP_PROBE_RATE_LIMITERUnauthorized probe requests20 requests1 minuteSource IP address
MCP_RATE_LIMITERAuthenticated MCP tool calls120 requests1 minuteOpaque SHA-256 hashed bearer token

Rate-Limit Privacy: Bearer tokens are never stored in plaintext or logged. The gateway computes an opaque SHA-256 hash to index authenticated rate-limit buckets.


Payload Size Restrictions

To defend against denial-of-service and memory exhaustion attacks, strict request size quotas are enforced at the network boundary:

  • OAuth Requests (/oauth/*): Max 16 KiB. Payloads exceeding this return 413 Payload Too Large.
  • MCP Requests (/mcp): Max 1 MiB. Ensures batch definitions and variable overrides stay within safe limits while preventing oversized JSON uploads.
  • Bearer Tokens: Max 4,096 bytes.

Gateway Isolation Secret

The gateway and the web application share a cryptographically secure random secret (MCP_REGISTRATION_SHARED_SECRET of 32+ characters).

  • When the gateway proxies token exchange or dynamic registration requests to the web backend, it injects the header x-mcp-gateway-secret.
  • The web backend explicitly rejects any registration or token exchange requests that lack this secret, preventing attackers from bypassing gateway rate limiters.

Cloudflare Bot Management & WAF

  • CIMD (Preferred): ChatGPT's preferred Client ID Metadata Document flow eliminates automated dynamic registration challenges because verification happens via ChatGPT's published HTTPS documents.
  • Dynamic Registration: If you enable dynamic registration on a zone using Cloudflare's Bot Fight Mode, automated clients may be challenged by Cloudflare's WAF before hitting the Worker. For production deployments with dynamic registration, use Cloudflare Super Bot Fight Mode with a narrow WAF skip rule targeting POST /oauth/register on the mcp.kalpana.one hostname. Never exempt the entire hostname.

On this page