Cover image
Try Now
2025-04-14

Python中的天气MCP服务器

3 years

Works with Finder

1

Github Watches

1

Github Forks

0

Github Stars

MCP Server

Weather MCP server in python

docs

python-sdk

# Create a new directory for our project
uv init

# Create virtual environment and activate it
uv venv
source .venv/bin/activate

# Install dependencies
uv add "mcp[cli]" httpx

# Create our server file
touch weather.py

Testing

This project includes a comprehensive test suite for the weather service API. The tests use pytest and pytest-asyncio to test the asynchronous functions that interact with the National Weather Service API.

Test Requirements

  • Python 3.12+
  • pytest
  • pytest-asyncio
  • pytest-cov
  • httpx

Installing Development Dependencies

You can install all development dependencies using:

# Using uv
uv pip install -e ".[dev]"

# Or using pip
pip install -e ".[dev]"

Running the Tests

To run the tests:

# Run all tests
pytest

# Run with verbose output
pytest -v

# Run with code coverage
pytest --cov=weather

Test Coverage

The test suite covers:

  1. Unit Tests for Helper Functions

    • format_alert function for formatting alert data
    • Error handling in make_nws_request
  2. API Function Tests

    • get_alerts: Testing successful retrieval, empty results, and API failures
    • get_forecast: Testing successful forecast retrieval and error handling for both API endpoints
  3. Mock Responses

    • All HTTP requests are mocked using httpx.AsyncMock
    • Multiple test scenarios with different API responses

Continuous Integration

When adding new features to the weather service, please ensure all tests pass by running the test suite before submitting changes.

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • Bora Yalcin
  • Evaluator for marketplace product descriptions, checks for relevancy and keyword stuffing.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • Beniyam Berhanu
  • Therapist adept at identifying core issues and offering practical advice with images.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Lists Tailwind CSS classes in monospaced font

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • huahuayu
  • 统一的API网关,用于将多个Etherscan样区块链Explorer API与对AI助手的模型上下文协议(MCP)支持。

  • deemkeen
  • 用电源组合控制您的MBOT2:MQTT+MCP+LLM

  • jae-jae
  • MCP服务器使用剧作《无头浏览器》获取网页内容。

    Reviews

    1 (1)
    Avatar
    user_38WsqfLR
    2025-04-15

    AzureDevOpsMCP is a remarkable tool for streamlining and managing development projects on Azure. Created by erinnmclaughlin, this product integrates seamlessly into workflows, ensuring efficient and organized project management. I highly recommend AzureDevOpsMCP for anyone looking to enhance their Azure DevOps experience. More details can be found at https://mcp.so/server/AzureDevOpsMCP/erinnmclaughlin.