nws-weather-usgs-water-mcp

nws-weather-usgs-water-mcp

Combines National Weather Service alerts and forecasts with modern USGS water data, enabling weather and hydrology queries through MCP. No API key required, with persistent local caching.

Category
访问服务器

README

NWS Weather + USGS Water MCP

<!-- mcp-name: io.github.wylieswanson/nws-weather-usgs-water-mcp -->

CI

An MCP server combining National Weather Service alerts and forecasts with modern USGS water data. Weather comes from api.weather.gov; water data uses the official Python dataretrieval.waterdata module and APIs under api.waterdata.usgs.gov. It does not call legacy waterservices.usgs.gov endpoints.

No API key is required. A persistent local cache reduces repeated calls while keeping live readings fresh.

Why this server

  • One MCP for weather and water: correlate forecasts and alerts with nearby gauges without configuring separate services.
  • Current USGS stack: all water retrieval uses modern Water Data APIs—not waterservices.usgs.gov.
  • Keyless by default: NWS needs an identifying User-Agent, but neither data source requires credentials.
  • Public-API friendly: bounded queries and source-specific SQLite TTLs reduce repeat traffic without letting safety data become stale.
  • MCP-ready results: every data response is bounded, structured, JSON-safe, and explicit about cache state and truncation.

Weather tools

Tool Purpose
get_active_alerts Active NWS watches, warnings, and advisories for a point
get_point_forecast Multi-period NWS point forecast
get_hourly_forecast Up to 168 hourly periods with precipitation probability
get_forecast_discussion Latest raw Area Forecast Discussion from an NWS office
get_wfo_for_point Resolve a point to its NWS office, grid, and zones

get_active_alerts is the highest-priority safety tool. An empty successful result means NWS reports no active alerts for that point; it is not an error.

Water tools

The primary tools use domain-friendly names and sensible USGS parameter-code defaults:

Tool Purpose
find_gauges Find nearby gauges that have a latest reading, with exact distance
search_sites Case-insensitive partial site-name search, optionally by state
get_current_flow Latest discharge (00060)
get_flow_anomaly Current discharge compared with this date's median and percentiles
get_daily_flow Mean daily discharge (00060, statistic 00003)
get_water_level Latest gage height (00065)
get_water_temperature Latest water temperature (00010)
get_flood_stage Latest gage height plus published action/flood thresholds

get_flood_stage reports only thresholds published in the USGS time-series metadata. It does not invent a flood threshold when a site has none.

The server also exposes generic tools for monitoring locations, time series, continuous and daily observations, latest values, field measurements, peaks, statistics, water-quality samples, reference tables, and collection queryables. Use get_server_info to discover supported collections and common parameter codes. Use get_cache_info and clear_cache to inspect or reset local caching.

Complete tool index

Category Tools
NWS weather get_active_alerts, get_point_forecast, get_hourly_forecast, get_forecast_discussion, get_wfo_for_point
Focused USGS water find_gauges, search_sites, get_current_flow, get_flow_anomaly, get_daily_flow, get_water_level, get_water_temperature, get_flood_stage
General USGS access search_monitoring_locations, search_time_series, get_observations, get_latest_values, get_field_data, get_statistics, get_water_quality_samples, lookup_reference_data, get_collection_queryables
Server and cache get_server_info, get_cache_info, clear_cache

Install and run

Python 3.10 or newer and uv are recommended.

After the package is published to PyPI, run it without a permanent installation:

uvx nws-weather-usgs-water-mcp

From a source checkout:

uv sync --frozen
uv run nws-weather-usgs-water-mcp

Run those commands from a source checkout. Press Ctrl-C to stop the stdio server.

The server uses stdio transport and runs without credentials. GeoPandas is not required; geometries are returned as JSON coordinate arrays.

Results default to 200 rows and are capped at 5,000 rows. Change the process cap only when needed:

USGS_WATERDATA_MAX_ROWS=10000 uv run nws-weather-usgs-water-mcp

MCP client configuration

Use an absolute path to this checkout:

{
  "mcpServers": {
    "nws-weather-usgs-water-mcp": {
      "command": "uv",
      "args": [
        "--directory",
        "/absolute/path/to/nws-weather-usgs-water-mcp",
        "run",
        "nws-weather-usgs-water-mcp"
      ],
      "env": {
        "NWS_USER_AGENT": "nws-weather-usgs-water-mcp (you@example.com)"
      }
    }
  }
}

Neither API requires a key. NWS requires an identifying User-Agent; the server supplies one automatically, and NWS_USER_AGENT lets you provide the recommended application/contact value. If a deployment later needs higher USGS limits, add "API_USGS_PAT": "your_key" to the same env object. That optional key is sent only to USGS in the X-Api-Key header and is never cached.

