MCP Weather Server logo

MCP Weather Server

by mohaimenhasan

A simple Model Context Protocol (MCP) server providing weather data via an Express API. It allows users to retrieve weather information for specific cities.

View on GitHub

Last updated: N/A

MCP Weather Server

A simple Model Context Protocol (MCP) server providing weather data via an Express API.

Prerequisites

  • Node.js (>= 18.x)
  • npm (>= 9.x)

Installation

  1. Clone the repository:

    git clone https://github.com/mohaimenhasan/mcp-weather-server.git
    cd mcp-weather-server
    
  2. Install dependencies:

    npm install
    

Configuration

  • Add an API key in index.ts - line 6. Get your api key from openweathermap. If you need one PM me - (@mohaimenhasan)

Build

Before using this MCP server in VS Code or deploying it, you must compile the TypeScript sources:

npm run build

This will produce a dist/ folder containing the compiled JavaScript.

Integrating with VS Code

Before opening this project in VS Code as an MCP server:

  1. Run:
    npm run build
    
  2. Go to VSCode. Add a MCP server, inside the servers: {} block as following:
"weather-mcp": 
{
    "type": "stdio",
    "command": "node",
    "args": [
        "C:\\<PATH_TO_YOUR_REPO>\\mcp-weather-server\\dist\\index.js"
    ]
}
  1. Go ahead and ask a question about your fave cities weather.

API Endpoints

  • GET /weather?location={city}: Returns current weather data for the specified city.

License

MIT