# OilPrice MCP

> OilPrice MCP Server provides real-time, historical data for over 50 energy commodities. It lets your agent pull current spot prices for WTI crude, Brent international oil, Natural Gas, Diesel, and more. You can query intraday movements, weekly trends, or custom date ranges directly into any AI workflow.

## Overview
- **Category:** data-analytics
- **Price:** Free
- **Tags:** commodity-prices, market-data, real-time-api, energy-trading, financial-data, rest-api

## Description

**OilPrice API - Track WTI & Brent Commodity Prices**

This server gives your agent instant access to real-time and historical data for over 50 energy commodities. You're pulling live market intelligence directly into your AI workflow, making sure you don't gotta rely on old spreadsheets or slow feeds. It covers everything from crude oil benchmarks to refined fuels like diesel.

**Getting Current Prices: Snapshot Data**

To get a quick read on the market, you can use `get_latest_prices`. This single call returns the most current spot prices for every energy commodity supported by the API. Need to focus just on the big players? You've got targeted tools ready. Calling `get_wti_price` pulls the immediate spot price for West Texas Intermediate (WTI) crude oil, which is the main US benchmark. For international tracking, use `get_brent_price` to get the current spot rate for Brent crude oil, a key global trading standard. You can also pull specific refined fuel pricing; just call `get_diesel_price` for the latest US Ultra Low Sulfur Diesel (ULSD) price, which is crucial if you're tracking transportation costs. If you need Natural Gas rates right now, `get_natural_gas_price` retrieves the Henry Hub spot price. It’s simple—you tell your agent what commodity you want, and it gives you that live number.

**Analyzing Market Movements: Time-Based Data**

If current prices aren't enough, you gotta know what happened leading up to this moment. For short-term volatility, `get_past_day_prices` gathers hourly price data, showing exactly how commodities moved over the last 24 hours. You can check out medium-range trends too: calling `get_past_week_prices` provides daily closing prices for commodity movements covering seven days. If you need a deeper dive into recent history, `get_past_month_prices` collects daily price data spanning the last 30 days.

For custom analysis—say, checking prices from Q2 of last year through early June—you use `get_historical_prices`. This function lets your agent pull detailed price records for any specific start date and end date range. **Note:** Using this historical tool requires the paid tier access.

**Discovering What's Available: The Commodity List**

Don't know what commodity codes you need? Run `list_commodities`. This function returns a comprehensive list of every energy product, confirming all 50+ available commodities and their unique API codes. You can then pass these exact codes to any other tool.

**Putting It Together: Workflow Examples**

You don't gotta run five separate calls just to analyze one week. Your agent handles that complexity for you. If you need a full picture, you might first call `list_commodities` to confirm the code for 'Junk Fuel'. Then, you can use `get_historical_prices` with that specific code and a custom date range to plot its movement. You could follow up by calling `get_latest_prices` just to see where the market is standing right now compared to last Tuesday's price point.

It’s about layering data: pulling the current spot rate via `get_wti_price`, then running `get_past_day_prices` to map out the hourly swings, and finally using `get_historical_prices` on a custom date range for long-term context. Your agent structures this data so you can analyze market dynamics immediately, all without leaving your chat environment.

## Tools

### get_brent_price
Retrieves the current spot price for Brent crude oil, a primary global benchmark.

### list_commodities
Lists all available energy commodities and their unique codes supported by the API.

### get_diesel_price
Gets the current US Ultra Low Sulfur Diesel (ULSD) price, critical for transportation cost tracking.

### get_historical_prices
Fetches detailed price data for a commodity over any custom start and end date range (paid tier).

### get_latest_prices
Returns the most up-to-date spot prices for all available energy commodities.

### get_natural_gas_price
Retrieves the current Henry Hub price for US Natural Gas.

### get_past_day_prices
Gathers hourly price data showing commodity movements over the last 24 hours.

### get_past_month_prices
Provides daily price data for a specific commodity covering the last 30 days.

### get_past_week_prices
Gathers daily price data showing commodity movements over the last 7 days.

### get_wti_price
Retrieves the current spot price for West Texas Intermediate (WTI) crude oil, the US benchmark.

## Prompt Examples

**Prompt:** 
```
What is the current price of WTI crude oil?
```

**Response:** 
```
Fetching latest WTI price... Current WTI Crude is trading at $78.45 USD per barrel. The price was last updated 2 minutes ago. WTI has been trading in a $77-79 range this session.
```

**Prompt:** 
```
Show me natural gas prices for the last week.
```

**Response:** 
```
Retrieving past week natural gas prices... Henry Hub Natural Gas has traded between $2.72-$2.95/MMBtu over the last 7 days. Current price is $2.85/MMBtu, up 3% from last week. Prices have been supported by increased heating demand and steady LNG export volumes.
```

**Prompt:** 
```
Compare WTI and Brent crude prices today.
```

**Response:** 
```
Fetching both benchmarks... WTI Crude is at $78.45/bbl while Brent Crude is at $82.30/bbl. The WTI-Brent spread is currently $3.85, which is within the normal range. Brent's premium reflects tighter global supply and stronger international demand compared to US inventories.
```

## Capabilities

### Retrieve Current Spot Prices
Get instant pricing for any major commodity—WTI, Brent, Natural Gas, or refined fuels—using `get_latest_prices`.

