Kushwaha2406Vikash/MCP-Server
3.1
If you are the rightful owner of MCP-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 dayong@mcphub.com.
This document provides a comprehensive summary of the Model Context Protocol (MCP) server designed for fetching weather data based on city names.
I will convert this information into a README.md file.
# 🌦️ MCP Server - Weather Data Fetcher
This project is a **Model Context Protocol (MCP) server** that provides simple weather data based on city names. It demonstrates how to use **Node.js, MCP SDK, and Zod** to build a server and client that communicate over `stdio`.
---
## 📌 Features
- ✅ MCP Server built using `@modelcontextprotocol/sdk`
- ✅ Provides weather details (temperature + forecast) for cities
- ✅ Example: *Noida → 30°C, chance to rain* | *Delhi → 45°C, high temperature*
- ✅ Validates input with **Zod**
- ✅ Includes **client script** for testing
---
## 🛠️ Tech Stack
- **Node.js** (v18+ recommended)
- **MCP SDK** (`@modelcontextprotocol/sdk`)
- **Zod** for schema validation
- **Tested with STDIO client-server transport**
---
## 📂 Project Structure
```yaml
mcpserver/
│── package.json
│── server.js # MCP Server (Weather Data Fetcher)
│── client.js # MCP Client to test requests
│── node_modules/
│── .gitignore
⚙️ Installation
-
Clone the repository:
git clone [https://github.com/your-username/mcpserver.git](https://github.com/your-username/mcpserver.git) cd mcpserver -
Install dependencies:
npm install
🚀 Usage
-
Start the Server
node server.js -
Run the Client
node client.js
📡 Example Output
Request:
{
method: "tools/call",
params: {
name: "getWeatherDataByCityName",
arguments: { city: "Noida" }
}
}
Response:
{
"content": [
{ "type": "text", "text": "{\"temp\":\"30\",\"forecast\":\"chance to rain\"}" }
]
}
🧪 Supported Cities
- Noida →
{ temp: "30", forecast: "chance to rain" } - Delhi →
{ temp: "45", forecast: "high temperature" } - Any other →
{ temp: null, error: "unable to fetch data" }
📜 License
This project is licensed under the ISC License.