mcp-server-eia
An 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.
README
mcp-server-eia
An MCP server that exposes the U.S. Energy Information Administration (EIA) Open Data API v2 to LLM clients. It provides a small set of generic, composable tools that mirror the API's uniform tree structure (browse → discover facets → query data), giving agents full coverage of all 17 EIA datasets — electricity, natural gas, petroleum, coal, nuclear outages, CO2 emissions, renewables, and the energy outlooks (AEO/IEO/STEO) — without hard-coding hundreds of endpoints.
Tools
| Tool | Purpose |
|---|---|
eia_browse_routes |
Explore the dataset tree from any path (empty = the 17 top-level datasets). At a leaf, returns dataset metadata: available frequencies, facet ids, valid data columns, and the covered date range. Primary discovery tool. |
eia_list_facets |
List the facet ids a dataset can be filtered by (e.g. stateid, sectorid, fueltypeid). |
eia_get_facet_options |
List the valid option values for a single facet, so filters use real ids. |
eia_get_data |
Query dataset rows with column selection, facet filters, frequency, date range, sorting, and pagination. Returns structured JSON with pagination metadata. |
How the EIA API is shaped
The API is a recursive tree. A GET on a route path returns either child
routes (an intermediate node) or leaf metadata (a queryable dataset). The
typical workflow is:
eia_browse_routes(route="")— list top-level datasets.- Drill down, e.g.
eia_browse_routes(route="electricity/retail-sales")— read the validdata_columns,frequencies, and facet ids. eia_list_facets/eia_get_facet_options— find valid filter values.eia_get_data(...)— retrieve the numbers.
Conventions
- Routes are slash paths without a
v2/prefix, e.g.electricity/retail-sales. - Date formats depend on frequency:
2020(annual),2020-01(monthly),2020-01-01(daily),2020-01-01T00(hourly). - Facets are passed as
{facet_id: [values]}; sort as[{"column": ..., "direction": "asc"|"desc"}]. - Pagination:
length(page size, max 5000) andoffset. Reuse thenext_offsetreturned by the previouseia_get_dataresponse.
Requirements
- Python
>=3.14 uvfor dependency management- A free EIA API key: https://www.eia.gov/opendata/register.php
Setup
uv sync
Authentication
Set the EIA_API_KEY environment variable, or create a .env file in the
project root (loaded automatically at startup; .env is gitignored):
EIA_API_KEY=your_key_here
Running
uv run python -m eia_mcp.app
- With no port env var set, the server runs over stdio (for Claude Desktop, Claude Code, and other local MCP clients).
- If
PORTorDATABRICKS_APP_PORTis set, it runs over streamable HTTP on that port, serving MCP at the fixed path/mcpand aGET /healthreadiness endpoint. This is the mode the container image uses.
Container / gateway-hosted deployment
The included Dockerfile builds an image that serves MCP over streamable HTTP
at :8080/mcp (health at /health) — the contract the GSA Obot MCP gateway
expects for a containerized server.
docker build -t mcp-server-eia .
docker run --rm -p 8080:8080 -e EIA_API_KEY=your_key_here mcp-server-eia
curl -s localhost:8080/health # {"status":"healthy","service":"mcp-server-eia"}
Publish a public, version-pinned image for the gateway to pull:
./scripts/build-and-push.sh # tags ghcr.io/gsa-tts/mcp-server-eia:<version>
The gateway's Docker runtime pulls without registry auth, so the image must be publicly pullable. Set the GHCR package visibility to public after the first push.
Authentication model
This server deals with two distinct credentials on two different hops — do not conflate them:
| Credential | Hop | Who supplies / enforces it |
|---|---|---|
| Gateway/transport auth (e.g. Obot API key) | client → gateway → this server | The Obot gateway. In the containerized deployment the container has no public route, so the gateway is the only caller and it enforces access. |
EIA_API_KEY |
this server → api.eia.gov |
Read from the environment at call time (utils.get_api_key). In a singleUser gateway deployment, each user gets their own container instance with their own key injected as an env var. |
Because the gateway owns transport auth and each user's key is isolated per
instance, the server intentionally sets no FastMCP auth provider — it
assumes zero transport-authentication responsibility.
If this server is ever deployed as a
remoteserver (a public URL reachable independently of the gateway), the MCP endpoint would be unauthenticated. In that case add a FastMCP server-sideJWTVerifiervalidating the gateway/SSO issuer (contingent on that issuer exposing a JWKS endpoint) — notOAuthProxy/OAuthProvider. Keeping the servercontainerized(gateway-guarded) avoids this.
Example MCP client config (stdio)
{
"mcpServers": {
"eia": {
"command": "uv",
"args": ["run", "python", "-m", "eia_mcp.app"],
"cwd": "/path/to/mcp-server-eia",
"env": { "EIA_API_KEY": "your_key_here" }
}
}
}
Project layout
src/eia_mcp/
├── app.py # FastMCP init, instructions, transport selection
├── routes.py # HTTP health-check route
├── utils.py # API key, URL building, param encoding, HTTP client, errors
└── tools/
├── __init__.py # register_tools(mcp): wires up all tools
├── browse_routes.py # eia_browse_routes
├── list_facets.py # eia_list_facets
├── get_facet_options.py # eia_get_facet_options
└── get_data.py # eia_get_data
Dockerfile # containerized deployment (:8080/mcp, /health)
scripts/build-and-push.sh # build + push public GHCR image for the gateway
docs/eia-api-swagger/ # EIA API v2 OpenAPI/Swagger reference
Each tool lives in its own file and exposes a register(mcp) function; new tools
are added by dropping a file in tools/ and registering it in
tools/__init__.py.
Data source & attribution
Data is retrieved live from the U.S. Energy Information Administration Open Data API. See the EIA API terms of service for usage and attribution requirements.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。
mcp-server-qdrant
这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。