Add Live Oil Prices to Claude, Cursor & AI Agents (MCP Server Tutorial)
One config block gives your AI agent 26 commodity-price tools: Brent, WTI, natural gas, LNG, carbon, jet fuel, diesel by US state, futures curves, rig counts — plus persistent price alerts your agent can create and manage. Works in Claude Desktop, Claude Code, Cursor, and any MCP client. Try it without an API key.
Why Give Your Agent Commodity Data?
AI agents are great at reasoning and terrible at knowing today's Brent price. The OilPriceAPI MCP server (open source, MIT) fixes that through the Model Context Protocol: instead of pasting prices into prompts, your agent calls typed tools and gets source-timestamped JSON back.
What Your Agent Gets
- ✓ 17 read tools: spot prices, history, futures curves, marine fuels, rig counts, diesel by state, storage, OPEC production, EIA inventories, well permits, crack spreads
- ✓ 4 authenticated alert tools: create, list, and delete persistent price alerts
- ✓ 5 agent tools: multi-commodity market briefs and recurring price watches
- ✓ Natural language commodity names — "brent oil", not
BRENT_CRUDE_USD - ✓ 70+ commodities across oil, gas, refined products, carbon, metals, and forex
The server runs locally via npx and talks only to api.oilpriceapi.com. No conversation content leaves your machine — only the structured tool inputs (commodity codes, time periods). It even works with no API key at all in demo mode, serving live prices for a limited commodity set.
Every install below is quoted from the server's own README and was verified against the published oilpriceapi-mcp v2.4.2 package. You can also find it on Smithery, Glama, and our MCP page.
Install in Claude Desktop
Option A: One-Click .mcpb Bundle
Download oilpriceapi-2.4.2.mcpb from the latest GitHub release and double-click it. Claude Desktop installs the server and prompts you for an optional API key.
Option B: JSON Config
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"oilpriceapi": {
"command": "npx",
"args": ["-y", "oilpriceapi-mcp"],
"env": {
"OILPRICEAPI_KEY": "your-api-key-here"
}
}
}
}No key yet? Omit the env block entirely. The server starts in keyless demo mode and the price tools serve live prices for a limited commodity set.
Restart Claude Desktop. You should see the oilpriceapi server with 26 tools in the tools menu.
Install in Claude Code
One command:
claude mcp add oilpriceapi -e OILPRICEAPI_KEY=your-api-key-here -- npx -y oilpriceapi-mcp
Or, to share the server with your whole team, commit a .mcp.json at your project root (this is the config from the server's README):
{
"mcpServers": {
"oilpriceapi": {
"command": "npx",
"args": ["-y", "oilpriceapi-mcp"],
"env": {
"OILPRICEAPI_KEY": "your-api-key-here"
}
}
}
}Verify with /mcp inside Claude Code — the server reports as oilpriceapi v2.4.2.
Install in Cursor
Add to .cursor/mcp.json in your project root:
{
"mcpServers": {
"oilpriceapi": {
"command": "npx",
"args": ["-y", "oilpriceapi-mcp"],
"env": {
"OILPRICEAPI_KEY": "your-api-key-here"
}
}
}
}Cursor picks the server up on the next window reload (Settings → MCP shows it as connected). VS Code + Cline and Windsurf use the same npx command — see the README for those config paths.
Need this data in your app?
GET /v1/prices/latest?by_code=BRENT_CRUDE_USD → timestamped JSONAdd Your API Key
Demo mode covers Brent, WTI, diesel, gasoline, natural gas, gold, heating oil, and two forex pairs. For the full 70+ commodity catalog, historical data, futures curves, and persistent alerts, sign up for a free API key — 7-day free trial, then a free tier of 200 requests per month. No credit card required.
Put the key in the OILPRICEAPI_KEY env entry of whichever config you used above. The key is stored locally in your MCP client's config and sent only to api.oilpriceapi.com.
Real Prompts to Try
These exercise different tools. Each answer comes back with the source timestamp of the underlying quote, so the agent can tell you how fresh the number is.
"What's the Brent-WTI spread today?"
Calls opa_compare_prices and returns both benchmarks side by side with the spread and each price's source timestamp.
"What does diesel cost in California vs Texas right now?"
Calls opa_get_diesel_by_state twice — AAA retail diesel for all 50 states + DC. Useful for fleet and fuel-surcharge questions.
"Is the Brent futures curve in contango or backwardation?"
Calls opa_get_futures_curve and reads the shape of the forward curve for you (requires an API key with futures access).
Production: Alerts & Price Watches That Outlive the Chat
A one-off price check is a demo. The production pattern is to have your agent set up monitoring that keeps running after you close the window. With an API key, two tool families make that possible:
Persistent price alerts
Tell your agent: "Alert me if Brent crosses $85 — email plus my Slack webhook." It calls opa_create_price_alert. The alert engine watches prices server-side and fires on the threshold crossing — no chat session, no polling script, nothing running on your machine.
Recurring price watches
Tell your agent: "Watch Brent and TTF hourly, and summarize what changed each time I start a session." It calls opa_create_price_subscription once, then opa_get_subscription_events at the start of each session to pull everything recorded since its last cursor. The watch runs on the API side on your chosen interval (free tier: 1 watch, hourly).
That's the difference between an agent that can quote a price and an agent with a standing market desk: the data pipeline runs on a schedule whether or not anyone is chatting.
Frequently Asked Questions
Q: What is an oil price MCP server?
A: An MCP (Model Context Protocol) server exposes tools that AI agents like Claude and Cursor can call. The OilPriceAPI MCP server gives agents 26 tools covering spot prices, historical data, futures curves, marine fuels, rig counts, state diesel prices, and persistent price alerts.
Q: Do I need an API key to try it?
A: No. The server runs in keyless demo mode out of the box: the price tools serve live prices for a limited commodity set. An API key unlocks 40+ commodities, history, futures, and alerts — 7-day free trial, then a free tier of 200 requests per month.
Q: Which AI clients does it work with?
A: Claude Desktop (one-click .mcpb bundle or JSON config), Claude Code (claude mcp add or .mcp.json), Cursor, VS Code with Cline, and Windsurf — any MCP client that can launch a stdio server via npx.
Q: How fresh is the data my agent gets?
A: Every price response carries a source timestamp and a freshness status, so your agent can report exactly how old a quote is. Spot prices update at market cadence during trading hours; some series, like retail diesel, update daily or weekly.
Q: Can my agent set alerts that keep running after the chat ends?
A: Yes. The authenticated alert and subscription tools create persistent, server-side alerts and recurring watches tied to your account. They notify you by email or webhook — no chat session required.
Give Your Agent a Market Desk
Ready to Get Started?
One npx command, no API key needed to try it. Full catalog with a free key: 7-day trial, then 200 requests/month free.
npx -y oilpriceapi-mcp
26 tools • 70+ commodities • Keyless demo mode • Persistent alerts