yashraj-dudhe/mcp-weather-server
If you are the rightful owner of mcp-weather-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The MCP Weather Server is a TypeScript-based server providing real-time weather information through the Model Context Protocol (MCP).
get_current_weather
Fetches current weather data for a specified city.
MCP Weather Server
Overview
The MCP Weather Server is a TypeScript-based server that provides current weather information through the Model Context Protocol (MCP). It exposes a weather resource and a tool to fetch current weather data, allowing LLM applications to interact with real-time weather information.
Features
- Weather Resource: Exposes current weather data for a specified city.
- Fetch Current Weather Tool: Allows users to retrieve the current weather by providing a city name.
- LLM Interaction: Optional prompts for enhanced interaction with the weather data.
Installation
-
Clone the repository:
git clone <repository-url> cd mcp-weather-server
-
Install dependencies:
npm install
-
Create a
.env
file based on the.env.example
template and add your weather API key:WEATHER_API_KEY=your_api_key_here
Usage
To start the MCP Weather Server, run the following command:
npm start
The server will listen for incoming requests and provide weather information based on the registered resource and tool.
API Endpoints
Weather Resource
- URI:
weather://{city_name}
- Description: Retrieves current weather data for the specified city.
Fetch Current Weather Tool
- Tool Name:
get_current_weather
- Input:
city_name
: The name of the city for which to fetch the weather.
- Output: Returns the current weather data in the following format:
city_name
: Name of the citytemperature_celsius
: Current temperature in Celsiustemperature_fahrenheit
: Current temperature in Fahrenheitcondition
: Weather condition (e.g., sunny, rainy)humidity
: Current humidity percentage
Example
To fetch the current weather for New York City, you can use the following tool call:
const weather = await client.callTool({
name: "get_current_weather",
arguments: { city_name: "New York" }
});
Contributing
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
License
This project is licensed under the MIT License. See the LICENSE file for details.