OilPriceAPI MCP Server is a local stdio-run MCP server that enables compatible AI clients (such as Claude, Cursor, VS Code, etc.) to access source-timestamped oil, natural gas, LNG, carbon, fuel, and related energy data. It is powered by OilPriceAPI, a standardized REST API for energy dashboards, fleet and logistics tools, maritime workflows, and market research scenarios.
[Purpose] This server exposes energy prices and related data to AI clients through the MCP protocol, enabling users to query in natural language the prices, history, futures curves, and market briefs and price alerts for commodities such as Brent, WTI, diesel, and jet fuel.
[Main capabilities]
- Data and workflow tools: latest prices, historical data, futures, marine fuels, fuel surcharges, energy intelligence, alerts, market briefs, and persistent monitoring.
- Resources: reviewed product contracts and subscribable price snapshots.
- Prompts: analyst templates for briefs, spread analysis, natural gas markets, diesel costs, and supply analysis.
- Natural language support: you can directly say "brent oil" or "natural gas" without needing to memorize codes.
- Broad catalog: covers oil, natural gas, coal, refined products, metals, foreign exchange, marine fuels, state diesel, and some energy intelligence datasets; access permissions vary by plan and account.
- Smart errors: unrecognized commodities give suggestions instead of silently falling back.
- Read-only by default: unless write scopes are explicitly enabled, account change operations are not listed, and direct change calls are rejected.
- Diagnostic tool doctor: checks the Node runtime, package entry point, API reachability, key validity, current plan, and reports feature gating; doctor --demo performs bounded keyless requests.
- Capability contract: each package includes build/capabilities.json, generated by the same SDK registry as tools/list, recording package/version/source commit, minimum Node version, scopes, configuration files, exact manifest, per-tool annotations, key/permission requirements, resources, commands, and support URLs.
- Capability ledger: capability-ledger.json records an explicit decision (exposed or not exposed and why) for every operation in the published OilPriceAPI contract, and verifies it against the live contract via npm run check:capability-ledger.
[Usage]
- Keyless demo: omit OILPRICEAPI_KEY to use demo mode. Price tools (opa_get_price, opa_compare_prices, opa_list_commodities, opa_market_overview) provide the latest available values for a limited demo commodity set, while other data tools explain account requirements. Demo responses carry a footer marker.
- Configuration: via --config, generate client-native, copy-pasteable JSON for claude-desktop, claude-code, cursor, vscode, cline, and windsurf; add --demo to omit API key configuration entirely; scope, profile, and category options are preserved in the generated server arguments.
- Manual configuration example: add the server to Claude Desktop's claude_desktop_config.json, the project's .mcp.json, .cursor/mcp.json, .vscode/mcp.json, or ~/.codeium/windsurf/mcp_config.json.
- Container build: container builds require a source revision and commit timestamp so that the image, capability manifest, and build metadata can be traced to the same checkout; the runtime image uses an unprivileged node user; do not bake credentials into the image.
- This server runs only locally via stdio; its MCP registry record lists the npm package, with no remote endpoint. Hosted connector https://mcp.oilpriceapi.com/mcp is another smaller set of energy_* tools with OAuth account linking; unlike this package, this package provides the full opa_* toolset.
[Environment Variables and Scopes] The read scope includes all non-mutating tools, including alert history, subscription list, and subscription event polling. The four create/delete tools require --scope write or OILPRICEAPI_MCP_SCOPE=write. Unknown scope, profile, or category values fail closed before stdio startup. Profiles can reduce tool overload without replacing first-class MCP operations.
[Price Alerts and Market Briefs] Price alert tools (authentication required): create and manage persistent price alerts tied to an OilPriceAPI account; an API key is required. The alert engine evaluates qualifying source updates and notifies by email (and optionally webhook) when conditions are met. Market brief and subscription tools (authentication required): a market brief provides a multi-commodity snapshot in a single call. Subscriptions ("watches") are persistent, recurring snapshots tied to an account—the API records one event per interval, and the agent polls for new events via a per-user cursor (events are polled, not pushed; there is no persistent connection). Subscriptions differ from alerts: watches always emit an event at each interval (a run log), whereas alerts trigger only on threshold crossings. Per-account limits on codes, watches, and cadence apply; API responses are authoritative and return the current limits when exceeded.
[Example Questions] Price data available by subscription (JSON).
[Product Facts and Model Knowledge] opa_get_product_facts and oilpriceapi://product-facts can improve the accuracy of a connected MCP session, but they do not retrain the model or update its general knowledge. The server prioritizes the canonical keyless contract, uses bounded caching, and annotates source and warning metadata for any checksummed and validated package fallback.
[v3.0.0 Breaking Changes] The default tool scope is now read-only; create/delete alert and subscription tools require explicit --scope write or OILPRICEAPI_MCP_SCOPE=write; invalid scope/profile/category configurations now fail before MCP stdio startup; use --list-tools --json or --capabilities --json instead of relying on a hardcoded inventory.
[v2.0.0 breakingGender change] All tool names now use the opa_ prefix (for example get_commodity_price -> opa_get_price); unrecognized commodity names now return an error with suggestions instead of silently defaulting to Brent; list_commodities now fetches live from the API (falling back to a static list when unavailable).
[Privacy and data flow] This MCP server runs locally and communicates only with the OilPriceAPI service. What is sent: tool requests are converted into HTTPS calls to api.oilpriceapi.com (commodity codes, query parameters such as time range or state, carrier slug and service level inputs for fuel surcharges, and the alert parameters you specify for alert/subscription tools), authenticated with the API key. No conversation content is transmitted—only the structured tool inputs described above. API key storage: the key is stored locally in the MCP client configuration (or the OILPRICEAPI_KEY environment variable) and is sent only as an Authorization header to api.oilpriceapi.com. Logging and usage telemetry: each tool emits a local structured hit/miss event to stderr and annotates its API request with the tool name plus deliberately lossy parameter shapes; commodity codes, intervals, state codes, and bounded numeric controls may be retained; free text, prompts, names, IDs, API well numbers, coordinates, and thresholds are reduced to provided. API request logs follow the OilPriceAPI privacy policy. Third parties: data is not shared with third parties except as described in that policy. Demo mode: without an API key, price tools call a keyless demo endpoint on the same host; no key or account data is involved.
[Pricing boundary (HTTP 402)] Always open: the MCP server itself (MIT), setup, documentation, discovery (tool listing), and keyless demo mode for low-volume evaluation. API key: use public product facts and your account responses to obtain the current trial, quota, reset window, and dataset permissions; keyless demo mode remains available for a limited dataset. Behind the paywall: high-volume usage and premium datasets (futures, energy intelligence, well permits/production, large-scale alerts). When a request crosses that boundary, the API returns standard HTTP 402/403/429 with the exact limit or feature gate in the body, and this server displays that message along with an upgrade link—agents get a machine-readable stop rather than a silent failure. x402 Protocol: per-request encrypted micropayments via the x402 protocol are currently not supported—payment is through an account plan (Stripe), authenticated with an API key.
[API documentation and SDK] A Python SDK (with Pandas integration), Node.js SDK (TypeScript/JavaScript), Go SDK (idiomatic Go client), and OpenBB platform integration are provided. The interactive browser api.oilpriceapi.com/swagger lets you try every endpoint (demo mode, no key required). The OpenAPI specification is at swagger.json.
[Limitations] This server runs locally over stdio and has no remote endpoint; the hosted connector is a separate small tool set. Some data tools require an API key and a corresponding account plan. The keyless demo covers only a limited commodity set. Model knowledge is not updated by connecting.