Weather API MCP Server

Weather API MCP Server

Single-file HTTP MCP Server for WeatherAPI.com to get current weather, forecasts, and location data. Supports bearer token authentication and exposes MCP tools for weather data retrieval.

Category
Visit Server

README

Weather API MCP Server

Single-file HTTP MCP Server for WeatherAPI.com to get current weather, forecasts, and location data, powered by Bun.

  • Bearer token authentication – uses your WeatherAPI.com API key via Authorization header
  • Current weather data – get real-time weather conditions for any location
  • Weather forecasting – get 1-3 day weather predictions
  • Location search – find and validate location names
  • Single file implementation – complete MCP server in simple-mcp-server.ts
  • All capabilities are exposed as MCP tools over a Bun HTTP server

💡 Don't have Bun? Install it from https://bun.com/

🏗️ Built With

This single-file MCP server uses:

  • Bun's built-in HTTP server - Ultra-fast native HTTP handling with zero dependencies
  • Zod - TypeScript-first schema validation for bulletproof input validation
  • WeatherAPI.com - RESTful API for weather data and forecasts
  • Native fetch - Built-in HTTP client for API calls

🔐 Authentication

This MCP server uses Bearer token authentication with your WeatherAPI.com API key:

Authorization Header Authentication

Include your WeatherAPI.com API key in the Authorization header:

Authorization: Bearer your-weatherapi-key-here

MCP Client Integration

When adding this MCP server to MCP clients (Cursor, Claude Desktop, etc.):

  1. Server URL: http://localhost:3000/mcp
  2. Headers: Add Authorization header with your API key:
    {
      "Authorization": "Bearer your-weatherapi-key-here"
    }
    

Connecting to Cursor

Cursor is an excellent MCP client that can integrate with this weather API MCP server. Here's how to set it up:

1. Configure Cursor's MCP Settings

Create or edit your Cursor MCP configuration file at ~/.cursor/mcp.json:

{
  "mcpServers": {
    "weather": {
      "type": "http",
      "url": "http://localhost:3000/mcp",
      "headers": {
        "Authorization": "Bearer your-weatherapi-key-here"
      }
    }
  }
}

Important: Replace your-weatherapi-key-here with your actual WeatherAPI.com API key.

2. Start Your MCP Server

In a terminal, start the weather API MCP server:

cd weather-api-mcp-server
bun run simple-mcp-server.ts

The server will start on http://localhost:3000/mcp.

3. Restart Cursor

After updating the MCP configuration, restart Cursor completely for the changes to take effect.

4. Verify Connection

Once connected, you can ask Cursor to use the weather tools:

  • "What's the current weather in London?"
  • "Get a 3-day forecast for Tokyo"
  • "Search for locations named Springfield"

Cursor will automatically use the appropriate MCP tool from your weather server to fetch the data.

5. Troubleshooting

If the connection fails:

  1. Check server status: Ensure your MCP server is running on port 3000
  2. Verify API key: Make sure your WeatherAPI.com API key is correct
  3. Check Cursor logs: Look for MCP connection errors in Cursor's developer console
  4. Test manually: Use the MCP Inspector to verify your server works independently

Getting Your API Key

  1. Sign up for free at WeatherAPI.com
  2. Verify your email address
  3. Copy your API key from the dashboard
  4. Use it in the Authorization header as shown above

✨ Features

Capability WeatherAPI.com endpoint
Get current weather GET /v1/current.json with location parameter
Get weather forecast GET /v1/forecast.json with location and days
Search for locations GET /v1/search.json with query parameter

🗂 Repo layout

.
├─ simple-mcp-server.ts    # Complete single-file MCP server
├─ package.json            # Dependencies (bun, zod)
├─ tsconfig.json          # TypeScript configuration
└─ README.md              # This file

The entire MCP server is implemented in a single TypeScript file (simple-mcp-server.ts) that handles WeatherAPI.com integration.


⚙️ Prerequisites

  1. WeatherAPI.com API key

  2. Bun ≥ 1.2.2 installed locally.


🌍 Configuration

Name Example Required Description
PORT 3000 Server port (defaults to 3000)

🔑 Authentication: API key provided via Authorization header only - no environment variables needed!


🧪 Development & Testing

You can use the official MCP Inspector to interactively test this server.

  1. Start the server in one terminal:

    bun run simple-mcp-server.ts
    
  2. Run the inspector in another terminal:

    npx @modelcontextprotocol/inspector http://localhost:3000/mcp
    
  3. Add your API key in the inspector's headers section:

    {
      "Authorization": "Bearer your-weatherapi-key-here"
    }
    

This will launch a web UI where you can see all available tools and manually trigger them with different parameters.

▶️ Running locally

# Install Bun (if you don't have it)
curl -fsSL https://bun.sh/install | bash

# Install deps
bun install

# Run server on port 3000
bun run simple-mcp-server.ts

Send a request with curl if you feel like it:

curl -X POST "http://localhost:3000/mcp" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-weatherapi-key-here" \
  -d '{
        "jsonrpc": "2.0",
        "id": 1,
        "method": "tools/call",
        "params": {
          "name": "getCurrentWeather",
          "arguments": {
            "location": "London"
          }
        }
      }'

Additional endpoints

Route Method Purpose
/healthz GET/HEAD Simple health-check (returns 200 OK)

All responses include Access-Control-Allow-Origin: * so the MCP can be called from a browser without extra CORS configuration.


🛠️ MCP tool set

Tool Purpose Input → Output
getCurrentWeather get current weather conditions { location } → current weather data
getWeatherForecast get weather forecast { location, days? } → forecast data (1-3 days)
searchLocations find location names { query } → array of matching locations

🔍 Parameters:

  • location: City name, ZIP code, coordinates (lat,lon), or IP address
  • days: Number of forecast days (1-3, defaults to 3)
  • query: Search term for location names (partial matches work)

📊 Response Data:

  • Current weather: Temperature, conditions, humidity, wind, feels-like temperature
  • Forecast: Daily high/low temperatures, conditions, precipitation chance
  • Location data: Resolved location name, country, coordinates, timezone

Then use the Authorization header in your requests:

Authorization: Bearer your-weatherapi-key-here

Usage Examples

Current Weather:

# Get current weather for London
{ "location": "London" }

# Use coordinates
{ "location": "40.7128,-74.0060" }

# Use ZIP code
{ "location": "10001" }

Weather Forecast:

# 3-day forecast (default)
{ "location": "Tokyo" }

# 1-day forecast
{ "location": "Paris", "days": 1 }

# 2-day forecast
{ "location": "Sydney", "days": 2 }

Location Search:

# Find cities named "Springfield"
{ "query": "Springfield" }

# Partial match
{ "query": "Albuquer" }

# International locations
{ "query": "München" }

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured