天气查询服务

一个基于MCP协议的天气查询服务器,提供城市天气信息获取功能。

  • by upxill
  • Python
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 upxill/langchain-mcp-weather-server

使用说明

MCP Weather Server

A Model Context Protocol (MCP) server that provides weather information tools accessible via the streamable-http transport.

Overview

This MCP weather server provides a simple weather lookup tool that can be used by MCP clients to get weather information for any city.

The server runs on port 8081 using the streamable-http transport protocol.

Prerequisites

  • Python 3.13+

Installation

uv sync

Running

uv run main.py

The server will start on http://localhost:8081/mcp and wait for MCP client connections.

Architecture

  • FastMCP: Simplified MCP server framework
  • streamable-http: Transport protocol for server-client communication
  • Tool Definitions: Weather lookup tool exposed as an MCP tool

API Endpoints

The server provides a streamable-http endpoint at:

http://localhost:8081/mcp

Tools

get_weather(city: str) -> str

Returns weather information for a given city.

Parameters:

  • city (str): The name of the city to get weather for

Returns:

  • Weather information as a string

Example:

get_weather("New York")
# Returns: "The weather in New York is sunny."

Dependencies

  • mcp: Model Context Protocol library
  • fastmcp: Simplified MCP server framework