Kong API Gateway Integration Guide
Complete guide for integrating MCP Server with LangGraph with Kong API Gateway for rate limiting, authentication, and API management.Table of Contents
- Overview
- Installation
- Rate Limiting
- Authentication
- Deployment
- Multi-Tenancy
- Monitoring
- Advanced Features
- Troubleshooting
Overview
Kong API Gateway provides:- Rate Limiting: Per-consumer, per-service, global limits
- Authentication: JWT, API Key, OAuth2, Basic Auth
- Traffic Control: Request/response transformation, routing
- Security: IP restriction, bot detection, CORS
- Observability: Prometheus metrics, logging, tracing
Installation
Option 1: Kong for Kubernetes (Recommended)
Option 2: Kong DB-less (Declarative Configuration)
Rate Limiting
Basic Rate Limiting (All Users)
Redis-based Rate Limiting (Distributed)
For multi-replica Kong deployments, use Redis for shared state:Tiered Rate Limiting
Free Tier (60 req/min, 1,000 req/hour):Advanced Rate Limiting
Per-consumer with consumer groups:Authentication
API Key Authentication
1. Create KongPlugin:JWT Authentication
1. Create KongPlugin:OAuth2 Authentication
Deployment
Deploy with Kubernetes Manifests
Deploy with Helm
Multi-Tenancy
Separate Endpoints per Tier
Free Tier:Path-based Routing
Consumer Groups
Monitoring
Prometheus Metrics
Enable Prometheus plugin:ServiceMonitor for Prometheus Operator
Request Logging
Advanced Features
Request/Response Transformation
IP Restriction
Bot Detection
Circuit Breaker
Canary Releases
Troubleshooting
Check Kong Status
Test Rate Limiting
Check Rate Limit Headers
Debug Kong Logs
Common Issues
Rate limiting not working:- Check plugin is applied to route/service
- Verify Redis connectivity (for distributed)
- Check consumer credentials
- Verify consumer exists
- Check credential format
- Review JWT expiration
- Check backend service is running
- Verify service name in Kong configuration
- Check health checks
Kong Admin API
Testing Rate Limits
Python Test Script
Production Checklist
- Use Redis for distributed rate limiting
- Configure appropriate rate limits per tier
- Enable authentication (JWT or API Key)
- Set up monitoring and alerting
- Configure health checks
- Enable request logging
- Set up IP whitelisting if needed
- Configure bot detection
- Test rate limiting before production
- Document rate limits in API docs
- Set up consumer management
- Configure CORS appropriately
- Enable Prometheus metrics
- Test failover scenarios