使用说明
气象MCP服务器
这是一个 气象MCP服务器 其使用模型上下文协议(MCP)提供天气数据。它是用TypeScript构建的,在Node.js上运行。
📌 特性
- 获取和处理天气数据。
- 使用模型上下文协议(MCP)SDK。
- 使用TypeScript构建以实现类型安全。
- 可通过环境变量进行配置。
🛠 安装
1.️⃣ 克隆存储库
git clone https://github.com/your-username/weather-mcp-server.git
cd weather-mcp-server
二️⃣ 安装依赖关系
npm install
3.️⃣ 构建项目
npm run build
4.️⃣ 运行服务器
npm start
或者,您可以直接运行编译后的JavaScript:
node build/index.js
🔧 配置
此项目使用环境变量进行配置。您可以创建 .env 根目录中的文件:
API_KEY=your_weather_api_key
PORT=3000
📝 脚本
| 命令 | 描述 |
|---|---|
npm run build |
将TypeScript编译为JavaScript |
npm start |
运行已编译的服务器 |
npm run lint |
使用ESLint抓取TypeScript文件 |
📁 项目结构
weather-mcp-server/
│── src/
│ ├── index.ts # Main entry point
│── build/ # Compiled JavaScript output
│── package.json # Project dependencies and scripts
│── tsconfig.json # TypeScript configuration
│── .eslintrc.js # ESLint configuration
🐞 故障排除
- 如果
npm run build不产生输出,请检查TypeScript日志:npx tsc --diagnostics - 如果Node.js找不到
index.js,确保build/包含已编译的文件:ls build/ - 如果正在运行 视窗,
chmod将失败package.json.删除chmod 755 build/index.js从构建脚本中。
📜 许可证
该项目根据 ISC许可证.
🔧 由开发 莫伊兹·古曼