这是一个基于命令行和MCP(MindSpire Command Protocol)的天气应用程序,能提供全球任意地点的当前天气状况、预报及警报信息,让你随时随地掌握天气动态。
运行天气应用,只需执行以下命令:
./scripts/run_weather.sh
这将启动MCP服务器,提供一系列实用工具,如获取当前天气、预报、警报等。
git clone
cd weather-app
.env文件,并添加您的OpenWeatherMap API密钥:OPENWEATHER_API_KEY=your_api_key_here
您可以从此处获取API密钥:OpenWeatherMap。 3. 运行安装脚本:
./scripts/install.sh
用于开发环境时,请使用:
./scripts/install.sh --dev
运行以下命令启动MCP服务器后,可使用以下工具:
./scripts/run_weather.sh
get_current_weather:获取当前天气状况get_forecast:获取每日天气预报get_hourly_forecast:获取逐小时天气预报get_alerts:获取天气警报get_weather_by_coordinates:按坐标获取天气get_user_location:获取您的当前位置test_api_connection:测试API连接状态check_api_key_and_subscription:检查API密钥及订阅信息该项目使用以下工具确保代码质量:
我们使用预提交钩确保代码质量。安装开发依赖后,钩子会自动设置。 要手动安装预提交钩:
uv run pre-commit install
要手动运行所有钩子:
uv run pre-commit run --all-files
运行测试:
./scripts/run_tests.sh
带覆盖率运行:
./scripts/run_tests.sh --coverage
运行集成测试(需要API密钥):
./scripts/run_tests.sh --integration
带覆盖率的集成测试:
./scripts/run_tests.sh --integration --coverage
使用此项目作为模板创建自己的MCP服务器:
./scripts/install.sh --dev
from mindspire_protocol import MCPProtocol
# 按照需求实现具体的业务逻辑
class MyMCPServer:
def handle_command(self, command: str) -> str:
# 实现具体的命令处理逻辑
pass
if __name__ == "__main__":
server = MyMCPServer()
mcp_protocol = MCPProtocol(server)
mcp_protocol.start_listening()
该项目遵循MIT License协议。