Data source: Federal Reserve Economic Data (FRED)
Overview
Commodity Prices wraps Federal Reserve Economic Data (FRED), handling authentication, pagination, and rate limits for you. This tutorial covers all 5 tools with working code examples you can copy and run.
Prerequisites
- Sign up at https://context.gnist.ai/signup for a free API key (100 calls/day).
- Choose your integration method: MCP protocol or REST API.
Connect via MCP
Add to your MCP client config (Claude Desktop, Cursor, etc.):
{
"mcpServers": {
"gnist-commodity-prices": {
"url": "https://context.gnist.ai/mcp/commodity-prices/",
"headers": {
"Gnist-API-Key": "YOUR_API_KEY"
}
}
}
}
Tools (5)
get_commodity_price
Get price data for a commodity. Returns historical price observations from FRED for the specified commodity. Covers energy (oil, gas), precious metals (gold, silver, platinum), industrial metals (copper, aluminum, nickel), agricultural products (wheat, corn, coffee, cocoa), livestock, and forestry. Common commodities: - crude-oil-wti — WTI Crude Oil (daily, USD/barrel) - crude-oil-brent — Brent Crude Oil (daily, USD/barrel) - natural-gas — Henry Hub Natural Gas (daily, USD/MMBtu) - gold — Gold London PM Fix (daily, USD/troy oz) - silver — Silver London Fix (daily, USD/troy oz) - copper — Copper (monthly, USD/metric ton) - wheat — Wheat (monthly, USD/metric ton) - corn — Corn/Maize (monthly, USD/metric ton) - coffee — Coffee Arabica (monthly, USD/kg)
| Parameter | Type | Required | Description |
|---|---|---|---|
commodity | string | required | Commodity slug. Examples: "gold", "crude-oil-wti", "crude-oil-brent", "natural-gas", "silver", "copper", "wheat", "corn", "coffee". Use list_commodities to see all available options. |
observation_start | any | optional | Start date (YYYY-MM-DD). Omit to fetch from series start. |
observation_end | any | optional | End date (YYYY-MM-DD). Omit to fetch to latest available. |
frequency | any | optional | Aggregate to lower frequency: "d" (daily), "w" (weekly), "m" (monthly), "q" (quarterly), "a" (annual). |
limit | integer | optional | Maximum observations to return (default 100, max 100000). (default: 100) |
curl -X POST "https://context.gnist.ai/mcp/commodity-prices/" \
-H "Content-Type: application/json" \
-H "Gnist-API-Key: YOUR_API_KEY" \
-d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "get_commodity_price", "arguments": {"commodity": "example"}}}'
import httpx
resp = httpx.post(
"https://context.gnist.ai/mcp/commodity-prices/",
headers={"Gnist-API-Key": "YOUR_API_KEY"},
json={'id': 1,
'jsonrpc': '2.0',
'method': 'tools/call',
'params': {'arguments': {'commodity': 'example'},
'name': 'get_commodity_price'}},
)
print(resp.json())
list_commodities
List all available commodities. Returns the full catalog of commodities with their names, units, categories, and underlying FRED series IDs. Use this to discover valid commodity slugs for get_commodity_price.
| Parameter | Type | Required | Description |
|---|---|---|---|
category | any | optional | Filter by category: "energy", "precious-metals", "industrial-metals", "agricultural", "livestock", "forestry". Omit for all. |
curl -X POST "https://context.gnist.ai/mcp/commodity-prices/" \
-H "Content-Type: application/json" \
-H "Gnist-API-Key: YOUR_API_KEY" \
-d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "list_commodities", "arguments": {"category": "example"}}}'
import httpx
resp = httpx.post(
"https://context.gnist.ai/mcp/commodity-prices/",
headers={"Gnist-API-Key": "YOUR_API_KEY"},
json={'id': 1,
'jsonrpc': '2.0',
'method': 'tools/call',
'params': {'arguments': {'category': 'example'}, 'name': 'list_commodities'}},
)
print(resp.json())
list_commodity_categories
List commodity categories with counts. Returns the available categories (energy, precious-metals, industrial-metals, agricultural, livestock, forestry) and how many commodities each contains.
curl -X POST "https://context.gnist.ai/mcp/commodity-prices/" \
-H "Content-Type: application/json" \
-H "Gnist-API-Key: YOUR_API_KEY" \
-d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "list_commodity_categories", "arguments": {}}}'
import httpx
resp = httpx.post(
"https://context.gnist.ai/mcp/commodity-prices/",
headers={"Gnist-API-Key": "YOUR_API_KEY"},
json={'id': 1,
'jsonrpc': '2.0',
'method': 'tools/call',
'params': {'arguments': {}, 'name': 'list_commodity_categories'}},
)
print(resp.json())
compare_commodity_prices
Compare prices for multiple commodities aligned on a common time axis. Fetches price data for all specified commodities and aligns observations by date — only dates where all commodities have values are included. Useful for correlation analysis and cross-commodity comparisons. Example: compare_commodity_prices(["crude-oil-wti", "natural-gas"], frequency="m")
| Parameter | Type | Required | Description |
|---|---|---|---|
commodities | list[string] | required | List of 2-10 commodity slugs to compare (e.g. ["gold", "silver"]). |
observation_start | any | optional | Start date (YYYY-MM-DD) applied to all commodities. |
observation_end | any | optional | End date (YYYY-MM-DD) applied to all commodities. |
frequency | any | optional | Aggregate to common frequency before aligning: "m" (monthly), "q" (quarterly), "a" (annual). |
curl -X POST "https://context.gnist.ai/mcp/commodity-prices/" \
-H "Content-Type: application/json" \
-H "Gnist-API-Key: YOUR_API_KEY" \
-d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "compare_commodity_prices", "arguments": {"commodities": "[\"gold\""}}}'
import httpx
resp = httpx.post(
"https://context.gnist.ai/mcp/commodity-prices/",
headers={"Gnist-API-Key": "YOUR_API_KEY"},
json={'id': 1,
'jsonrpc': '2.0',
'method': 'tools/call',
'params': {'arguments': {'commodities': '["gold"'},
'name': 'compare_commodity_prices'}},
)
print(resp.json())
report_feedback
Report a bug, feature request, or general feedback for this data source. Use this when something doesn't work as expected, when you'd like a new feature, or when you have suggestions for improvement. Args: feedback: Describe the issue or suggestion. feedback_type: One of 'bug', 'feature_request', or 'general'.
| Parameter | Type | Required | Description |
|---|---|---|---|
feedback | string | required | |
feedback_type | string | optional | (default: general) |
curl -X POST "https://context.gnist.ai/mcp/commodity-prices/" \
-H "Content-Type: application/json" \
-H "Gnist-API-Key: YOUR_API_KEY" \
-d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "report_feedback", "arguments": {"feedback": "example"}}}'
import httpx
resp = httpx.post(
"https://context.gnist.ai/mcp/commodity-prices/",
headers={"Gnist-API-Key": "YOUR_API_KEY"},
json={'id': 1,
'jsonrpc': '2.0',
'method': 'tools/call',
'params': {'arguments': {'feedback': 'example'}, 'name': 'report_feedback'}},
)
print(resp.json())
Common Patterns
Use
list_commodities to find items, then get_commodity_price to get full details. This two-step pattern is common for exploring data before drilling down.Several tools support
limit, offset, or page parameters. Start with small limits during development, then increase for production queries.FAQ
What data does Commodity Prices provide?
Real-time and historical commodity prices — oil, gas, gold, silver, copper, wheat, and 20+ more. It exposes 5 tools: get_commodity_price, list_commodities, list_commodity_categories, compare_commodity_prices, report_feedback.
What do I need to get started?
A Gnist API key (free tier: 100 calls/day). Sign up at https://context.gnist.ai/signup.
What format does the Commodity Prices API return?
JSON, via either MCP protocol (JSON-RPC 2.0) or REST API.