Weather Query MCP Server

Integrations

  • Used for loading environment variables from a .env file, enabling secure configuration of API keys and other settings.

  • Supports repository cloning and version control for installation and deployment of the weather query service.

  • Integrates with OpenAI to process weather queries, requiring an API key for authentication to access weather information services.

天气查询 MCP 服务器/客户端示例

该项目是一个天气查询客户端,它与 MCP(模型客户端协议)服务器交互以获取并显示指定城市的天气信息。

特征

  • 连接到 MCP 服务器以列出可用的工具。
  • 查询指定城市的天气信息。
  • 显示格式化的天气信息,包括温度、湿度、风速和天气描述。

要求

  • Python 3.8+
  • openai
  • dotenv
  • mcp

设置

  1. 克隆存储库:
    git clone <repository_url> cd <repository_directory>
  2. 创建虚拟环境并激活它:
    python -m venv .venv source .venv/bin/activate # On Windows use `.venv\Scripts\activate`
  3. 安装所需的依赖项:
    pip install -r requirements.txt
  4. 在根目录中创建一个.env文件并添加您的 OpenAI API 密钥和其他配置:
    OPENAI_API_KEY=<your_openai_api_key> BASE_URL=<your_base_url> MODEL=<your_model>

用法

  1. 启动 MCP 服务器:
    python server.py
  2. 运行客户端并连接服务器:
    python client.py <path_to_server_script>
  3. 与客户互动:
    • 输入英文城市名称即可获取天气信息。
    • 输入quit退出客户端。

项目结构

  • server.py :包含 MCP 服务器实现和天气查询工具。
  • client.py :包含与服务器交互的 MCP 客户端实现。
  • .env :API 密钥和配置的环境变量。
  • .gitignore :指定 git 要忽略的文件和目录。
  • README.md :项目文档。

执照

该项目已获得 MIT 许可。

-
security - not tested
F
license - not found
-
quality - not tested

MCP 服务器实现允许用户获取和显示指定城市的天气信息,包括温度、湿度、风速和天气描述。

  1. Features
    1. Requirements
      1. Setup
        1. Usage
          1. Project Structure
            1. License
              ID: 11ak0zv1vd