Aggregate MCP tools from multiple AI MCP Proxy plugins

Deployment Platform
Tags
Related Resources
Minimum Version
Kong Gateway - 3.12
TL;DR

Use AI MCP Proxy in conversion-only mode to convert each RESTful API into MCP tools, then configure a listener-mode plugin to aggregate and expose all tools to AI clients. Then, use Cursor, or any other compatible client to validate the aggregated tool calls.

Prerequisites

This is a Konnect tutorial and requires a Konnect personal access token.

  1. Create a new personal access token by opening the Konnect PAT page and selecting Generate Token.

  2. Export your token to an environment variable:

     export KONNECT_TOKEN='YOUR_KONNECT_PAT'
    
  3. Run the quickstart script to automatically provision a Control Plane and Data Plane, and configure your environment:

     curl -Ls https://get.konghq.com/quickstart | bash -s -- -k $KONNECT_TOKEN --deck-output
    

    This sets up a Konnect Control Plane named quickstart, provisions a local Data Plane, and prints out the following environment variable exports:

     export DECK_KONNECT_TOKEN=$KONNECT_TOKEN
     export DECK_KONNECT_CONTROL_PLANE_NAME=quickstart
     export KONNECT_CONTROL_PLANE_URL=https://us.api.konghq.com
     export KONNECT_PROXY_URL='http://localhost:8000'
    

    Copy and paste these into your terminal to configure your session.

This tutorial requires Kong Gateway Enterprise. If you don’t have Kong Gateway set up yet, you can use the quickstart script with an enterprise license to get an instance of Kong Gateway running almost instantly.

  1. Export your license to an environment variable:

     export KONG_LICENSE_DATA='LICENSE-CONTENTS-GO-HERE'
    
  2. Run the quickstart script:

    curl -Ls https://get.konghq.com/quickstart | bash -s -- -e KONG_LICENSE_DATA 
    

    Once Kong Gateway is ready, you will see the following message:

     Kong Gateway Ready
    

decK is a CLI tool for managing Kong Gateway declaratively with state files. To complete this tutorial, install decK version 1.43 or later.

This guide uses deck gateway apply, which directly applies entity configuration to your Gateway instance. We recommend upgrading your decK installation to take advantage of this tool.

You can check your current decK version with deck version.

For this tutorial, you’ll need Kong Gateway entities, like Gateway Services and Routes, pre-configured. These entities are essential for Kong Gateway to function but installing them isn’t the focus of this guide. Follow these steps to pre-configure them:

  1. Run the following command:

    echo '
    _format_version: "3.0"
    services:
      - name: mcp-service
        url: http://host.docker.internal:3000
      - name: weather-service
        url: https://api.weatherapi.com/v1/current.json
      - name: freecurrency-service
        url: https://api.freecurrencyapi.com/v1/latest
    routes:
      - name: mcp-route
        paths:
        - "/marketplace"
        service:
          name: mcp-service
      - name: weather-route
        paths:
        - "/weather"
        service:
          name: weather-service
      - name: freecurrency-route
        paths:
        - "/currency"
        service:
          name: freecurrency-service
      - name: listener-route
        paths:
        - "/mcp-listener"
    ' | deck gateway apply -
    

To learn more about entities, you can read our entities documentation.

Before setting up the first AI MCP Proxy plugin, you need an upstream HTTP API. For this tutorial, use a simple Express-based mock API that simulates a small marketplace with users and their orders. It exposes /marketplace/users and /marketplace/{userId}/orders endpoints.

Run the following to download and start the mock API:

curl -s -o api.js "https://gist.githubusercontent.com/subnetmarco/5ddb23876f9ce7165df17f9216f75cce/raw/a44a947d69e6f597465050cc595b6abf4db2fbea/api.js"
npm install express
node api.js

Verify it’s running:

curl -X GET http://localhost:3000

You should see:

{"name":"Sample Users API"}%
  1. Go to WeatherAPI.
  2. Navigate to your dashboard and copy your API key.
  3. Export your API key by running the following command in your terminal:
    export DECK_WEATHERAPI_API_KEY='your-weatherapi-api-key'
    
  1. Go to FreecurrencyAPI.
  2. Sign up for a free account.
  3. Navigate to your dashboard and copy your API key.
  4. Export your API key by running the following command in your terminal:
    export DECK_FREECURRENCYAPI_API_KEY='your-freecurrencyapi-api-key'
    

This tutorial uses the MCP Inspector which helps you explore and debug MCP servers.

  1. Ensure you have Node.js and npm installed. If needed, download them from https://nodejs.org.

  2. Update npx to the latest version:
     npm install -g npx
    
  3. Then install the Inspector:
     npm install -g @modelcontextprotocol/inspector
    

This tutorial uses Cursor as an MCP client:

  1. Go to the Cursor downloads page.
  2. Download the installer for your operating system.
  3. Install Cursor on your machine.
  4. Launch Cursor and sign in to your account or create a new account.

Configure the first AI MCP Proxy plugin

Let’s configure the first AI MCP Proxy plugin to convert its endpoints to MCP tools. We configure the plugin in conversion-only mode because this instance only converts RESTful API paths into MCP tool definitions. It doesn’t handle incoming MCP requests directly. Later, we’ll aggregate these tools from multiple conversion-only instances using listener-mode plugins.

In this configuration we define tags[] at the plugin level because listener AI MCP Proxy plugin will use them to discover, aggregate, and expose the registered tools.

