We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Alexliu13483/weather_mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
Weather MCP - 專案結構
═══════════════════════════════════════════════════════════════
weather_mcp/
│
├── 📂 src/weather_mcp/ 核心套件
│ ├── __init__.py 套件初始化與公開 API
│ ├── server.py MCP 伺服器 (FastMCP)
│ ├── client.py MCP 客戶端
│ ├── tools.py LangChain 工具包裝
│ ├── agent.py React Agent 整合
│ └── visualization.py 資料視覺化
│
├── 📂 examples/ 使用範例
│ └── simple_usage.py 5 個範例函數
│
├── 📂 tests/ 單元測試 (15 測試)
│ ├── test_client.py 客戶端測試 (7 個)
│ └── test_visualization.py 視覺化測試 (8 個)
│
├── 📂 docs/ 文件
│ ├── QUICKSTART.md 快速開始指南
│ └── TESTING.md 測試指南
│
├── 📄 main.py 主程式 (5 種模式)
├── 📄 requirements.txt 依賴套件
├── 📄 pyproject.toml 專案配置
├── 📄 pytest.ini 測試配置
├── 📄 .env.example 環境變數範本
├── 📄 .gitignore Git 忽略規則
├── 📄 LICENSE MIT 授權
├── 📄 README.md 專案說明
├── 📄 PROJECT_SUMMARY.md 專案摘要
└── 📄 STRUCTURE.txt 本檔案
═══════════════════════════════════════════════════════════════
核心模組說明
───────────────────────────────────────────────────────────────
🔧 server.py (130 行)
• MCP 伺服器實作
• 3 個工具:geocode_city, get_weather, get_alerts
• FastMCP + stdio 協定
• Open-Meteo API 整合
🔌 client.py (180 行)
• MCP 客戶端
• 異步操作支援
• Timeout 與錯誤處理
• Jupyter 環境相容 (nest_asyncio)
🛠️ tools.py (140 行)
• LangChain StructuredTool 包裝
• 4 個工具:geocode, weather, alerts, city_weather
• Pydantic 輸入驗證
• JSON 序列化
🤖 agent.py (180 行)
• LangChain React Agent
• Google Gemini 2.5 Flash 整合
• 中英文城市名稱對照
• 自然語言查詢
📊 visualization.py (240 行)
• Matplotlib 圖表
• 4 種圖表類型
• 統計摘要功能
• Pandas 資料處理
═══════════════════════════════════════════════════════════════
執行模式
───────────────────────────────────────────────────────────────
1. 互動模式 python main.py --mode interactive
2. 客戶端測試 python main.py --mode client
3. Agent 測試 python main.py --mode agent
4. 視覺化測試 python main.py --mode viz
5. MCP 伺服器 python main.py --mode server
═══════════════════════════════════════════════════════════════
測試覆蓋
───────────────────────────────────────────────────────────────
✅ 15/15 測試通過 (100%)
⏱️ 執行時間: ~2.4 秒
客戶端測試 (7):
• 初始化測試 (預設、自訂)
• 伺服器腳本查找
• 異步工具呼叫
• 事件迴圈管理
• 城市名稱翻譯
視覺化測試 (8):
• 初始化與配置
• 資料準備
• 4 種圖表類型
• 統計摘要
═══════════════════════════════════════════════════════════════
程式碼統計
───────────────────────────────────────────────────────────────
核心模組: ~870 行
測試程式碼: ~150 行
範例程式碼: ~200 行
文件: ~800 行
───────────────────────────────────
總計: ~2020 行
═══════════════════════════════════════════════════════════════
依賴套件
───────────────────────────────────────────────────────────────
核心:
• mcp >= 1.0.0
• fastmcp >= 0.3.0
LangChain:
• langchain >= 0.1.0
• langchain-google-genai >= 1.0.0
• langgraph >= 0.0.40
資料處理:
• pandas >= 2.0.0
• matplotlib >= 3.7.0
• requests >= 2.31.0
工具:
• nest-asyncio >= 1.5.0
• pydantic >= 2.0.0
開發:
• pytest >= 7.4.0
• pytest-asyncio >= 0.21.0
═══════════════════════════════════════════════════════════════