# Kong (AI API Gateway) MCP

> Kong (AI API Gateway) MCP Server manages your entire API lifecycle. Your agent can list, create, and update services, routes, and plugins—including setting up secure LLM routing with `ai-proxy`. It lets you configure rate limits, manage consumer keys, and audit the whole gateway without touching a UI. It’s full control over your backend APIs and AI traffic, all from chat.

## Overview
- **Category:** friends-mcp
- **Price:** Free
- **Tags:** api-gateway, microservices, traffic-management, service-orchestration, cloud-native, ai-ops

## Description

**Kong API Gateway MCP Server - Manage Services & Routes**

Your agent gives you total control over your API lifecycle. You'll list, create, and update services, routes, and plugins—including setting up secure LLM routing with `ai-proxy`. You can configure rate limits, manage consumer keys, and audit the whole gateway without ever touching a UI. It's full control over your backend APIs and AI traffic, all from chat.

**Define Backend Services**

You'll define a new backend service by specifying its upstream URL, name, and protocol using `create_service`. You can list every backend service registered and available in the gateway with `list_services`.

**Configure API Routing**

To set up inbound routing rules, you'll establish a new routing rule, mapping incoming client requests to specific backend services via `create_route`. You can retrieve a list of all currently configured routing rules in the API Gateway with `list_routes`.

**Control AI Plugins**

Your agent lets you apply a new plugin, like AI Proxy, to a specific service for LLM routing and key encapsulation using `create_ai_plugin`. You can modify the configuration of an existing plugin, such as adjusting rate limits or swapping AI model providers, with `update_plugin`. You can remove a plugin from the Kong Gateway permanently with `delete_plugin` and show all plugins configured globally or on specific services/routes using `list_plugins`.

**Manage User Credentials**

To generate a new API key credential for a specific Kong consumer profile, you'll use `create_consumer_key`. You can list all consumer profiles registered within the Kong API Gateway using `list_consumers`.

**Audit Gateway Health**

Check the current state of the API gateway by listing every backend service available with `list_services`, checking all configured routing rules with `list_routes`, and showing all active plugins with `list_plugins`.

## Tools

### create_ai_plugin
Applies a new plugin, like AI Proxy, to a specific service for LLM routing and key encapsulation.

### create_consumer_key
Generates a new API key credential for a specific Kong consumer profile.

### create_route
Establishes a new routing rule, exposing an existing service via a defined path or hostname.

### create_service
Defines a new backend service by specifying its upstream URL, name, and protocol.

### delete_plugin
Removes a plugin from the Kong Gateway, taking it out of service permanently.

### list_consumers
Lists all consumer profiles registered within the Kong API Gateway.

### list_plugins
Shows all plugins (like Rate Limiting, AI Proxy, Key Auth) configured globally or on specific services/routes.

### list_routes
Retrieves a list of all currently configured routing rules in the API Gateway.

### list_services
Lists every backend service registered and available within the Kong API Gateway.

### update_plugin
Modifies the configuration of an existing plugin, such as adjusting rate limits or swapping AI model providers.

## Prompt Examples

**Prompt:** 
```
List all registered services in my Kong Gateway
```

**Response:** 
```
I've found 4 services: 'auth-api', 'inventory-service', 'ai-gateway-proxy', and 'legacy-backend'. Would you like to see the routing rules for any of these?
```

**Prompt:** 
```
Add the 'ai-proxy' plugin to service ID '123-abc' using OpenAI
```

**Response:** 
```
Applying AI Proxy plugin to service '123-abc'… Done. I've configured it to route traffic to OpenAI using the GPT-4 model. Your gateway is now ready to handle AI requests for this endpoint.
```

**Prompt:** 
```
Who are the registered consumers in our gateway?
```

**Response:** 
```
I've identified 3 consumers: 'MobileApp_Prod', 'ThirdParty_Partner', and 'InternalAdmin_CLI'. 'MobileApp_Prod' has 2 active API keys. Would you like to generate a new key for 'ThirdParty_Partner'?
```

## Capabilities

### Define Backend Services
Create new backend services by defining the upstream URL, name, and protocol.

### Configure API Routing
Set up inbound routing rules that map incoming client requests to specific backend services.

### Control AI Plugins
Apply, configure, and update plugins like `ai-proxy` to manage LLM routing and security features.

### Manage User Credentials
List consumer profiles and generate specific API keys for usage tracking.

### Audit Gateway Health
List all plugins, services, and routes to check the current state of the API gateway.

## Use Cases

### A new microservice needs an API endpoint.
The backend developer writes the code for the 'Inventory Service.' Instead of manually logging into Kong Manager, they tell their agent: 'Create a service for the inventory backend' (`create_service`), then 'Expose it at `/v1/inventory`' (`create_route`). The agent handles the whole deployment cycle, and the service is live immediately.

