home / mcp / mcp weather server
Provides current weather and forecasts by integrating OpenWeatherMap via Deepseek with an MCP interface.
Configuration
View docs{
"mcpServers": {
"asxrnd-mcp_deepseek": {
"command": "uv",
"args": [
"run",
"mcp",
"dev",
"server.py"
],
"env": {
"LOG_LEVEL": "INFO",
"DATABASE_URL": "postgresql://user:pass@host:5432/db",
"ACCRUALS_API_URL": "http://host:8000",
"ALLOWED_BASE_DIR": "/path/to/allowed/dir",
"DEEPSEEK_API_KEY": "YOUR_DEEPSEEK_API_KEY",
"OPENWEATHER_API_KEY": "YOUR_OPENWEATHER_API_KEY",
"OPENWEATHER_BASE_URL": "https://api.openweathermap.org/data/2.5"
}
}
}
}You have an MCP Weather Server that connects to OpenWeatherMap to fetch current weather and forecasts, powered by Deepseek for natural-language interaction. It is designed to be modular and can integrate with a remote accruals API and a remote PostgreSQL database, while exposing weather tools through the MCP protocol for easy consumption by clients.
You interact with the server through an MCP client. Start the MCP server, then use the client to issue natural-language requests such as asking for the current weather in a city or requesting a multi-day forecast. The server will process your request, call the appropriate weather tools, and return real data from OpenWeatherMap.
Prerequisites: - Python 3.10+ and a virtual environment tool - An MCP runtime (the examples assume the MCP CLI is installed and available as uv) - Access to the internet for API calls to OpenWeatherMap and Deepseek Follow these steps to install and run the MCP Weather Server locally:
python3 -m venv venv
# Activate the virtual environment
# macOS/Linux:
source venv/bin/activate
# Windows:
venv\Scripts\activate
# Install dependencies
pip3 install -r requirements.txt
# Run the MCP server via the MCP runtime (examples shown below) or install the server package if required by your setup
# Start with a clean development run (see next section for details)
uv run mcp dev server.py
# Alternatively, install a predefined Weather Service MCP (if available in your setup)
uv run mcp install server.py --name "Weather Service"Configure API keys, database connections, and remote services using environment variables. Create a .env file at the project root with the following keys (placeholders shown):
OPENWEATHER_API_KEY=YOUR_OPENWEATHER_API_KEY
OPENWEATHER_BASE_URL=https://api.openweathermap.org/data/2.5
DEEPSEEK_API_KEY=YOUR_DEEPSEEK_API_KEY
DATABASE_URL=postgresql://username:password@HOST:PORT/DBNAME
ACCRUALS_API_URL=http://HOST:8000
ALLOWED_BASE_DIR=/path/to/allowed/dir
LOG_LEVEL=INFOIf you encounter issues, check the key variables and the MCP runtime setup. Common problems include missing API keys, invalid city names when querying weather, or connectivity issues to remote services. Tips: - Ensure OPENWEATHER_API_KEY is present in the environment - Verify internet connectivity and that the OpenWeatherMap free tier limits are not exceeded - Confirm DEEPSEEK_API_KEY is correct if using Deepseek features - Validate ACCRUALS_API_URL points to a running remote FastAPI service when you enable accruals data access
The server exposes two MCP tools to fetch weather data: - get_current_weather: Retrieve the current weather for a city - get_forecast: Retrieve a multi-day forecast for a city These tools are designed to be called by the MCP client and Deepseek workflows to return live weather information.
This setup uses a two-tier architecture where weather data is retrieved from OpenWeatherMap, while user interactions can be processed by Deepseek. A remote accruals API can be queried if you have a deployed FastAPI service for accrual data. The MCP server exposes weather tools that your client can invoke, either directly or through Deepseek, to obtain real-time weather information.
You can start the MCP server in development mode or install the Weather Service as an MCP server. The following commands are examples of how to run the MCP server processes:
uv run mcp dev server.py
uv run mcp install server.py --name "Weather Service"Retrieve the current weather for a city using OpenWeatherMap data via MCP tooling.
Retrieve a multi-day weather forecast for a city using OpenWeatherMap data via MCP tooling.