CommodityPriceAPI MCP Server
OfficialQuery real-time, historical, and comparative commodity prices (gold, silver, oil, and 140+ others) through an MCP client, with 8 tools exposed in the schema (the README advertises 9 — get_intraday_rates is described but absent from the schema).
List supported symbols (
list_symbols) — discover valid commodity codes, categories, default currencies, and units before making rate calls.Get latest prices (
get_latest_rates) — current rates for one or more symbols in a single call, optionally converted to a target quote currency. Rates may lag up to 10 minutes.Gold and silver shortcuts (
get_gold_price,get_silver_price) — fetch the latest XAU/XAG rate directly, with optional currency conversion.Historical OHLC data (
get_historical_rates) — open/high/low/close for one or more symbols on a past date, back to 1990; falls back to the nearest available date.Time series (
get_time_series) — daily rates across a date range of up to 1 year.Fluctuation analysis (
get_fluctuation) — start/end rates plus absolute and percent change between two dates.Account/quota check (
get_usage) — view current plan, quota, and usage for the configured API key.
Note: symbol codes like GOLD or retired codes (e.g. PL) are auto-resolved to canonical symbols; quote conversion requires a Premium/Plus plan, and get_usage/list_symbols take no parameters.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@CommodityPriceAPI MCP Server What is the current price of gold?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
CommodityPriceAPI MCP Server
Official MCP server for CommodityPriceAPI. Exposes 9 MCP tools for real-time, intraday and historical commodity prices — gold, silver, oil, natural gas, wheat, coffee, and 140+ other commodities. Your AI assistant queries the market in plain English; the MCP server handles the API calls.
Works with Claude Desktop, Claude Code, Cursor, Windsurf, VS Code, Cline, Codex, and any other MCP-compatible client.
Item | Value |
Package |
|
Transport |
|
Node.js |
|
Quick Start
Get a free CommodityPriceAPI key — free 7-day trial, 2,000 requests, no card required.
Cursor users can install in one click:
Everyone else: add this to your MCP client config (see Install by Client for the exact file path):
{
"mcpServers": {
"commoditypriceapi": {
"command": "npx",
"args": ["-y", "@commoditypriceapi/mcp"],
"env": {
"COMMODITYPRICEAPI_KEY": "<YOUR_API_KEY>"
}
}
}
}Restart your client.
Test it: ask "What's the current gold price?"
Related MCP server: metalsmarket-bot
Table of Contents
Install by Client
Requirements
Node.js 18 or later
npxavailable in your terminalA CommodityPriceAPI key — sign up free
Claude Desktop
Add to claude_desktop_config.json (Settings → Developer → Edit Config):
{
"mcpServers": {
"commoditypriceapi": {
"command": "npx",
"args": ["-y", "@commoditypriceapi/mcp"],
"env": {
"COMMODITYPRICEAPI_KEY": "<YOUR_API_KEY>"
}
}
}
}Restart Claude Desktop after saving.
Claude Code
claude mcp add commoditypriceapi --env COMMODITYPRICEAPI_KEY=<YOUR_API_KEY> -- npx -y @commoditypriceapi/mcpStart a new Claude Code session after adding the server.
Cursor
One-click install:
Or add to .cursor/mcp.json manually:
{
"mcpServers": {
"commoditypriceapi": {
"command": "npx",
"args": ["-y", "@commoditypriceapi/mcp"],
"env": {
"COMMODITYPRICEAPI_KEY": "<YOUR_API_KEY>"
}
}
}
}Restart Cursor after saving.
Windsurf
Add to ~/.codeium/windsurf/mcp_config.json:
{
"mcpServers": {
"commoditypriceapi": {
"command": "npx",
"args": ["-y", "@commoditypriceapi/mcp"],
"env": {
"COMMODITYPRICEAPI_KEY": "<YOUR_API_KEY>"
}
}
}
}Restart Windsurf after saving.
VS Code / GitHub Copilot
Add to your VS Code settings.json:
{
"mcp": {
"servers": {
"commoditypriceapi": {
"command": "npx",
"args": ["-y", "@commoditypriceapi/mcp"],
"env": {
"COMMODITYPRICEAPI_KEY": "<YOUR_API_KEY>"
}
}
}
}
}Restart VS Code after saving.
Cline
Open MCP Servers panel → Configure → Advanced MCP Settings. Add to cline_mcp_settings.json:
{
"mcpServers": {
"commoditypriceapi": {
"command": "npx",
"args": ["-y", "@commoditypriceapi/mcp"],
"env": {
"COMMODITYPRICEAPI_KEY": "<YOUR_API_KEY>"
}
}
}
}Restart Cline after saving.
Codex CLI
codex mcp add commoditypriceapi --env COMMODITYPRICEAPI_KEY=<YOUR_API_KEY> -- npx -y @commoditypriceapi/mcp
codex mcp listStart a new Codex session after adding the server.
Any Other MCP Client
Use this config:
{
"command": "npx",
"args": ["-y", "@commoditypriceapi/mcp"],
"env": {
"COMMODITYPRICEAPI_KEY": "<YOUR_API_KEY>"
}
}Verify It Works
Try these after setup:
Prompt | Expected tool |
What's the current gold price? |
|
Get the latest silver and Brent crude prices. |
|
Show gold's hourly price on November 4th, 2026. |
|
What was the gold price on January 2nd, 2020? |
|
Show daily gold prices for the first week of August 2026. |
|
How much did gold change between January and August 2026? |
|
Which commodity symbols do you support? |
|
How much of my API quota is left? |
|
Tool Reference
All 9 tools map 1:1 to CommodityPriceAPI v3 endpoints. Tools that take symbols accept a comma-separated list; get_intraday_rates takes a single symbol (e.g. XAU,XAG,XPT,BRENTOIL-SPOT). Use list_symbols to look up valid symbols — there are 245 across Metals, Energy, Agriculture, and more.
Precious metals use ISO 4217 codes: XAU (gold), XAG (silver), XPT (platinum), XPD (palladium). Copper is XCU. The retired codes PL, PA, and HG still work on v3 — they are auto-resolved to the new symbol (see the note below).
get_latest_rates
GET /v3/rates/latest — latest rates for one or more symbols. Rates may lag up to 10 minutes depending on plan.
Parameter | Required | Description |
| Yes | Comma-separated symbols, e.g. |
| No | Target quote currency (e.g. |
| No |
|
Note on unresolved: v3 appends an unresolved map, keyed by the symbol you typed, in three cases. The same applies to get_intraday_rates, get_historical_rates, get_time_series, and get_fluctuation.
Case | HTTP | What the entry holds |
Symbol is not a catalogue code but has exactly one match (e.g. |
|
|
Some symbols could not be returned |
|
|
No symbol resolved |
| Tool returns a |
get_gold_price
GET /v3/rates/latest/xau — shortcut for the latest gold (XAU) rate, including bid/ask.
Parameter | Required | Description |
| No | Target quote currency. Premium/Plus plans only. |
| No |
|
| No |
|
get_silver_price
GET /v3/rates/latest/xag — shortcut for the latest silver (XAG) rate, including bid/ask.
Parameter | Required | Description |
| No | Target quote currency. Premium/Plus plans only. |
| No |
|
| No |
|
get_intraday_rates
GET /v3/rates/intraday — the rates of one symbol through a single UTC day at a chosen interval, from one minute to one day. Each point is the rate recorded at that exact mark (14:05 is the rate observed at 14:05 UTC), not an OHLC bar. Advanced and Enterprise plans only — other plans get 402.
Parameter | Required | Description |
| Yes | Exactly one symbol, e.g. |
| Yes |
|
| Yes | UTC day, |
| No | First mark of the window, |
| No |
|
A result holds at most 100 points. When nextStartTime is not null, call again with startTime set to it to get the next page; from 15m upward a whole day fits in one call. Marks with no recorded rate are left out, so count can be below the window size. Only symbols updated every second, minute, or 10 minutes have intraday data — others return 400 BAD_REQUEST. Rates are in the symbol's own currency; there is no quote parameter.
get_historical_rates
GET /v3/rates/historical — open/high/low/close rates for one or more symbols on a specific past date, available back to 1990-01-01. If no rate exists for that exact date, the API returns the nearest available date.
Parameter | Required | Description |
| Yes | Comma-separated symbols |
| Yes |
|
get_time_series
GET /v3/rates/time-series — daily historical rates for one or more symbols between two dates. Max span: 1 year.
Parameter | Required | Description |
| Yes | Comma-separated symbols |
| Yes |
|
| Yes |
|
get_fluctuation
GET /v3/rates/fluctuation — how each symbol changed between two dates: start rate, end rate, absolute change, and percent change.
Parameter | Required | Description |
| Yes | Comma-separated symbols |
| Yes |
|
| Yes |
|
list_symbols
GET /v3/symbols — all supported commodity symbols with name, category, quote currency, unit, and update interval. Takes no parameters. Call this before rate tools when unsure of a symbol.
get_usage
GET /v3/usage — current plan, quota, and usage for the configured API key. Takes no parameters.
Prompt Examples
Live prices
What's the current gold price?
What's gold per gram right now?
Get the latest prices for silver, platinum, copper, and WTI crude.
What's gold trading at in euros?
Historical data
What was the price of wheat on January 2nd, 2026?
Compare gold and silver prices over the last 30 days.
Show me daily natural gas prices for Q1 2026.
Intraday
Show gold's hourly price on November 4th, 2026.
Give me silver's 5-minute rates between 14:00 and 16:00 UTC yesterday.
When did Brent crude peak during yesterday's session?
Price changes
How much did Brent crude fluctuate this quarter?
Did gold go up or down since the start of the year, and by how much?
Discovery and account
Which commodity symbols do you support for energy?
How much of my API quota is left this month?
Example Answers and Tool Output
The text answers show what a client might say; exact wording depends on the model. JSON blocks are raw tool output.
Latest gold price
Prompt: What's the current gold price?
Example answer: Gold (XAU) is currently trading at $4,386.23 per troy ounce (bid $4,385.93 / ask $4,386.23).
{
"success": true,
"timestamp": 1786617187,
"rates": {
"XAU": {
"rate": 4386.23,
"bid": 4385.93,
"ask": 4386.23
}
},
"metadata": {
"XAU": {
"unit": "T.oz",
"quote": "USD"
}
}
}Historical rate
Prompt: What was the gold price on January 2nd, 2020?
Example answer: On 2020-01-02, gold opened at $1,518.26 and closed at $1,528.76 per troy ounce (high $1,531.31, low $1,517.15).
{
"success": true,
"date": "2020-01-02",
"rates": {
"XAU": {
"date": "2020-01-02",
"open": 1518.26,
"high": 1531.31,
"low": 1517.15,
"close": 1528.76
}
}
}Intraday rates
Prompt: Show gold's hourly price on October 14th, 2026, from 18:00 UTC.
Example answer: Gold moved between $3,958.84 and $3,967.38 per troy ounce from 18:00 to 23:00 UTC, ending the day at its high of $3,967.38.
{
"success": true,
"symbol": "XAU",
"date": "2026-10-14",
"interval": "1h",
"startTime": "18:00",
"count": 6,
"nextStartTime": null,
"rates": {
"2026-10-14T18:00:00Z": 3961.27,
"2026-10-14T19:00:00Z": 3958.84,
"2026-10-14T20:00:00Z": 3963.1,
"2026-10-14T21:00:00Z": 3966.45,
"2026-10-14T22:00:00Z": 3964.92,
"2026-10-14T23:00:00Z": 3967.38
},
"metadata": {
"XAU": { "unit": "T.oz", "quote": "USD" }
}
}Fluctuation
Prompt: How much did gold change between January 2nd and August 12th, 2026?
Example answer: Gold rose from $4,332.01 to $4,400.12 per troy ounce — up $68.11, or +1.57%.
{
"success": true,
"startDate": "2026-01-02",
"endDate": "2026-08-12",
"rates": {
"XAU": {
"startRate": 4332.01,
"endRate": 4400.12,
"change": 68.11,
"changePercent": 1.57
}
}
}Auto-resolved symbol
Prompt: What's the price of GOLD and platinum?
Example answer: Gold (XAU) is $4,386.23 and platinum (XPT) is $1,412.50 per troy ounce. Note: GOLD isn't a symbol code, so the API returned it under XAU.
{
"success": true,
"timestamp": 1786617187,
"rates": {
"XAU": 4386.23,
"XPT": 1412.5
},
"metadata": {
"XAU": { "unit": "T.oz", "quote": "USD" },
"XPT": { "unit": "T.oz", "quote": "USD" }
},
"unresolved": {
"GOLD": {
"message": "GOLD is not a symbol code used by this API. Gold is available as \"XAU\", so its rate was returned under that symbol.",
"resolvedTo": "XAU"
}
}
}Status is 200 — an entry with resolvedTo never downgrades the response.
Error Codes
Tool calls never crash the server. Upstream errors are returned as structured tool results with error, code, message, and a guidance field so the client can explain what went wrong instead of echoing a status code.
Code | Meaning |
| Invalid parameter — e.g. an intraday |
| Missing or invalid API key — check |
| Your trial or subscription doesn't cover this request (e.g. |
| API key usage limit reached — upgrade or wait for quota reset |
| Symbol not found — call |
| Rate limited — wait a minute and retry |
| Request to the upstream API timed out (see |
| Server could not reach the upstream API |
Example error result for an invalid symbol:
{
"error": "SYMBOL_NOT_FOUND",
"code": 404,
"message": "The symbol is not supported, please visit the documentation for a list of supported symbols",
"guidance": "Call list_symbols to see valid commodity symbols."
}How It Works
This is a stdio MCP server that wraps the CommodityPriceAPI v3 REST API.
At runtime:
Your MCP client starts the server process via
npx.The client reads the tool list.
When a prompt matches a tool, the client calls it.
The server validates inputs, calls the CommodityPriceAPI, and returns structured JSON.
The server sends your API key to CommodityPriceAPI via both the x-api-key header and the apiKey query parameter — the upstream API accepts either, so this covers all cases without extra config.
Environment Variables
Variable | Required | Default | Description |
| Yes | Your CommodityPriceAPI key | |
| No |
| Upstream request timeout in ms |
Building from Source
git clone https://github.com/Commodity-Price-API/commoditypriceapi-mcp.git
cd commoditypriceapi-mcp
npm install
npm run buildRun it directly:
COMMODITYPRICEAPI_KEY=<YOUR_KEY> node dist/cli.jsInspect with the MCP Inspector:
COMMODITYPRICEAPI_KEY=<YOUR_KEY> npx @modelcontextprotocol/inspector node dist/cli.jsTroubleshooting
Client uses an old tool list after updating: Restart the client and confirm it loaded the latest npm version.
401 errors: Check that COMMODITYPRICEAPI_KEY is set in your MCP client config's env block.
A symbol is missing from a multi-symbol response: Look at the unresolved map in the result. If the entry has resolvedTo, nothing is missing — the rate is in rates under that symbol (e.g. GOLD → XAU, PL → XPT). Otherwise each missing symbol has a message and usually suggestions (e.g. OIL → WTIOIL-SPOT, BRENTOIL-SPOT, …). If there are no suggestions, call list_symbols to find the correct symbol.
499 timeouts: The upstream API did not respond in time. Increase COMMODITYPRICEAPI_REQUEST_TIMEOUT_MS (default: 15000 ms).
Pricing
Free 7-day trial with 2,000 requests, no card required. For plan details, see the CommodityPriceAPI pricing page.
Links
License
Available Tools
8 toolsget_fluctuationGet commodity price fluctuationA
Returns how one or more commodity symbols changed between a start and end date: start rate, end rate, absolute change, and percent change.
Inputs: endDate (required), symbols (required), startDate (required).
get_gold_priceGet latest gold (XAU) priceA
Shortcut for the latest gold (XAU) rate without needing to pass a symbols list.
Inputs: quote.
get_historical_ratesGet historical commodity ratesA
Returns open/high/low/close rates for one or more symbols on a specific past date (available back to 1990-01-01). If no rate exists for that exact date, the API returns the nearest available date.
Inputs: date (required), symbols (required).
get_latest_ratesGet latest commodity ratesA
Returns the latest rates for one or more commodity symbols (e.g. gold, silver, crude oil). Rates may lag up to 10 minutes depending on plan. Use 'quote' to convert to a specific currency (Premium/Plus plans only).
Inputs: symbols (required), quote.
get_silver_priceGet latest silver (XAG) priceA
Shortcut for the latest silver (XAG) rate without needing to pass a symbols list.
Inputs: quote.
get_time_seriesGet commodity time seriesA
Returns daily historical rates for one or more symbols between two dates. The date range cannot exceed 1 year.
Inputs: endDate (required), symbols (required), startDate (required).
get_usageGet API usageA
Returns the current plan, quota, and usage for the configured CommodityPriceAPI key.
Inputs: no named parameters.
list_symbolsList supported commodity symbolsA
Returns all commodity symbols supported by CommodityPriceAPI, including category, default currency, and unit. Use this to look up a symbol before calling rate tools.
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Tools are largely distinct, with clear separation between account usage, symbol lookup, latest rates, historical rates, time series, and fluctuation. The get_gold_price and get_silver_price shortcuts overlap with get_latest_rates, but their descriptions explicitly label them as shortcuts, reducing confusion.
All tool names follow a consistent verb_noun pattern using snake_case, primarily 'get_' with one 'list_' exception. The naming is predictable and uniform across the entire set.
With 8 tools, the server is well-scoped for its purpose of providing commodity price data. Each tool covers a meaningful aspect (usage, symbol metadata, current rates, historical, time series, fluctuation), and the two shortcuts are acceptable conveniences.
The tool surface covers the core domain lifecycle: discovering symbols, fetching current and historical prices, time series, and fluctuation analysis. Currency conversion is available via a parameter, and usage tracking is included. No significant gaps are apparent.
Related MCP Connectors
Official Intrinio MCP server. US stock prices, options and fundamentals for AI agents.
Official MCP server of Hasfiyat Altın API: live Turkish gold & FX prices (TRY), history, calc.
Unlock the power of real-time cryptocurrency data with our Crypto Price Insights MCP server.
Official MCP server for subfeed.app — the cloud for agents. 15+ tools for AI agents to register, build, and deploy other agents. Zero human required. Start here: subfeed.app/skill.md
Related MCP Servers
AlicenseAqualityCmaintenanceMCP server that provides access to SiftingIO market data, including live prices, SEC filings, OHLCV bars, 13F holdings, market status, and economic calendar tools for AI assistants.3636 npm1MIT- FlicenseNot gradedqualityDmaintenanceEnables LLM clients to query live and historical metal and commodity prices from metalsmarket.net through an MCP server.-
- AlicenseNot gradedqualityBmaintenanceFinancialFilings gives AI assistants and agents official filings, as published (annual and interim reports, ad-hoc disclosures, insider transactions, ESG reports) and standardized financials for listed companies in the US, EU, UK, APAC and LATAM. Remote MCP server at https://mcp.financialfilings.com/mcp with OAuth sign-in: no API key to copy, free for any FinancialFilings account.2MIT
- AlicenseBqualityDmaintenanceAn MCP server that brings public gold (XAUUSD) market data into Claude, ChatGPT, and other MCP clients. Free tier includes 13 tools for price, OHLCV, macro context, correlations, and more.1325 PyPI9MIT