energy-mcp
Integrates with LangChain's MCP adapters to provide AI agents with tools for retrieving and analyzing hourly electricity demand, peak loads, and temperature data across US balancing authorities.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@energy-mcp Compare CISO and PJM demand for the first week of January"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
energy-mcp
An MCP server for US electricity demand and weather data. It exposes the data as MCP tools, resources, and prompts, runs locally over stdio, and works with any MCP client: Claude Desktop, Claude Code, LangChain's MCP adapters, or the MCP Inspector.
The data ships as a small SQLite file of real observations, so you can clone the repo and run it without a database or an API key.
Python 3.11+ · MCP SDK 1.x (FastMCP) · MIT
What is MCP
MCP is an open protocol from Anthropic. It gives an AI client one standard way to call external tools and read external data, instead of a custom integration per app. A server advertises what it offers, and a client connects and uses it. Servers can offer three things:
Tools: functions the model can call.
Resources: read-only content the client loads as context.
Prompts: reusable templates a user can pick.
This server provides all three.
Related MCP server: euenergy-mcp
Tools, resources, and prompts
Tools:
list_regions(): regions available, with row counts and date coverage.query_demand(region, start, end, limit=168): hourly demand in MWh for a date range.daily_demand(region, start, end): daily average, peak, and minimum.peak_demand(region, start, end): the single highest-demand hour.compare_regions(start, end, regions=None): average and peak across regions.demand_vs_weather(region, start, end): daily demand joined to that region's temperature.
Resources:
schema://energy: a plain description of the tables.docs://coverage: which regions and dates are currently loaded.
Prompts:
analyze_demand(region): a starter that walks a region through the tools.
Quickstart
You need uv.
git clone https://github.com/visethchapman/energy-mcp
cd energy-mcp
uv run energy-mcp # starts the server on stdio; it waits for a clientTo click around the tools in a UI, use the MCP Inspector:
uv run mcp dev src/energy_mcp/server.pyConnect it to a client
Claude Desktop
Add this to claude_desktop_config.json (on macOS,
~/Library/Application Support/Claude/claude_desktop_config.json) and restart
Claude Desktop:
{
"mcpServers": {
"energy": {
"command": "uv",
"args": ["--directory", "/absolute/path/to/energy-mcp", "run", "energy-mcp"]
}
}
}Claude Code
claude mcp add energy -- uv --directory /absolute/path/to/energy-mcp run energy-mcpThen ask in plain language, and the client picks the tools:
"Which US grid had the highest average demand in July 2024?"
"When did ERCOT peak in 2024, and how hot was Houston that day?"
"Compare CISO and PJM demand for the first week of January."
Example output
Real results from the bundled data when a client calls a tool:
> peak_demand(region="ERCO", start="2024-01-01", end="2024-12-31")
{ "region": "ERCO", "period": "2024-08-20 23:00:00", "demand_mwh": 85544.0 }
> compare_regions(start="2024-07-01", end="2024-07-31")
[ {"region":"PJM", "avg_mwh":109674.4, "peak_mwh":153121.0},
{"region":"ERCO", "avg_mwh": 60200.6, "peak_mwh": 81200.0},
{"region":"CISO", "avg_mwh": 32008.4, "peak_mwh": 44727.0},
{"region":"NYIS", "avg_mwh": 21494.1, "peak_mwh": 28990.0} ]
> demand_vs_weather(region="ERCO", start="2024-07-01", end="2024-07-03")
[ {"day":"2024-07-01", "avg_mwh":67736.3, "tmax_c":37.8, "tmin_c":26.7},
{"day":"2024-07-02", "avg_mwh":68463.9, "tmax_c":36.1, "tmin_c":27.2},
{"day":"2024-07-03", "avg_mwh":68017.8, "tmax_c":34.4, "tmin_c":26.7} ]demand_vs_weather is the interesting one. ERCOT demand climbs with Houston
temperature in summer (air-conditioning load), and the tool returns both series
so a model can point at the link.
Data
Everything is real, trimmed to calendar year 2024 to keep the file around 5 MB.
Table | Source | Rows |
| EIA Open Data API, 4 balancing authorities: ERCO, CISO, PJM, NYIS | ~35k |
| NOAA GHCN-Daily, one station near each region's main load zone | ~1.5k |
| NOAA station metadata | 4 |
| table documentation | 3 |
The SQLite file is committed, so nothing is fetched at runtime. To rebuild it or widen the date range (this needs a free EIA API key):
uv run --extra build python scripts/build_sample_db.py --start 2023-01-01 --end 2024-12-31Set ENERGY_MCP_DB to point the server at a different SQLite file.
Safety
Read-only. The database is opened with SQLite
mode=ro, so no tool can write.Parameterized SQL. Arguments are bound as parameters, not formatted into the query string, so they cannot inject SQL.
Validated inputs. Region and date arguments are checked before they reach the database, and bad input comes back as a clear error the model can act on.
No secrets to run. The data is in the repo; the EIA key is only for rebuilding it.
Development
uv run pytest
uv run mcp dev src/energy_mcp/server.pyLayout:
src/energy_mcp/
server.py # FastMCP server: tools, resources, prompts
db.py # read-only SQLite access
data/energy_sample.sqlite # bundled real data
scripts/build_sample_db.py # how the sample was assembled
tests/test_tools.pyThe project uses the MCP 1.x SDK (the FastMCP API), which is what the current
Claude Desktop docs and the mcp CLI use. The 2.x SDK is a newer redesign.
Related
energy-text2sql is a text-to-SQL agent over the same EIA and NOAA data. Same data, different interface: one answers questions by writing SQL, this one serves the data as MCP tools.
License
MIT
Available Tools
6 toolscompare_regionsA
Compare average and peak demand across regions over the same date range. Useful for questions like "which grid was busiest last summer?".
Args:
start: Inclusive start date, 'YYYY-MM-DD'.
end: Inclusive end date, 'YYYY-MM-DD'.
regions: Optional subset of region codes. Defaults to all regions.
Inputs: end (required), start (required), regions. Returns: result
daily_demandA
Return daily demand statistics (average, peak, minimum MWh) for one region over a date range. Use this instead of query_demand for ranges longer than a few days.
Args:
region: Balancing authority code.
start: Inclusive start date, 'YYYY-MM-DD'.
end: Inclusive end date, 'YYYY-MM-DD'.
Inputs: end (required), start (required), region (required). Returns: result
demand_vs_weatherA
Join daily average demand against daily temperature for a region, using the NOAA weather station nearest that region's main load zone. Reveals the demand-temperature relationship (heating and cooling load).
Args:
region: Balancing authority code.
start: Inclusive start date, 'YYYY-MM-DD'.
end: Inclusive end date, 'YYYY-MM-DD'.
Returns one row per day: average demand (MWh) and that day's max/min temp (C).
Inputs: end (required), start (required), region (required). Returns: result
list_regionsA
List the balancing authorities available, with row counts and the date range of demand data for each. Call this first to see what you can query.
Inputs: no named parameters. Returns: result
peak_demandA
Find the single highest-demand hour for one region over a date range, returning the timestamp and the demand in MWh.
Args:
region: Balancing authority code.
start: Inclusive start date, 'YYYY-MM-DD'.
end: Inclusive end date, 'YYYY-MM-DD'.
Inputs: end (required), start (required), region (required).
query_demandA
Return hourly electricity demand (MWh) for one region over a date range.
Args:
region: Balancing authority code (e.g. ERCO, CISO, PJM, NYIS).
start: Inclusive start date, 'YYYY-MM-DD'.
end: Inclusive end date, 'YYYY-MM-DD'.
limit: Max rows to return (default 168 = one week of hours).
Returns hourly rows ordered by time. For long ranges prefer daily_demand.
Inputs: end (required), start (required), region (required), limit. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool serves a distinct purpose: listing regions, retrieving hourly/daily/peak demand, comparing across regions, and correlating demand with weather. No functional overlap.
All six tool names follow a consistent verb_noun pattern with snake_case: list_regions, query_demand, daily_demand, peak_demand, compare_regions, demand_vs_weather. Naming is predictable and clear.
With 6 tools, the server is well-scoped for its purpose – covering region discovery, multiple demand granularities, inter-region comparison, and weather integration. No bloat or deficiency.
Core demand querying workflows are fully supported. A minor gap is the lack of a raw hourly multi-region query (compare_regions only returns averages/peaks). Overall, the surface is thorough for typical use cases.
Related MCP Connectors
MCP server for building and testing AI agents with multi-model experimentation and insights.
Hosted MCP server for live public-data APIs and Skills for AI agents.
MCP server for querying and analyzing data from ad platforms, analytics tools, and spreadsheets
Hosted MCP server exposing US hospital procedure cost data to AI assistants
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA production-ready Python MCP server providing tools for fetching live weather data, querying local SQLite databases, reading files, summarizing webpages, and performing safe mathematical calculations. It enables MCP-compatible LLM clients to execute these tasks autonomously as part of agentic workflows.-
- FlicenseNot gradedqualityCmaintenanceA read-only MCP server that exposes European day-ahead electricity prices for ~41 bidding zones via tools like hourly prices, cheapest hours, current price, and cross-zone summary, enabling AI agents to query energy market data.1-
- AlicenseNot gradedqualityCmaintenanceA no-API-key-required MCP server that wraps Open-Meteo APIs to provide geocoding and weather forecast data, enabling city lookups and multi-day forecasts through tools, resources, and prompts.MIT
- FlicenseAqualityDmaintenanceAn MCP server that exposes the U.S. Energy Information Administration (EIA) Open Data API, enabling LLMs to browse and query energy data across 17 datasets with generic, composable tools.4-