@cyanheads/eia-mcp-server

v0.1.6 pre-1.0

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.

@cyanheads/eia-mcp-server
claude mcp add --transport http eia-mcp-server https://eia.caseyjhand.com/mcp
codex mcp add eia-mcp-server --url https://eia.caseyjhand.com/mcp
{
  "mcpServers": {
    "eia-mcp-server": {
      "url": "https://eia.caseyjhand.com/mcp"
    }
  }
}
gemini mcp add --transport http eia-mcp-server https://eia.caseyjhand.com/mcp
{
  "mcpServers": {
    "eia-mcp-server": {
      "command": "bunx",
      "args": [
        "@cyanheads/eia-mcp-server@latest"
      ]
    }
  }
}
{
  "mcpServers": {
    "eia-mcp-server": {
      "type": "http",
      "url": "https://eia.caseyjhand.com/mcp"
    }
  }
}
curl -X POST https://eia.caseyjhand.com/mcp \
  -H "Content-Type: application/json" \
  -H "MCP-Protocol-Version: 2025-11-25" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"curl","version":"1.0.0"}}}'

Tools

7

read 6

eia_browse_routes

Lists child routes under a given path in the EIA dataset taxonomy. Start with no path to get the 14 top-level categories (electricity, petroleum, natural-gas, steo, aeo, ieo, seds, etc.), then drill into subcategories. Each result includes an isLeaf flag — leaf routes are queryable endpoints; non-leaf routes have children to browse. When isLeaf is true on the browsed path itself, switch to eia_describe_route.

read
invocation
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "eia_browse_routes",
    "arguments": {}
  }
}
schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "path": {
      "description": "Route path to browse (e.g. \"electricity\", \"petroleum/pri\"). Omit for root.",
      "type": "string"
    }
  },
  "additionalProperties": false
}
view source ↗

eia_describe_route

Returns full metadata for a leaf route: available facets with their valid values, data column names and units, frequency options, and date range. Call this before eia_query_route to discover valid facet IDs, facet values, column IDs, and frequency codes. Facet values are fetched from separate EIA endpoints and merged — results are cached per-route for the process lifetime to minimize API calls.

read
invocation
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "eia_describe_route",
    "arguments": {
      "route": "<route>"
    }
  }
}
schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "route": {
      "type": "string",
      "minLength": 1,
      "description": "Leaf route path (e.g. \"electricity/retail-sales\", \"steo\"). Discoverable via eia_browse_routes or eia_search_routes."
    }
  },
  "required": [
    "route"
  ],
  "additionalProperties": false
}
view source ↗

eia_search_routes

Fuzzy text search across route names, descriptions, and category labels. Resolves natural-language queries like "electricity retail sales by state" or "natural gas imports" to matching route paths. STEO series names are indexed so queries like "ethanol net imports" or "crude oil production forecast" also resolve. Results include isLeaf so you know whether to browse further or query directly. Results with score > 0.5 are weak matches — try a more specific query or use eia_browse_routes to explore the taxonomy.

read
invocation
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "eia_search_routes",
    "arguments": {
      "query": "<query>"
    }
  }
}
schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "query": {
      "type": "string",
      "minLength": 1,
      "description": "Free-text search terms to match against route names and descriptions."
    },
    "limit": {
      "default": 10,
      "description": "Maximum results to return (default 10, max 30).",
      "type": "integer",
      "minimum": 1,
      "maximum": 30
    }
  },
  "required": [
    "query",
    "limit"
  ],
  "additionalProperties": false
}
view source ↗

eia_query_route

Fetches data from a leaf route with optional facet filters, date range, frequency, and column selection. Use eia_describe_route first to discover valid facet IDs, facet values, column IDs, and frequency codes. Data values are strings in the response (EIA API returns all numeric values as strings, e.g. "9.13"); cast to DOUBLE in SQL when arithmetic is needed. Returns a preview inline; large result sets (total > length) spill to a DataCanvas table when canvas is enabled — use the returned canvas_id and dataset name with eia_dataframe_query for SQL analysis. Pass the same canvas_id on subsequent eia_query_route calls to accumulate multiple route results into one canvas for cross-route joins.

