Autogenerate MCP tools for Weather API

Incompatible with
konnect
Related Resources
Minimum Version
Kong Gateway - 3.12
TL;DR

Use the AI MCP Proxy plugin to map WeatherAPI endpoints into MCP tools, allowing AI agents in Cursor to query current weather.

Prerequisites

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: weather-service
        url: https://api.weatherapi.com/v1/current.json
    routes:
      - name: weather-route
        paths:
        - "/weather"
        service:
          name: weather-service
    ' | deck gateway apply -
    

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

  1. Go to WeatherAPI.
  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_WEATHERAPI_API_KEY='your-weatherapi-api-key'
    
  1. Go to the Cursor downloads page.
  2. Download and install Cursor for your OS.
  3. Launch Cursor and sign in or create an account.

Add an API key using the Request Transformer Advanced plugin

First, we’ll 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 -

Configure the AI MCP Proxy plugin

We can move on to configuring the AI MCP Proxy plugin. This setup exposes the upstream WeatherAPI endpoint as an MCP tool, enabling our AI client, Cursor, to call it directly.

In this configuration, we also define the tool along with its parameters—including the configured API key—so that the MCP client can make tool calls for our weather queries.

echo '
_format_version: "3.0"
plugins:
  - name: ai-mcp-proxy
    route: weather-route
    config:
      mode: conversion-listener
      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.
      server:
        timeout: 60000
' | deck gateway apply -

Configure Cursor

  1. Open your Cursor desktop app.

  2. Navigate to Cursor > Settings.

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

  4. In the MCP Tools section, click Add Custom MCP.

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

     {
       "mcpServers": {
           "weather": {
               "url": "http://localhost:8000/weather"
           }
       }
     }
    
  6. Return to the Cursor settings tab. You should now see the weather MCP server with one tool available:

    Tools exposed in Cursor

  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:

Add context in Cursor chat

Validate MCP tools configuration

Enter the following question in the Cursor chat:

What is the current weather in London?

You will notice that Cursor makes a tool call to the WeatherAPI tools we exposed through the AI MCP Proxy plugin:

I'll fetch the current weather for London.
> Called weather-route-1

When the agent finishes reasoning, you should see the following response in Cursor:

London weather (now)
- Condition: Overcast
- Temperature: 17.2°C (63.0°F)
- Feels like: 17.2°C (63.0°F)
- Wind: 14.8 kph NE (gusts 18.8 kph)
- Humidity: 83%
- Pressure: 1016 mb
- Visibility: 10 km
- UV index: 0.1
- Updated: 2025-08-19 07:45 (Europe/London)
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!