
Eia Mcp Server
io.github.cyanheads由 GitHub 帳號 cyanheads 發布v0.1.7更新於 Oct 26, 2026
Browse and query the EIA API v2 — electricity, petroleum, natural gas, coal, forecasts via MCP.
概覽
瀏覽並查詢美國 EIA API v2 能源資料(電力、石油、天然氣、煤炭與預測),支援模糊路由搜尋和對暫存結果執行 SQL。
- 可以做什麼
- 瀏覽與描述 EIA 資料集路由、分面、欄位、頻率與日期範圍
- 用自然語言搜尋路由、序列名稱和分面值,並可解析舊版 APIv1 序列 ID
- 依分面篩選、日期範圍、欄位、頻率和分頁查詢葉節點路由
- 將查詢結果暫存為資料框,並對其執行唯讀 SQL SELECT
- 列出與刪除已暫存的資料框以釋放記憶體
- 適用情境
- 適合需要美國官方能源統計的情境:電價與發電、石油與天然氣序列(如 Henry Hub、WTI)、煤炭或 EIA 預測,並希望直接篩選、分頁和彙總,而不必手動組裝 API 請求。
- 執行需求
- 透過 bunx、npx 或 Docker 在本機以 stdio(或 Streamable HTTP)執行;需要 Bun v1.4.0 以上或 Node.js v24 以上。需要 api.eia.gov 的免費 API 金鑰,放在 EIA_API_KEY 中,並作為 api_key 參數隨每次請求送出。需能連線 api.eia.gov。另提供公開託管執行個體。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Eia Mcp Server,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
@cyanheads/eia-energy-mcp-server
Browse and query the U.S. Energy Information Administration API v2 — electricity, petroleum, natural gas, coal, forecasts, and more via MCP. STDIO or Streamable HTTP.
[Version] [License] [Docker] [MCP SDK] [npm] [TypeScript] [Bun]
[Install in Claude Desktop] [Install in Cursor] [Install in VS Code]
Public Hosted Server: https://eia-energy.caseyjhand.com/mcp
Overview
US energy data from the Energy Information Administration (EIA): electricity, petroleum, natural gas, coal, and forecasts. Find datasets in plain language, query time series with facet filters, and run SQL over large results.
Tools
The three eia_dataframe_* tools need DataCanvas, which is on by default; eia_dataframe_drop additionally requires EIA_DATAFRAME_DROP_ENABLED=true. With CANVAS_PROVIDER_TYPE=none, which the Claude Desktop bundle sets, they are neither callable nor listed by MCP. Disabled definitions remain in the server manifest with their enable hints. A default deployment lists the first six tools.
Capability reference
Browse accepts route as an alias for path; describe and query accept path as an alias for route. Supplying both spellings is rejected. Whitespace and slashes are normalized, then exactly one complete leading v2 segment is removed: /v2/electricity/retail-sales/ resolves to electricity/retail-sales, and /v2/ browses root. Full URLs, /data suffixes, interior v2, and case remain unchanged.
All four route tools distinguish retryable upstream failures: rate_limited for HTTP 429 or OVER_RATE_LIMIT, upstream_unreachable for transport failures, upstream_unavailable for HTTP service outages, upstream_invalid_response for unusable bodies or missing envelopes, and upstream_timeout when EIA does not answer in time — each attempt is cut at 45 s, and a call's attempts, backoffs, and chained requests share one 56 s deadline, inside the 60 s timeout MCP clients apply. Recovery hints reach both response surfaces. HTTP 501 remains definitive, 504 remains a timeout, and caller cancellation stays cancellation.
eia_browse_routes tool
- Omit
pathfor the 14 top-level categories; pass a path to browse its children. - Each child carries
isLeaf: describe and query leaves, or browse categories further. - A missing path returns
route_not_found; EIA rate-limiting, being unreachable, or not answering in time returns retryablerate_limited,upstream_unreachable, orupstream_timeout.
eia_describe_route tool
- Pass a leaf
routefor facets, data columns, frequencies, and date range. Each facet window is capped atEIA_FACET_VALUE_CAP(default 50); page withfacetandvalues_offset. - To find a value by name in a large facet (plant, entity, and mine IDs run to thousands), pass
values_query: each facet keeps the values whoseid,name, oraliascontains it, ignoring case, andvalues_offsetpages the matches.values_query: "palo verde"onelectricity/facility-fuel'splantCodereturns6008and57773in one call. date_rangeis metadata for the default frequency; another frequency may extend outside it. Both response surfaces carry this caveat beside the unchanged start/end values.value_count,values_truncated, and, withvalues_query,values_matcheddescribe each window. A facet whose values EIA did not return is listed inunavailable_facets; the next call retries it.- Errors:
route_not_found,route_not_queryable,facet_not_found, and retryablefacet_unavailable,rate_limited,upstream_unreachable,upstream_timeout.
eia_search_routes tool
- Search route names, descriptions, STEO's 1,469 and SEDS's 968 series names, and facet values. Before any describe, the facet values cover fuel, sector, technology, and coal-rank vocabularies, RTO balancing authorities (
Electric Reliability Council of Texas→respondent: ERCO), and the series and product names of the daily and weekly petroleum and natural-gas routes (Henry Hub→natural-gas/pri/fut,series: RNGWHHD); describing a route adds its own.limitdefaults to 10; a larger value returns at most 30 and says so, even on short or empty results.truncatedis true when more matches exist. Only the first 256 characters ofqueryare searched, with a notice when it is cut. - Matches carry
score(0 exact, 1 no match; above 0.72 is weak) and may carry afilter_hintforeia_query_route. CheckindexCompleteandindexGapsbefore trusting a short result set. - A legacy APIv1 series ID, as EIA's website and Excel add-in write them, is resolved through EIA's
/v2/seriesidlookup before any text search, in any case:ELEC.PRICE.TX-RES.Mreturns one result,electricity/retail-saleswithfilter_hint{sectorid: "RES", stateid: "TX"},frequency: "monthly", andcolumns: ["price"], ready foreia_query_route. A hit needs no index, so it answers in under a second even on a cold server. When EIA's own lookup reports no rows for the mapping it returns (some AEO IDs), the notice says the query will come back empty. An ID EIA does not recognize (PET.ZZZZZZ.W, orU.S.A, which only looks like one) returns the text search with a notice saying so; a lookup that times out, is rate-limited, or hits an outage does the same with a retry notice, never an error. - The first search builds the index and normally takes 20–40 s (at most 45 s); later searches answer from the built index. If EIA rate-limits, cannot be reached, or does not answer in time, the call fails with retryable
rate_limited,upstream_unreachable, orupstream_timeout.
eia_query_route tool
- Pass a leaf
route, with optional facet-IDfilters,columns,frequency,start/end, andsort. Page withoffsetandlength(default 25; a larger value returns at most 5,000 and says so). - Returns
lengthrows per page; continue atnext_offset(=offset+ returned count). - After describe has cached a complete facet vocabulary, and for 24 hours after that list was fetched, query notices name unmatched filter values and suggest case-sensitive IDs when possible. Filters and their echoes stay unchanged; diagnostics never fetch metadata or facet values.
- With effective monthly
YYYY-MMdata, a year-only bound means January:end: "2021"stops at2021-01; use2021-12for the full year. Query notices disclose this for either bound without expanding it. - EIA reads each bound as the period of the effective frequency containing its first day, so
start: "2023-01", end: "2023"returns January at monthly. A range is reported as inverted (no_data) only when EIA returns no rows andstartselects a later period thanend; the message names both periods. Atlocal-hourlyeach bound needs its hour and UTC offset (2024-02-01T02-06); one without fails asinvalid_periodbefore any request. So does a bound naming a date or hour that does not exist in the shape its frequency reads exactly —2024-02-30atdailyorweekly,2024-02-01T24athourly— since EIA answers those with an HTTP 500 rather than rows. totalreports the full match count; values remain strings and units appear as{col}-units. Errors cover invalid route, facet, column, frequency, sort, or period, inverted ranges (no_data), a filter list too long for EIA's ~8 KB request URI (uri_too_long; split the values across calls), and retryablerate_limited,upstream_unreachable, andupstream_timeout.stage: truestages up toEIA_CANVAS_MAX_ROWS(default 25000) as adatasethandle for SQL viaeia_dataframe_describeandeia_dataframe_query(hyphens in column names become underscores). If staging fails,datasetis absent and the note says so. Staging that would run past the call deadline stops before the next page, stages the rows already fetched, and the note says time ran out and gives the offset to resume from.
eia_dataframe_describe tool
- Omit
nameto list active staged dataframes; pass a handle to inspect one. A miss returnsfound: falsewithactive_names. - Entries carry
source_tool,query_params,created_at,expires_at,row_count,truncated/max_rows, andcolumn_schema. Listing does not extend expiry.
eia_dataframe_query tool
- Run one read-only SQL SELECT against staged handles. Inline rows follow
preview(default 25; a larger value returns at mostrow_limitand says so, and0returns none).row_limitdefaults to 1,000 and returns at most 10,000. Echoes (executedSql,columns) come back whole.register_asstill stages the complete result. truncated: truemeanstotalRowsis a cap, not a full count.register_asstages the complete result under an unused name with an exact count; the notice gives theLIMIT/OFFSETquery, with noORDER BY, that pages the rest in the order the preview showed. A result with no rows still lists its columns.- Cast EIA VARCHAR values for arithmetic. Writes, file reads, and system catalogs are rejected; declared failures include
missing_table,invalid_sql,non_select_statement,denied_function,multi_statement,sql_read_only,system_catalog_access, andregister_as_clash.
eia_dataframe_drop tool
- Pass
nameto remove a staged dataframe; requiresEIA_DATAFRAME_DROP_ENABLED=true. - Returns
dropped: falsewhen nothing matched; a failed drop returns retryablecanvas_drop_failedand the dataframe stays staged. Cleanup is optional: dataframes expire after 24 h unused.
Features
Built on @cyanheads/mcp-ts-core: stdio and Streamable HTTP transports, pluggable auth (none / jwt / oauth), swappable storage (in-memory, filesystem, Supabase, Cloudflare KV/R2/D1), structured logging with optional OpenTelemetry tracing.
EIA-specific:
- Covers all 14 top-level dataset categories of EIA API v2, with the route tree cached in process
- Fuzzy search (Fuse.js) over route names/descriptions, all 1,469 STEO and 968 SEDS series names, and facet values — 1,753 benchmark petroleum and natural-gas series names and the RTO balancing authorities among them, indexed at warm time
- Facet values are fetched and cached per route by
eia_describe_routefor 24 hours, after which the next describe re-fetches the route; a list EIA does not return is reported inunavailable_facetsand retried on the next call, and a refresh EIA does not answer serves the cached values with a notice naming when they were fetched - Routes whose metadata could not be fetched are reported through
eia_search_routesinstead of dropped - DataCanvas (DuckDB) is on by default and staging is opt-in per call; with the canvas off the three dataframe tools are not callable
- Count inputs (
length,row_limit,preview,limit) lower an over-cap value to its cap with a notice;EIA_CLAMP_LIMITS=falseadvertises and enforces each cap as a schema maximum instead
Agent skill:
eia-energy-guidecarries the gates for answering energy questions with these tools: per-route geography codes, total rows beside their components, per-row unit columns, nulls and zeros, and forecasts mixed with history. MCP clients read it from the server asskill://eia-energy-guide/SKILL.md; it also ships in the npm package, the Docker image, and the.mcpbbundle, and plugin installs scan it fromskills/.
Agent-friendly output:
- Provenance —
eia_query_routeechoes the canonical route, and staged dataframes record theirsource_toolandquery_params - Capped-window disclosure — truncated responses report the count against the cap and a
noticenaming the next call - Typed failures — error
reasonvalues (e.g.route_not_queryable,invalid_facet,missing_table) carry arecoveryhint
Getting started
Public Hosted Instance
A public instance is available at https://eia-energy.caseyjhand.com/mcp — no installation required. Point any MCP client at it via Streamable HTTP:
Self-Hosted / Local
Get a free API key at api.eia.gov, then add the following to your MCP client configuration file.
Or with npx (no Bun required):
Or with Docker:
For Streamable HTTP, set the transport and start the server:
Prerequisites
- Bun v1.4.0 or higher (or Node.js v24+).
- A free EIA API key from api.eia.gov. The
DEMO_KEYhits rate limits quickly; a real key is required for sustained use.
Installation
- Clone the repository:
- Navigate into the directory:
- Install dependencies:
- Configure environment:
Configuration
All configuration is validated at startup via Zod schemas in src/config/server-config.ts. Key environment variables:
See .env.example for the full list of optional overrides.
Running the server
Local development
-
Build and run:
-
Run checks and tests:
Docker
The Dockerfile defaults to HTTP transport, stateless session mode, and logs to /var/log/eia-energy-mcp-server. OpenTelemetry peer dependencies are installed by default — build with --build-arg OTEL_ENABLED=false to omit them.
Project structure
Development guide
See CLAUDE.md for development guidelines and architectural rules. The short version:
- Handlers throw, framework catches — no
try/catchin tool logic - Use
ctx.logfor request-scoped logging,ctx.statefor tenant-scoped storage - Always call
eia_describe_routebeforeeia_query_route— facet values require a separate API fan-out and are not embedded in route metadata - Wrap EIA responses: validate raw → normalize to domain type → return output schema; data values are strings — never coerce silently
Contributing
Issues are welcome. Run checks and tests before submitting:
License
Apache-2.0 — see LICENSE for details.
來源:README.md,提交 36e5ac0
工具
0版本歷史
1- v0.1.7最新Sep 16, 2026
評分
已滿足適用檢查項的 40%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分
請在儲存庫或註冊中心條目中宣告授權條款。