Cover image
Try Now
2025-04-14

样本Python项目

3 years

Works with Finder

0

Github Watches

0

Github Forks

0

Github Stars

mcp-sample

A Python-based weather application that provides weather alerts and forecasts using the National Weather Service (NWS) API.

Features

  • Get active weather alerts for any US state
  • Get detailed weather forecasts for any location using latitude and longitude within the US
  • Uses official NWS API for accurate and reliable data
  • Runs as an MCP server for seamless integration

Important Note

This application uses the National Weather Service (NWS) API, which only provides weather data for locations within the United States. For international weather data, you would need to modify the application to use a different weather service API.

Installation

This project requires Python 3.10 or higher. To install dependencies:

pip install .

Usage

The application can be used in two ways: as a Python module or as an MCP server.

Using as an MCP Server

The application is designed to run as an MCP server, which allows for seamless integration with MCP clients:

  1. Run the server:
python weather.py
  1. The server exposes two MCP tools:
  • get_alerts: Get weather alerts for a US state

    # Example MCP client usage
    result = await mcp.invoke("get_alerts", {"state": "CA"})
    
  • get_forecast: Get weather forecast for coordinates

    # Example MCP client usage
    result = await mcp.invoke("get_forecast", {
        "latitude": 37.7749,      # San Francisco coordinates
        "longitude": -122.4194
    })
    

Using as a Python Module

You can also import and use the functions directly in your Python code:

Get Weather Alerts

Get active weather alerts for a US state using its two-letter state code:

from weather import get_alerts

# Get alerts for California
alerts = await get_alerts("CA")

print(alerts)

Get Weather Forecast

Get a detailed weather forecast for a specific location using latitude and longitude:

from weather import get_forecast

# Get forecast for San Francisco (approximate coordinates)
forecast = await get_forecast(37.7749, -122.4194)
print(forecast)

The forecast includes:

  • Temperature
  • Wind conditions
  • Detailed forecast description
  • 5-period forecast (typically covering the next few days)

API Details

The application uses the National Weather Service (NWS) API. No API key is required, but we include a User-Agent header as per API requirements. The API only provides data for locations within the United States.

相关推荐

  • av
  • 毫不费力地使用一个命令运行LLM后端,API,前端和服务。

  • 1Panel-dev
  • 🔥1Panel提供了直观的Web接口和MCP服务器,用于在Linux服务器上管理网站,文件,容器,数据库和LLMS。

  • WangRongsheng
  • 🧑‍🚀 llm 资料总结(数据处理、模型训练、模型部署、 o1 模型、mcp 、小语言模型、视觉语言模型)|摘要世界上最好的LLM资源。

  • sigoden
  • 使用普通的bash/javascript/python函数轻松创建LLM工具和代理。

  • hkr04
  • 轻巧的C ++ MCP(模型上下文协议)SDK

  • rulego
  • ⛓️Rulego是一种轻巧,高性能,嵌入式,下一代组件编排规则引擎框架。

  • RockChinQ
  • 😎简单易用、🧩丰富生态 -大模型原生即时通信机器人平台| 适配QQ / 微信(企业微信、个人微信) /飞书 /钉钉 / discord / telegram / slack等平台| 支持chatgpt,deepseek,dify,claude,基于LLM的即时消息机器人平台,支持Discord,Telegram,微信,Lark,Dingtalk,QQ,Slack

  • dmayboroda
  • 带有可配置容器的本地对话抹布

  • paulwing
  • 使用MCP服务创建的测试存储库

    Reviews

    3.4 (8)
    Avatar
    user_5XWIEwlJ
    2025-04-24

    I recently tried the mcp-sample and I'm genuinely impressed! The product, crafted by TomShlaim, showcases impeccable design and functionality. It seamlessly integrates and performs beyond expectations. Highly recommend for those in search of reliability and efficiency. A must-have in your tech arsenal!

    Avatar
    user_xmq2PmpE
    2025-04-24

    I have been using the mcp-sample for a while now and I must say, it's incredibly efficient and user-friendly. TomShlaim has done an excellent job with this product. Navigating through the interface is a breeze and the features provide great value. I highly recommend it to anyone looking for a reliable solution.

    Avatar
    user_Q06K1ssh
    2025-04-24

    I've been using mcp-sample created by TomShlaim for a while now, and it has significantly enhanced my productivity. The tool is intuitive and straightforward to use, making my tasks easier to manage. The initial setup through the provided URL was seamless, and the welcome information was clear and helpful. Overall, I highly recommend mcp-sample to anyone looking for an efficient productivity application!

    Avatar
    user_OifWnsB7
    2025-04-24

    As an avid user of the mcp application, I am thoroughly impressed with the mcp-sample by TomShlaim. The intuitive design and seamless functionality truly set it apart. This product has significantly optimised my workflow and provided exceptional value. Highly recommended for anyone seeking a reliable and efficient solution!

    Avatar
    user_u8ECjxEK
    2025-04-24

    As a dedicated user of MCP, I find the mcp-sample by TomShlaim to be a valuable resource. This product offers a streamlined experience with its clear instructions and user-friendly interface. Highly recommended for anyone looking to utilize MCP effectively!

    Avatar
    user_LEGiXBhW
    2025-04-24

    As a dedicated user of the mcp application, I am thoroughly impressed with mcp-sample by TomShlaim. This tool stands out due to its remarkable efficiency and user-friendly interface. Navigating through its features is seamless, thanks to the intuitive design. The application's performance consistently meets my expectations, making it an invaluable resource for my daily tasks. Highly recommended for anyone seeking reliability and ease of use!

    Avatar
    user_8C9TW5Jg
    2025-04-24

    As a loyal user of the mcp-sample, I can confidently say that it's an outstanding product by TomShlaim. The seamless integration and user-friendly interface make it one of the best in its category. The attention to detail and consistent updates reflect the dedication of the author. Highly recommended for anyone looking for a reliable solution!

    Avatar
    user_6okCNSXg
    2025-04-24

    I have been using the mcp-sample by TomShlaim, and I am thoroughly impressed with its functionality. The user-friendly interface and efficient performance have greatly simplified my workflow. I highly recommend this product to anyone looking for a reliable solution in this category. The welcome message is a nice touch, creating an inviting experience from the start. Overall, an excellent tool that meets my needs perfectly!