energy-mcp

energy-mcp

An MCP server for US electricity demand and weather data that provides tools, resources, and prompts to query hourly demand, daily demand, peak demand, and demand vs temperature across regions, all running locally with a bundled SQLite database.

Category
访问服务器

README

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.

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 client

To click around the tools in a UI, use the MCP Inspector:

uv run mcp dev src/energy_mcp/server.py

Connect 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-mcp

Then 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
demand (hourly, MWh) EIA Open Data API, 4 balancing authorities: ERCO, CISO, PJM, NYIS ~35k
daily_weather NOAA GHCN-Daily, one station near each region's main load zone ~1.5k
stations NOAA station metadata 4
schema_cards 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-31

Set 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.py

Layout:

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.py

The 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

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选