### Analyze Specific Benchmarks
Pull targeted prices for key benchmarks like WTI (`get_wti_price`) and international Brent crude (`get_brent_price`).

### Track Short-Term Volatility
Analyze hourly price swings over the last 24 hours using `get_past_day_prices`.

### Review Medium to Long-Term Trends
Access daily pricing history for custom timeframes, from weekly trends (`get_past_week_prices`) up to a full month or more via `get_historical_prices`.

### Discover Commodity Codes
Run `list_commodities` when you need to confirm the codes and list of all 50+ available energy products.

## Use Cases

### Comparing Global vs. Domestic Oil Prices
A trader needs to know the spread between US and international oil markets. They ask their agent: 'Compare WTI and Brent today.' The agent runs both `get_wti_price` and `get_brent_price`, allowing the user to immediately calculate the current price spread for arbitrage analysis.

### Forecasting Next Month's Fuel Budget
A logistics manager needs a quarterly budget estimate. They ask for 'Diesel prices over the last 30 days.' The agent uses `get_past_month_prices` with the diesel code, giving them enough data to trend costs and predict spending fluctuations.

### Investigating Gas Price Spikes
An analyst notices recent natural gas volatility. They use `get_past_day_prices` for Natural Gas to pinpoint exactly when the sharp price movements occurred in the last 24 hours, helping them identify market triggers.

### Initial Data Discovery
A new user is unsure which energy commodity data they need. They simply ask: 'What types of commodities do you track?' The agent calls `list_commodities`, providing a comprehensive catalog and the necessary codes for them to proceed.

## Benefits

- Track real-time benchmarks. Instead of checking multiple websites, use `get_latest_prices` to get immediate spot quotes for WTI, Brent, Natural Gas, and more in one call.
- Analyze price movements over time. Use `get_past_day_prices` to see hourly volatility or `get_past_week_prices` to track short-term trends without manual graphing.
- Optimize purchasing timing. By running `get_diesel_price`, you instantly compare fuel costs against current market rates, informing your logistics decisions immediately.
- Build deep reports quickly. Use `get_historical_prices` with specific date ranges to pull data for long-term analysis and academic papers in minutes.
- Confirm scope fast. If you aren't sure which commodity code to use, just call `list_commodities`. It gives you a catalog of all 50+ supported energy products.

## How It Works

The bottom line is your AI client acts like a terminal connection to live energy market feeds, bringing complex financial data directly into your conversation or script.

1. First, connect your AI client to the OilPriceAPI server using a valid API key.
2. Next, tell your agent exactly what you need—e.g., 'Show me WTI prices for the last week' or 'What is the current diesel price?'
3. Your agent executes the correct tool call and returns clean, structured data for that commodity and time frame.

## Frequently Asked Questions

**How often are oil and gas prices updated?**
Oil, gas, and refined product prices (WTI, Brent, Natural Gas, Diesel, Gasoline, etc.) are updated every 5 minutes during market hours. Coal prices update daily. This ensures you have near real-time data for trading decisions and cost monitoring.

**How do I get an OilPriceAPI key and what does the free trial include?**
Visit https://oilpriceapi.com/ and sign up for a free account. The 7-day free trial includes 10,000 API requests, access to all 50+ commodities, all endpoints (latest, past day, past week, past month), and no credit card required. After the trial, paid plans start at $15/month. Rate limit on free tier: 60 requests/minute.

**What commodity codes are available?**
The API offers 50+ energy commodities. Key codes include: WTI_USD (WTI Crude), BRENT_CRUDE_USD (Brent Crude), NATURAL_GAS_USD (Henry Hub Gas), DIESEL_USD (Ultra Low Sulfur Diesel), GASOLINE_USD (RBOB Gasoline), HEATING_OIL_USD (No. 2 Heating Oil), JET_FUEL_USD (Aviation Fuel/Kerosene), COAL_USD (Newcastle Thermal Coal). Use the `list_commodities` tool to see the full catalog.

**Can I access historical price data for trend analysis?**
Yes! The free tier includes past_day (24h hourly), past_week (7d daily), and past_month (30d daily) endpoints. For custom date ranges beyond 30 days, use the `get_historical_prices` tool which requires a paid subscription. This is ideal for long-term trend analysis, backtesting trading strategies, and academic research.

**How do I compare WTI and Brent benchmarks using `get_latest_prices`?**
You must call the tool for both commodity codes: `WTI_USD` and `BRENT_CRUDE_USD`. This lets your agent calculate the current 'spread' between the two. Monitoring this spread is essential because it indicates global supply tension or US inventory changes.

**What’s the difference between `get_past_day_prices` and `get_past_week_prices`?**
Use `get_past_day_prices` when you need granular, hourly data for intraday volatility over 24 hours. For a wider view, run `get_past_week_prices`; this delivers daily closing prices across the last seven days.

**How do I track specific fuel costs using `get_diesel_price`?**
This tool gives you the current US Diesel price, which is vital for logistics and procurement teams. You can immediately check if refined product margins are tightening or widening compared to crude oil benchmarks.

**What should I do if a commodity code fails when calling `get_latest_prices`?**
If you get an error, first verify the spelling of your desired `commodity_code`. Always cross-reference codes against the output from the `list_commodities` tool. This resolves most API connection or syntax issues.