Skip to main content
Glama

MCP Weather Server

基于 SSE 的MCP服务器和客户端

这演示了基于 SSE 的 MCP 服务器和使用其工具的独立 MCP 客户端的工作模式。基于此处的原始讨论。

用法

注意:确保在.env中或作为环境变量提供ANTHROPIC_API_KEY

uv run weather.py uv run client.py http://0.0.0.0:8080/sse
Initialized SSE client... Listing tools... Connected to server with tools: ['get_alerts', 'get_forecast'] MCP Client Started! Type your queries or 'quit' to exit. Query: whats the weather like in Spokane? I can help you check the weather forecast for Spokane, Washington. I'll use the get_forecast function, but I'll need to use Spokane's latitude and longitude coordinates. Spokane, WA is located at approximately 47.6587° N, 117.4260° W. [Calling tool get_forecast with args {'latitude': 47.6587, 'longitude': -117.426}] Based on the current forecast for Spokane: Right now it's sunny and cold with a temperature of 37°F and ...

为什么?

这意味着 MCP 服务器现在可以是一个正在运行的进程,代理(客户端)可以随时随地连接、使用和断开连接。换句话说,基于 SSE 的服务器和客户端可以是解耦的进程(甚至可能位于解耦的节点上)。这与基于 STDIO 的模式(客户端本身会将服务器作为子进程生成)不同,并且更适合“云原生”用例。

通过 Smithery 安装

要通过Smithery自动为 Claude Desktop 安装基于 SSE 的服务器和客户端:

npx -y @smithery/cli install @sidharthrajaram/mcp-sse --client claude

服务器

weather.py是一个基于 SSE 的 MCP 服务器,它提供了一些基于国家气象局 API 的工具。改编自 MCP 文档中的示例 STDIO 服务器实现。

默认情况下,服务器在 0.0.0.0:8080 上运行,但可以使用命令行参数进行配置,例如:

uv run weather.py --host <your host> --port <your port>

客户

client.py是一个 MCP 客户端,用于连接并使用基于 SSE 的 MCP 服务器的工具。代码改编自 MCP 文档中STDIO 客户端的示例实现。

默认情况下,客户端连接到命令行参数中提供的 SSE 端点,例如:

uv run client.py http://0.0.0.0:8080/sse
-
security - not tested
F
license - not found
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

这个基于 SSE 的 MCP 服务器允许用户连接并与国家气象局 API 交互以检索天气警报和预报。

  1. 用法
    1. 为什么?
      1. 通过 Smithery 安装
      2. 服务器
      3. 客户

    Related MCP Servers

    • -
      security
      F
      license
      -
      quality
      This is a Model Context Protocol (MCP) server that provides weather information using the National Weather Service (NWS) API. Features Get weather alerts for a US state Get weather forecast for a specific location (using latitude and longitude)
      Last updated -
      Python
      • Linux
      • Apple
    • A
      security
      A
      license
      A
      quality
      An MCP server that provides real-time weather information including temperature, humidity, wind speed, and sunrise/sunset times through the OpenWeatherMap API.
      Last updated -
      1
      Python
      MIT License
      • Linux
      • Apple
    • -
      security
      F
      license
      -
      quality
      An MCP server implementation that allows users to fetch and display weather information for specified cities, including temperature, humidity, wind speed, and weather descriptions.
      Last updated -
      Python
      • Linux
      • Apple
    • -
      security
      A
      license
      -
      quality
      An MCP server that connects to OpenWeatherMap's API to provide current weather data and multi-day forecasts for locations worldwide in different measurement units.
      Last updated -
      12
      TypeScript
      MIT License

    View all related MCP servers

    MCP directory API

    We provide all the information about MCP servers via our MCP API.

    curl -X GET 'https://glama.ai/api/mcp/v1/servers/sidharthrajaram/mcp-sse'

    If you have feedback or need assistance with the MCP directory API, please join our Discord server