Azure Container Apps remote MCP server example

Azure Container Apps remote MCP server example

site icon
2025.04.15 0
Python天气服务实时数据位置服务
Azure-MCP-Server 是一个基于 FastAPI 的 Model Context Protocol (MCP) 服务器,专为 Azure Container Apps 设计。它通过安全的 API 密钥保护的 Server-Sent Events (SSE) 接口提供天气相关的工具(如警报和预报)。该服务器旨在与 MCP 兼容的客户端(如 Visual Studio Code 或自定义脚本)集成。
View on GitHub

Overview

基本能力

产品定位

Azure-MCP-Server 是一个用于提供天气相关服务的 MCP 服务器,适用于需要实时天气数据和警报的应用场景。

核心功能

  • 提供天气警报和预报工具
  • 使用 SSE 传输协议进行通信
  • 通过 API 密钥进行身份验证
  • 支持与 MCP 兼容的客户端集成

适用场景

  • 需要实时天气数据的应用
  • 天气警报系统
  • 天气预报服务

工具列表

  • get_alerts: 获取指定美国州的天气警报
  • get_forecast: 获取指定经纬度的天气预报

常见问题解答

  • ModuleNotFoundError: 确保虚拟环境已激活且依赖已安装。
  • 客户端挂起: 检查服务器是否运行且 API 密钥是否匹配。
  • pip 问题: 运行 python -m ensurepip --upgradepython -m pip install --upgrade pip

使用教程

使用依赖

  • Python 3.11 或更高版本
  • uv

安装教程

  1. 克隆仓库 bash git clone https://github.com/KRVaghani/Azure-MCP-Server.git cd Azure-MCP-Server
  2. 设置虚拟环境和依赖 bash uv venv uv sync
  3. 设置 API 密钥 bash export API_KEYS=devkey # 或您选择的密钥
  4. 运行服务器 bash uv run fastapi dev main.py

调试方式

  • 测试 SSE 端点 bash curl -H "x-api-key: devkey" http://localhost:8000/sse
  • 使用示例客户端 bash python model_request_client.py

许可证

该项目遵循 MIT 开源许可条款。