echo '
_format_version: "3.0"
plugins:
  - name: ai-mcp-proxy
    tags:
    - mcp-tools
    route: mcp-route
    config:
      mode: conversion-only
      tools:
      - description: Get users
        method: GET
        path: "/marketplace/users"
        parameters:
        - name: id
          in: query
          required: false
          schema:
            type: string
          description: Optional user ID
      - description: Get orders for a user
        method: GET
        path: "/marketplace/orders"
        parameters:
        - description: User ID to filter orders
          in: query
          name: userid
          required: true
          schema:
            type: string
' | deck gateway apply -

Configure the second AI MCP Proxy plugin for the WeatherAPI

Step 1: Add an API key using the Request Transformer Advanced plugin

To authenticate to Weather API, we’ll need to configure the Request Transformer Advanced plugin. This plugin modifies outgoing requests before they reach the upstream API. In this example, it automatically appends your WeatherAPI API key to the query string so that all requests are authenticated without needing to manually provide the key each time.

echo '
_format_version: "3.0"
plugins:
  - name: request-transformer-advanced
    route: weather-route
    enabled: true
    config:
      add:
        querystring:
        - key:${{ env "DECK_WEATHERAPI_API_KEY" }}
' | deck gateway apply -

Step 2: Configure the AI MCP Proxy plugin

We can move on to configuring the second AI MCP Proxy plugin. Like the previous marketplace configuration, this instance only converts RESTful paths into tool definitions and doesn’t process MCP requests directly. Again, the tags[] field ensures that listener-mode plugins can later discover and aggregate this tool along with others from the marketplace instance.

echo '
_format_version: "3.0"
plugins:
  - name: ai-mcp-proxy
    tags:
    - mcp-tools
    route: weather-route
    config:
      mode: conversion-only
      tools:
      - description: Get current weather for a location
        method: GET
        path: "/weather"
        parameters:
        - name: q
          in: query
          required: true
          schema:
            type: string
          description: Location query. Accepts US Zipcode, UK Postcode, Canada Postalcode,
            IP address, latitude/longitude, or city name.
' | deck gateway apply -

Configure the third AI MCP Proxy plugin for Free Currency

Step 1: Add an API key using the Request Transformer Advanced plugin

To authenticate requests to the Free Currency API, we use the Request Transformer Advanced plugin again to append the API key to all requests automatically.

echo '
_format_version: "3.0"
plugins:
  - name: request-transformer-advanced
    route: freecurrency-route
    enabled: true
    config:
      add:
        querystring:
        - apikey:${{ env "DECK_FREECURRENCYAPI_API_KEY" }}
' | deck gateway apply -

Step 2: Configure the AI MCP Proxy plugin

As in the previous steps, this AI MCP Proxy instance converts the RESTful paths of FreecurrencyAPI into tool definitions only. They will be aggregated by the listener-mode plugin based on the tags[] field.

echo '
_format_version: "3.0"
plugins:
  - name: ai-mcp-proxy
    route: freecurrency-route
    tags:
    - mcp-tools
    config:
      mode: conversion-only
      tools:
      - description: Get latest exchange rates for one or more currencies
        method: GET
        path: "/currency"
        parameters:
        - name: currencies
          in: query
          required: false
          schema:
            type: string
          description: A comma-separated list of currency codes (e.g., "EUR,USD,CAD").
' | deck gateway apply -

Configure the listener AI MCP Proxy plugin

Now, let’s configure another AI MCP Proxy plugin instance in listener mode to aggregate and expose the tools registered by the conversion-only plugins. The listener plugin discovers tools based on their shared tag value—in this case, mcp-tools—and serves them through an MCP server that AI clients can connect to.

echo '
_format_version: "3.0"
plugins:
  - name: ai-mcp-proxy
    route: listener-route
    config:
      mode: listener
      server:
        tag: mcp-tools
        timeout: 45000
      logging:
        log_statistics: true
        log_payloads: false
      max_request_body_size: 32768
' | deck gateway apply -

Validate the configuration

Run the MCP inspector

First, let’s run the MCP Inspector to see whether our listener AI MCP Proxy plugin properly aggregates all exposed tools.

  1. Execute the following command to run the MCP Inspector:

     npx @modelcontextprotocol/inspector --mcp-url http://localhost:8000/mcp-listener
    
  2. If successful, you should see the following output in your terminal:

     Starting MCP inspector...
     ⚙️ Proxy server listening on localhost:6277
     🔑 Session token: <YOUR_TOKEN>
       Use this token to authenticate requests or set DANGEROUSLY_OMIT_AUTH=true to disable auth
    
     🚀 MCP Inspector is up and running at:
       http://localhost:6274/?MCP_PROXY_AUTH_TOKEN=<YOUR_TOKEN>
    
  3. The script will automatically open a new browser window with MCP Inspector’s UI:

    MCP Inspector's UI

  4. Click the Connect button on the left.

Make sure that you use Streamable HTTP as Transport Type and that the URL points at http://localhost:8000/mcp-listener

  1. In the Tools tile, click the List tools button. You should see the following tools available:

    MCP tools in MCP Inspector

Configure Cursor

  1. Open your Cursor desktop app.

  2. Navigate to Settings in the top right corner.

  3. In the Cursor Settings tab, go to Tools & MCP in the left sidebar.

  4. In the Installed MCP Servers section, click New MCP Server.

  5. Paste the following JSON configuration into the newly opened mcp.json tab:

     {
       "mcpServers": {
           "mcp-listener": {
               "url": "http://localhost:8000/mcp-listener"
           }
       }
     }
    
  6. Return to the Cursor settings tab. You should now see the mcp-listener MCP server with four tools available.

  7. To open a new Cursor chat, click cmd + L if you’re on Mac, or ctrl + L if you’re on Windows.

  8. In the Cursor chat tab, click @ Add Context and select mcp.json.

Validate aggregated MCP tools configuration

You can now test each exposed tool using Cursor.

Something wrong?

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!