read
invocation
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "eia_query_route",
    "arguments": {
      "route": "<route>"
    }
  }
}
schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "route": {
      "type": "string",
      "minLength": 1,
      "description": "Leaf route path (e.g. \"electricity/retail-sales\", \"steo\"). Discoverable via eia_browse_routes or eia_search_routes."
    },
    "filters": {
      "description": "Facet filters keyed by facet ID (e.g. { \"stateid\": \"TX\", \"sectorid\": [\"RES\", \"COM\"] }). Use the facets[].id values returned by eia_describe_route as keys here.",
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        ]
      }
    },
    "columns": {
      "description": "Data column IDs to return (reduces payload). Defaults to all. IDs discoverable via eia_describe_route.",
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "frequency": {
      "description": "Aggregation frequency ID (e.g. \"monthly\", \"annual\"). Defaults to route default. Valid IDs from eia_describe_route.",
      "type": "string"
    },
    "start": {
      "description": "Period start in the route date format (e.g. \"2020-01\" for monthly, \"2020\" for annual). Format from eia_describe_route.",
      "type": "string"
    },
    "end": {
      "description": "Period end (same format as start).",
      "type": "string"
    },
    "sort": {
      "description": "Result ordering.",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "column": {
            "type": "string",
            "description": "Column ID to sort by."
          },
          "direction": {
            "type": "string",
            "enum": [
              "asc",
              "desc"
            ],
            "description": "Sort direction."
          }
        },
        "required": [
          "column",
          "direction"
        ],
        "additionalProperties": false,
        "description": "A sort criterion."
      }
    },
    "offset": {
      "default": 0,
      "description": "Pagination offset (default 0).",
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "length": {
      "default": 100,
      "description": "Rows to fetch per request (default 100, max 5000 per EIA limit).",
      "type": "integer",
      "minimum": 1,
      "maximum": 5000
    },
    "canvas_id": {
      "description": "DataCanvas ID to register results into. Omit on first call — a new canvas is minted and returned. Pass the returned canvas_id on subsequent calls to accumulate multiple route results into one canvas for cross-route SQL joins.",
      "type": "string"
    }
  },
  "required": [
    "route",
    "offset",
    "length"
  ],
  "additionalProperties": false
}
view source ↗

eia_dataframe_describe

List canvas dataframes (df_<id>) materialized by eia_query_route, with provenance, TTL, row count, and column schema. Lazy-sweeps expired tables before responding so the list is always current. Pass a specific name to inspect one dataframe; omit to list all active dataframes for this tenant.

read
invocation
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "eia_dataframe_describe",
    "arguments": {}
  }
}
schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "name": {
      "description": "df_<id> handle to describe a single dataframe. Omit to list all active dataframes.",
      "type": "string"
    }
  },
  "additionalProperties": false
}
view source ↗

eia_dataframe_query

Run a single-statement SELECT against canvas dataframes registered by eia_query_route. Standard DuckDB SQL — joins, aggregates, window functions, CTEs all supported. Reference dataframes by the df_<id> handles returned by eia_query_route or listed by eia_dataframe_describe. Read-only: writes, DDL, DROP, COPY, PRAGMA, ATTACH, and external-file table functions are rejected. System catalogs (information_schema, pg_catalog, sqlite_master, duckdb_*) are denied at the bridge layer. EIA data values are VARCHAR — use CAST(col AS DOUBLE) for arithmetic and aggregation. Optional register_as chains results as a new dataframe with a fresh TTL.

read
invocation
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "eia_dataframe_query",
    "arguments": {
      "sql": "<sql>"
    }
  }
}
schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "sql": {
      "type": "string",
      "minLength": 1,
      "description": "Single-statement SELECT against df_<id> tables. EIA data columns are VARCHAR — use CAST(col AS DOUBLE) for arithmetic. Example: SELECT period, CAST(value AS DOUBLE) AS val FROM df_XXXXX ORDER BY period"
    },
    "register_as": {
      "description": "When set, persist the result as a new dataframe with a fresh TTL. Use to chain analyses without re-running upstream queries. Conflicts with an existing name throw Conflict.",
      "type": "string"
    },
    "preview": {
      "description": "Rows to include in the immediate response. Defaults to row_limit. Set lower when chaining via register_as and only a sample is needed inline.",
      "type": "integer",
      "minimum": 0,
      "maximum": 10000
    },
    "row_limit": {
      "default": 1000,
      "description": "Hard cap on rows materialized in the response (default 1000, max 10000).",
      "type": "integer",
      "minimum": 1,
      "maximum": 10000
    }
  },
  "required": [
    "sql",
    "row_limit"
  ],
  "additionalProperties": false
}
view source ↗

disabled 1

eia_dataframe_drop

Drop a canvas dataframe by name. Idempotent — returns dropped=false when nothing matched. Use to free canvas resources ahead of the per-table TTL when an analysis is complete. In normal operation, TTL cleanup (default 24 h, sliding) is sufficient and this tool is unnecessary. Only available when EIA_DATAFRAME_DROP_ENABLED=true.

disabledwould be destructive

Disabled. Dataframe drop is disabled in this deployment.

EIA_DATAFRAME_DROP_ENABLED=true
schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "minLength": 1,
      "description": "df_<id> handle to drop."
    }
  },
  "required": [
    "name"
  ],
  "additionalProperties": false
}
view source ↗