Local caching

Successful results are cached in a per-user SQLite database. SQLite provides safe access when several MCP client processes share the cache, and a cache failure never prevents a live API request.

Data Default TTL
NWS active alerts 60 seconds maximum
NWS forecasts and forecast discussions 15 minutes
NWS point-to-grid mapping 7 days
Latest readings, nearby gauges, flood stage, flow anomaly 10 minutes
Continuous observations 10 minutes
Daily observations and USGS statistics 6 hours
Field data and other collections 30 minutes
Samples 1 hour
Site and time-series metadata 6 hours
Reference tables and queryable schemas 24 hours

Each tool result includes a cache object with hit, age_seconds, and ttl_seconds. Only successful responses are cached; API errors are not.

Variable Purpose
NWS_USGS_CACHE_ENABLED=0 Disable caching
NWS_USGS_CACHE_DIR=/path Override the OS-specific cache directory
NWS_USGS_CACHE_MAX_ENTRIES=2000 Limit stored query results
NWS_USGS_CACHE_TTL_SECONDS=300 Override defaults; alerts remain capped at 60s
NWS_ALERTS_CACHE_TTL_SECONDS=30 Override alert TTL, capped at 60 seconds
NWS_FORECAST_CACHE_TTL_SECONDS=900 Override forecast TTL
NWS_POINTS_CACHE_TTL_SECONDS=604800 Override point-grid TTL
NWS_DISCUSSION_CACHE_TTL_SECONDS=900 Override discussion TTL
USGS_LATEST_CACHE_TTL_SECONDS=600 Override current/latest-value TTL
USGS_CONTINUOUS_CACHE_TTL_SECONDS=600 Override continuous-observation TTL
USGS_DAILY_CACHE_TTL_SECONDS=21600 Override daily-value TTL
USGS_METADATA_CACHE_TTL_SECONDS=21600 Override site/time-series metadata TTL
USGS_REFERENCE_CACHE_TTL_SECONDS=86400 Override reference/queryable TTL
USGS_STATISTICS_CACHE_TTL_SECONDS=21600 Override statistics TTL
USGS_SAMPLES_CACHE_TTL_SECONDS=3600 Override water-quality sample TTL

The get_cache_info MCP tool reports the active path and entry count; clear_cache deletes all cached responses.

Examples

Ask an MCP client:

  • “Are there active alerts at 34.62, -111.25?”
  • “Give me the next 24 hourly forecast periods at Bull Pen trailhead.”
  • “Get the latest Flagstaff forecast discussion.”
  • “Find streamflow gauges within 20 miles of 33.45, -112.07.”
  • “What is the current flow at USGS site 01646500?”
  • “How abnormal is the current flow at Fossil Creek site 09507480?”
  • “Give me mean daily flow at 01646500 from 2026-06-01 through 2026-06-30.”
  • “What are the current gage height and published flood stage at 01646500?”
  • “Find sites containing ‘Salt River’ in Arizona.”

Bare USGS site numbers such as 01646500 are automatically normalized to modern monitoring-location IDs such as USGS-01646500. Time-series values can be provisional, so consumers should retain approval_status and qualifier.

Result shape

Data tools return a consistent envelope designed for MCP clients:

{
  "data_type": "current_flow",
  "row_count": 1,
  "columns": ["monitoring_location_id", "time", "value", "unit_of_measure"],
  "max_rows_reached": false,
  "records": [{"monitoring_location_id": "USGS-01646500", "value": 1234}],
  "metadata": {"source_url": "https://api.waterdata.usgs.gov/..."},
  "cache": {"enabled": true, "hit": false, "age_seconds": 0, "ttl_seconds": 600}
}

Fields within records vary by source collection. max_rows_reached tells the client that it should narrow the query or deliberately request a larger bound. Missing pandas values serialize as JSON null; timestamps use ISO 8601 and geometries are plain coordinate arrays.

Data source and stability

This project targets api.weather.gov and the versioned modern endpoints at api.waterdata.usgs.gov, including the OGC API v0 collections. Those APIs can evolve, so pin this package by release and review the changelog before upgrading. NWS and USGS remain authoritative; this server only retrieves, composes, bounds, caches, and serializes their data.

Development

uv sync --extra dev
uv run pytest
uv run ruff check .
uv run ruff format --check .
uv run pyright

The service layer is separate from the MCP registration layer, allowing unit tests to validate filtering, row caps, site-ID normalization, and JSON-safe serialization without network calls.

See CONTRIBUTING.md, SECURITY.md, and CHANGELOG.md before publishing or contributing. Coding agents should also follow AGENTS.md; Claude-specific project context is in CLAUDE.md.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选