天气新闻助手

一个基于Azure OpenAI和MCP服务器的天气和新闻查询工具,提供实时天气和最新新闻信息。

  • by edgarkirk
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 edgarkirk/ai-school-mcp

使用说明

天气与新闻助理

使用Azure OpenAI、MCP服务器和Streamlit回答有关当前天气和最新新闻的问题。

设置

创建 .env:

DIAL_API_KEY=your_key_here
AZURE_ENDPOINT=https://ai-proxy.lab.epam.com
API_VERSION=2023-08-01-preview
MODEL=gpt-4o

安装依赖项:

pip install mcp[cli] streamlit requests python-dotenv openai

运行:

PYTHONPATH=src streamlit run src/clients/assistant/main.py

码头工人

docker build -t weather-news-assistant .
docker run --network host --env-file .env weather-news-assistant

打开http://localhost:8501

建筑

Streamlit UI
    │
    ▼
Orchestrator  ──►  Azure OpenAI (tool selection + weather narration)
    │
    ├──► MCP stdio ──► servers/weather  ──► Open-Meteo API
    └──► MCP stdio ──► servers/news     ──► Google News RSS

项目结构

src/
├── servers/
│   ├── weather/main.py      # MCP server — Open-Meteo API
│   ├── news/main.py         # MCP server — Google News RSS
│   ├── orchestrator.py      # Agent — LLM tool calling via MCP
│   └── prompts.py           # System prompt
└── clients/
    └── assistant/
        └── main.py          # Streamlit UI

工具

工具 说明
get_current_weather(city) 当前温度、条件、风
get_weather_forecast(city, days) 每日预报长达7天
get_latest_news(category) 按类别分列的标题
search_news(query) 关键词新闻搜索

备注

  • 需要EPAM VPN才能访问Azure OpenAI
  • 天气和新闻不需要API密钥