MCP-Based Weather Information System

MCP-Based Weather Information System

Provides current weather information for any location and generates AI-powered responses using Google Gemini through FastMCP.

Category
访问服务器

README

MCP-Based Weather Information System

A Python-based project that provides weather information using MCP tools and includes a simple web dashboard for viewing weather details. The project integrates WeatherAPI for live weather data and Google Gemini API for AI-powered responses through FastMCP.


Features

  • MCP Server

  • Retrieves current weather information for any location.

  • Generates AI-powered responses using Google Gemini.

  • Weather Dashboard

  • Provides an interactive and user-friendly interface.

  • Displays weather details for the selected city instantly.


Project Structure

MCP/
├── my_mcp_server.py      # MCP and HTTP server
├── weather_dashboard.py  # Weather dashboard UI
├── weather.html          # Legacy static page
├── .env                  # API keys and setup
└── venv/                 # Virtual environment

Requirements

  • Python 3.10 or higher
  • WeatherAPI API key
  • Google Gemini API key

Installation

1. Create a Virtual Environment

python -m venv venv
.\venv\Scripts\Activate.ps1

2. Install Dependencies

pip install mcp python-dotenv requests google-genai

3. Create a .env File

GOOGLE_API_KEY=your_google_api_key
WEATHER_API_KEY=your_weather_api_key
WEATHER_API_BASE_URL=https://api.weatherapi.com/v1
MCP_SERVER_PORT=8001
HTTP_SERVER_PORT=8002
WEATHER_DASHBOARD_PORT=8080

Running the Weather Dashboard

Start the dashboard:

python weather_dashboard.py

Open:

http://localhost:8080

Steps

  1. Enter a location (e.g., Delhi).
  2. Click the Get Weather button.
  3. View weather details instantly.

Running the MCP Server

Start the server:

python my_mcp_server.py

Health Check

curl http://localhost:8002/health

Example Tool Request

curl -X POST http://localhost:8002/ `
-H "Content-Type: application/json" `
-d '{"tool":"get_current_weather","args":{"location":"London"}}'

Available MCP Tools

Tool Description
get_current_weather Returns current weather information for a location.
generate_gemini_response Generates AI-powered responses using Google Gemini.

Notes

  • Use accurate city names for better results.
  • Keep the .env file secure and private.

Technologies Used

  • Python – Core programming language used for developing the application.
  • FastMCP – Framework used to create and manage MCP tools and services.
  • Requests – Python library used for making HTTP requests to external APIs.
  • Python Dotenv – Used to load environment variables from a .env file.
  • Google Gemini API – Used to generate AI-powered text responses.
  • WeatherAPI – Provides real-time weather data for different locations.
  • HTML, CSS, and JavaScript – Used to create an interactive web interface.

Project Results

Image 1: Weather Dashboard Home Interface

<p align="center"> <img width="492" height="382" src="https://github.com/user-attachments/assets/fda6c3a6-8592-41e6-9ef4-e2faa5ac4517" alt="Image"> </p>

Image 2: Real-Time Weather Information Interface

<p align="center"> <img width="492" height="382" src="https://github.com/user-attachments/assets/0c0dccf4-2883-4533-8772-32f3ad549974" alt="Image"> </p>


推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选