MCP Weather Server
Enables users to search for location coordinates, retrieve current weather data, and stream real-time weather updates using the Open-Meteo API. Supports location search by city name and provides detailed weather information including temperature, wind speed, and weather conditions.
README
MCP Weather Server
A streamable HTTP MCP (Model Context Protocol) server for getting weather data via the Open-Meteo API.
🚀 Features
- Streamable HTTP Transport: Compatible with MCP 2025-03-26 specification
- Session Management: Support for persistent sessions with unique IDs
- Weather Tools: Three main tools for geolocation and weather data
- REST API: Health endpoint for monitoring
📦 Installation
# Clone and install dependencies
npm install
# Compile TypeScript
npm run build
# Start the server
npm start
🔧 Configuration
The server uses the following environment variables:
PORT: Listening port (default: 3000)
Example:
PORT=8080 npm start
🛠️ Available MCP Tools
1. search_location
Search for GPS coordinates of a city or location by name.
Parameters:
city_name(string): Name of the city or location to search forcountry(string, optional): Country name to narrow the searchlimit(number, optional): Maximum number of results to return (default: 5, max: 10)
Example response:
{
"query": "Paris",
"country_filter": null,
"total_results": 5,
"locations": [
{
"name": "Paris",
"country": "France",
"admin1": "Île-de-France",
"latitude": 48.8566,
"longitude": 2.3522,
"timezone": "Europe/Paris",
"population": 2161000,
"elevation": 42
},
{
"name": "Paris",
"country": "United States",
"admin1": "Texas",
"latitude": 33.6609,
"longitude": -95.5555,
"timezone": "America/Chicago",
"population": 25171,
"elevation": 177
}
]
}
2. get_weather
Get current weather information for a location.
Parameters:
latitude(number): Latitude in decimal degrees (-90 to 90)longitude(number): Longitude in decimal degrees (-180 to 180)location_name(string, optional): Optional location name for display
Example response:
{
"location": "Paris",
"weather": {
"current_weather": {
"temperature": 15.2,
"windspeed": 10.5,
"winddirection": 230,
"weathercode": 1,
"is_day": 1,
"time": "2024-01-15T14:00"
},
"current_units": {
"temperature": "°C",
"windspeed": "km/h",
"winddirection": "°",
"weathercode": "wmo code",
"is_day": "",
"time": "iso8601"
}
},
"lastUpdate": "2024-01-15T14:05:30.123Z"
}
3. stream_weather
Start streaming weather data with periodic updates.
Parameters:
latitude(number): Latitude in decimal degrees (-90 to 90)longitude(number): Longitude in decimal degrees (-180 to 180)location_name(string, optional): Optional location name for displayinterval_seconds(number, default: 60): Update interval in seconds
🌐 HTTP Endpoints
Server Health
GET /health
Returns server status:
{
"status": "OK",
"timestamp": "2024-01-15T14:05:30.123Z"
}
MCP Endpoint
POST /mcp
GET /mcp
DELETE /mcp
Main endpoint for MCP communications. Supports:
POST: Initialization and request sendingGET: SSE stream establishment for responsesDELETE: Session termination
📋 Usage Example with MCP Client
1. Session Initialization
const initRequest = {
jsonrpc: '2.0',
id: 1,
method: 'initialize',
params: {
protocolVersion: '2024-11-05',
capabilities: { tools: {} },
clientInfo: { name: 'weather-client', version: '1.0.0' }
}
};
const response = await fetch('http://localhost:8080/mcp', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json, text/event-stream'
},
body: JSON.stringify(initRequest)
});
const sessionId = response.headers.get('mcp-session-id');
2. List Available Tools
const listToolsRequest = {
jsonrpc: '2.0',
id: 2,
method: 'tools/list',
params: {}
};
const response = await fetch('http://localhost:8080/mcp', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json, text/event-stream',
'mcp-session-id': sessionId
},
body: JSON.stringify(listToolsRequest)
});
3. Call Weather Tool
const weatherRequest = {
jsonrpc: '2.0',
id: 3,
method: 'tools/call',
params: {
name: 'get_weather',
arguments: {
latitude: 48.8566,
longitude: 2.3522,
location_name: 'Paris'
}
}
};
const response = await fetch('http://localhost:8080/mcp', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json, text/event-stream',
'mcp-session-id': sessionId
},
body: JSON.stringify(weatherRequest)
});
🧪 Testing
To test the server:
# Start the server
PORT=8080 npm start
# In another terminal, test the health endpoint
curl http://localhost:8080/health
🔍 Using MCP Inspector
You can use the official MCP Inspector to visually explore and test your weather server tools in a user-friendly interface.
Installation and Setup
-
Install MCP Inspector (requires Node.js):
npx @modelcontextprotocol/inspector -
Start your weather server:
PORT=8080 npm start -
Configure MCP Inspector:
- Server URL:
http://localhost:8080/mcp - Transport:
HTTP (Streamable) - Protocol Version:
2024-11-05
- Server URL:
Visual Interface Features

The MCP Inspector provides:
- 🛠️ Tools Explorer: Browse all available tools (
search_location,get_weather,stream_weather) - 📝 Interactive Forms: Easy-to-use forms for entering tool parameters
- 🎯 Real-time Testing: Execute tools and see live responses
- 📊 Response Viewer: JSON-formatted results with syntax highlighting
- 🔄 Session Management: Visual session state and connection status
- 📈 Request/Response History: Track all your API interactions
Example Workflow
- Connect to your server using the Inspector
- Explore the three available weather tools
- Test location search:
- Tool:
search_location - Parameters:
city_name: "Paris"
- Tool:
- Get weather data:
- Tool:
get_weather - Parameters: Use coordinates from previous search
- Tool:
- Monitor streaming:
- Tool:
stream_weather - Watch real-time weather updates
- Tool:
Benefits
- No coding required: Test your MCP server without writing client code
- Visual debugging: See exactly what data flows between client and server
- Tool validation: Verify parameter schemas and response formats
- Rapid prototyping: Quickly iterate on your MCP server implementation
The Inspector is particularly useful during development to ensure your weather server works correctly before integrating it into larger applications.
🏗️ Architecture
- Express.js: HTTP server
- MCP SDK: MCP protocol implementation with StreamableHTTPServerTransport
- Open-Meteo API: Weather data source
- TypeScript: Development language with compilation to JavaScript
📄 Specifications
- MCP Protocol: Version 2024-11-05 and 2025-03-26
- Transport: Streamable HTTP with SSE support
- Data Format: JSON-RPC 2.0
- Weather API: Open-Meteo
🔗 Useful Links
📝 License
This project is a demonstration example based on open-meteo-mcp.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。