
Security News
npm ‘is’ Package Hijacked in Expanding Supply Chain Attack
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
yujie-weather-mcp-server
Advanced tools
A simple MCP server for weather queries with AI integration
一个简单的 MCP (Model Context Protocol) 服务器,提供天气查询功能并集成AI模型生成友好的天气报告。
cd weather-mcp-server
npm install
npm start
或者使用开发模式(自动重启):
npm run dev
目前支持以下城市(中英文均可):
获取指定城市的天气信息并生成AI增强的天气报告。
参数:
city
(string, 必需): 城市名称示例调用:
{
"name": "get_weather",
"arguments": {
"city": "北京"
}
}
返回示例:
🌤️ 北京 天气报告
今天北京的天气晴天,温度15°C,湿度45%。天气有点凉,建议多穿一件衣服。
📊 详细数据:
• 温度:15°C
• 天气:晴天
• 湿度:45%
@modelcontextprotocol/sdk
实现标准的 MCP 协议替换 WEATHER_DATA
为真实的天气API调用:
async function getWeatherData(city) {
const response = await fetch(`https://api.openweathermap.org/data/2.5/weather?q=${city}&appid=YOUR_API_KEY`);
return await response.json();
}
替换 callAIModel
函数为真实的AI API调用:
async function callAIModel(weatherData, city) {
const response = await fetch('https://api.openai.com/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.OPENAI_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'gpt-3.5-turbo',
messages: [
{
role: 'user',
content: `请根据天气信息生成友好的天气报告:${JSON.stringify(weatherData)}`
}
]
})
});
const data = await response.json();
return data.choices[0].message.content;
}
MIT License
FAQs
A simple MCP server for weather queries with AI integration
We found that yujie-weather-mcp-server demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
Security News
A critical flaw in the popular npm form-data package could allow HTTP parameter pollution, affecting millions of projects until patched versions are adopted.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.