### We need to upgrade our LLM provider for cost reasons.
The AI Ops Team Lead runs into unexpected high costs with OpenAI. They tell their agent to use `update_plugin` to modify the `ai-proxy` plugin settings. They switch the backend model provider from GPT-4 to Claude, adjusting the rate limits in the same chat session. The change takes effect instantly.

### A new third-party partner needs API access.
The Platform Engineer needs to onboard a new partner. They first run `list_consumers` to check existing accounts, then use `create_consumer_key` to generate a unique API key. Finally, they might use `create_ai_plugin` to ensure the new key is properly authorized through the gateway.

### Debugging a misrouted API call.
The developer suspects a service is using outdated credentials. They use `list_services` to verify the correct service name, then use `list_plugins` to check if the `key-auth` plugin is active on that specific route. This pinpoints the exact failure point without digging through logs.

## Benefits

- **Provision New Endpoints:** Use `create_service` to define a new backend service with its upstream URL and protocol. Then, use `create_route` to immediately expose it to clients, all without leaving your terminal.
- **Secure AI Integration:** Apply and configure the `ai-proxy` plugin using `create_ai_plugin`. This lets you route LLM traffic and handle key encapsulation securely, making your APIs AI-ready.
- **Real-Time Operational Fixes:** Need to change a rate limit or switch an AI model provider? The `update_plugin` tool lets you patch existing plugin configurations dynamically, keeping your service running smoothly.
- **Governance and Audit:** Use `list_plugins` and `list_services` to audit the entire gateway. You can find every active plugin or every registered service, ensuring nothing is forgotten.
- **User Management:** Manage client access using `list_consumers` and `create_consumer_key`. This allows you to track usage per tenant or user group, enforcing proper access control.
- **Clean Architecture:** Run an infrastructure audit by calling `list_plugins` and `delete_plugin` to identify and remove unused modules, keeping the proxy pipeline clean and efficient.

## How It Works

The bottom line is, you manage your entire API infrastructure and AI traffic using conversational commands, without ever logging into the Kong Manager UI.

1. Subscribe to the server and provide your Kong Admin URL and Admin Token.
2. Your agent connects to the gateway, authenticating with the provided credentials.
3. You issue a command (e.g., 'Create a new service for the billing API') and the agent executes the necessary API calls.

## Frequently Asked Questions

**How do I use the `create_service` tool with Kong (AI API Gateway) MCP Server?**
The `create_service` tool requires you to provide the upstream URL, name, and protocol for the new backend service. You tell the agent these three pieces of data, and it registers the service in Kong.

**Can I manage AI routing with the `create_ai_plugin` tool?**
Yes, `create_ai_plugin` is used to apply the `ai-proxy` plugin to a service. This allows you to configure LLM routing, select model providers, and manage key encapsulation for AI traffic.

**What does the `list_plugins` tool show me?**
The `list_plugins` tool shows every plugin currently configured on your Kong Gateway, whether it's global or scoped to a specific service or route.

**How do I generate a new API key using `create_consumer_key`?**
You run `create_consumer_key` and specify the consumer profile name. The agent then generates the required API key credential for that consumer in Kong.

**Can I update rate limits using the `update_plugin` tool?**
Yes. `update_plugin` lets you adjust plugin settings in real time, like changing a rate limit or swapping out an AI model provider without downtime.

**How do I use the `list_consumers` tool to check my registered API users?**
It shows all Consumer profiles registered in Kong. You can see who's connected and how many API keys they have, which is key for tracking usage.

**What can I do with the `create_route` tool in Kong (AI API Gateway)?**
It creates a new Route definition. This lets you expose a backend Service using specific path or hostname rules, ensuring clients hit the right endpoint.

**Can I delete a plugin using the `delete_plugin` tool?**
Yes, this permanently removes a Plugin from the Kong Gateway. Use it to clean up unused modules and keep your proxy pipeline simple.

**Can I use this server to manage Kong's AI Proxy plugin?**
Absolutely. The `create_ai_plugin` tool is specifically designed to inject the `ai-proxy` plugin onto Services. You can define providers like OpenAI or Anthropic and manage model routing directly through your agent.

**How do I create a new API route through a conversation?**
Use the `create_route` tool and provide a JSON payload defining the paths and the Service ID it should point to. Your agent will handle the Admin API call to provision the routing rule instantly.

**Can my agent generate new API keys for consumers?**
Yes. The `create_consumer_key` tool allows you to provision new credentials for specific Consumers. This is perfect for onboarding new tenants or rotating keys for downstream applications securely.