The Weather MCP Server provides weather information through the National Weather Service (NWS) API using the Model Context Protocol (MCP). It allows you to retrieve weather alerts for US states and get weather forecasts for specific locations using latitude and longitude coordinates.
To install the Weather MCP Server:
python -m venv .venv
source .venv/bin/activate # On Windows, use `.venv\Scripts\activate`
uv add "mcp[cli]" httpx
The server uses a configuration file config.py
with the following settings:
You can modify these settings in the config.py
file to customize the server behavior.
To run the server on its own:
source .venv/bin/activate # On Windows, use `.venv\Scripts\activate`
python weather.py
The Weather MCP Server can be integrated with Cline:
get_alerts(state: str)
: Get weather alerts for a US state (use two-letter state code, e.g., "CA" for California)get_forecast(latitude: float, longitude: float)
: Get weather forecast for a specific locationExample usage in Cline:
# Get alerts for California
result = await mcp.call_tool("weather.get_alerts", state="CA")
print(result)
# Get forecast for San Francisco (approximate coordinates)
result = await mcp.call_tool("weather.get_forecast", latitude=37.7749, longitude=-122.4194)
print(result)
Note: The exact syntax for calling MCP tools may vary depending on your Cline setup.
The server includes error handling for API requests and logging. If an error occurs during a request, the server will log the error and return an appropriate error message. Logs are printed to the console with the configured log level and format.
You can manually test the server using the MCP client to call the provided tools:
# Get alerts for California
result = await mcp.call_tool("get_alerts", state="CA")
print(result)
# Get forecast for San Francisco (approximate coordinates)
result = await mcp.call_tool("get_forecast", latitude=37.7749, longitude=-122.4194)
print(result)
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "weather" '{"command":"python","args":["weather.py"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"weather": {
"command": "python",
"args": [
"weather.py"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"weather": {
"command": "python",
"args": [
"weather.py"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect