CommodityPriceAPI MCP Server
Connect Claude, Cursor, Windsurf, VS Code, Cline, Codex, and any MCP-compatible client to real-time and historical commodity prices — gold, silver, oil, natural gas, wheat, coffee, and 520+ more. Your AI assistant queries the market in plain English; the MCP server handles the API calls. Use the hosted server with nothing to install, or run it locally with npx.
Quick start
Up and running in three steps.
Get a free API key
Sign up for an unlimited free trial for integrations — no card required — and copy your API key from the dashboard.
Connect the server
Add the hosted URL https://mcp.commoditypriceapi.com/mcp to your client and enter your key on the connect page. Prefer to run it yourself? Use the npx config instead.
Ask in plain English
Ask: "What's the current gold price?" Your AI assistant calls the API for you.
Hosted vs local
Both run the same server with the same 9 tools and answer the same prompts. They differ in where the server runs and how your API key reaches it.
| Hosted | Local (npx) | |
|---|---|---|
| Install | Nothing. Add the URL to your client. | Node.js 18+; npx fetches the package. |
| Connection | Streamable HTTP to mcp.commoditypriceapi.com/mcp | stdio, a process on your machine |
| API key | Entered once on our connect page. Your client stores an access token, not the key. | Stored in plain text in your client config (env block). |
| Works in | Claude on the web and desktop, and any client with remote MCP support | Desktop and terminal clients that can launch local processes |
| Updates | Always the latest version | npx -y picks up new releases when the client restarts |
| Tools | The same 9 tools | The same 9 tools |
How connecting to the hosted server works
The hosted server at https://mcp.commoditypriceapi.com/mcp uses OAuth 2.1, the sign-in flow built into the MCP specification. You never paste your key into a config file.
- 01Your client finds the sign-in endpoints from the server URL and registers itself. You do not create an OAuth app.
- 02It opens a CommodityPriceAPI connect page in your browser, showing the name of the app asking for access.
- 03You paste your API key and click Connect. The key is checked against your account before access is granted.
- 04Your client receives an access token and uses it for every tool call. To disconnect, remove the server or clear its authentication in your client.
Set up your client
Pick hosted or local, then your client. Either way you need a CommodityPriceAPI key.
Add a URL. Nothing to install; you sign in with your API key.
Runs on your machine with Node.js 18+. The key goes in your config.
Claude setup: hosted server
In Claude on the web or desktop, open Settings → Connectors → Add custom connector, name it CommodityPriceAPI and paste the URL below. Click Connect, then enter your API key on the page that opens.
Remote MCP server URL
https://mcp.commoditypriceapi.com/mcpHave your API key ready for the connect page. Find it in your dashboard.
Claude setup: local server (npx)
Add the block below to claude_desktop_config.json (Settings → Developer → Edit Config), then restart Claude Desktop. The local server only runs in Claude Desktop, not on claude.ai.
claude_desktop_config.json
{
"mcpServers": {
"commoditypriceapi": {
"command": "npx",
"args": ["-y", "@commoditypriceapi/mcp"],
"env": {
"COMMODITYPRICEAPI_KEY": "<YOUR_API_KEY>"
}
}
}
}Replace <YOUR_API_KEY> with the key from your dashboard.
Claude Code setup: hosted server
Run this command, start a new Claude Code session, type /mcp, pick commoditypriceapi and choose Authenticate. Your browser opens the connect page; enter your API key there.
Terminal
claude mcp add --transport http commoditypriceapi \
https://mcp.commoditypriceapi.com/mcpHave your API key ready for the connect page. Find it in your dashboard.
Claude Code setup: local server (npx)
Run this one command in your terminal, then start a new Claude Code session.
Terminal
claude mcp add commoditypriceapi \
--env COMMODITYPRICEAPI_KEY=<YOUR_API_KEY> \
-- npx -y @commoditypriceapi/mcpReplace <YOUR_API_KEY> with the key from your dashboard.
Cursor setup: hosted server
Install in one click or add the block below to .cursor/mcp.json (or ~/.cursor/mcp.json globally). Cursor shows a Needs login button next to the server; click it and enter your API key.
.cursor/mcp.json
{
"mcpServers": {
"commoditypriceapi": {
"url": "https://mcp.commoditypriceapi.com/mcp"
}
}
}Have your API key ready for the connect page. Find it in your dashboard.
Cursor setup: local server (npx)
Install in one click via Cursor's MCP deeplink, or add the block below to .cursor/mcp.json in your project (or ~/.cursor/mcp.json globally), then restart Cursor.
.cursor/mcp.json
{
"mcpServers": {
"commoditypriceapi": {
"command": "npx",
"args": ["-y", "@commoditypriceapi/mcp"],
"env": {
"COMMODITYPRICEAPI_KEY": "<YOUR_API_KEY>"
}
}
}
}Replace <YOUR_API_KEY> with the key from your dashboard.
Windsurf setup: hosted server
Add the block below to ~/.codeium/windsurf/mcp_config.json and refresh the MCP servers. Windsurf opens the connect page in your browser; enter your API key there. Note the key is serverUrl, not url.
mcp_config.json
{
"mcpServers": {
"commoditypriceapi": {
"serverUrl": "https://mcp.commoditypriceapi.com/mcp"
}
}
}Have your API key ready for the connect page. Find it in your dashboard.
Windsurf setup: local server (npx)
Add the block below to ~/.codeium/windsurf/mcp_config.json, then restart Windsurf.
mcp_config.json
{
"mcpServers": {
"commoditypriceapi": {
"command": "npx",
"args": ["-y", "@commoditypriceapi/mcp"],
"env": {
"COMMODITYPRICEAPI_KEY": "<YOUR_API_KEY>"
}
}
}
}Replace <YOUR_API_KEY> with the key from your dashboard.
VS Code setup: hosted server
Add the block below to your VS Code settings.json (works with GitHub Copilot). When the server starts, VS Code asks to sign in; allow it and enter your API key on the connect page.
settings.json
{
"mcp": {
"servers": {
"commoditypriceapi": {
"type": "http",
"url": "https://mcp.commoditypriceapi.com/mcp"
}
}
}
}Have your API key ready for the connect page. Find it in your dashboard.
VS Code setup: local server (npx)
Add the block below to your VS Code settings.json (works with GitHub Copilot), then restart VS Code. Note the extra mcp → servers nesting.
settings.json
{
"mcp": {
"servers": {
"commoditypriceapi": {
"command": "npx",
"args": ["-y", "@commoditypriceapi/mcp"],
"env": {
"COMMODITYPRICEAPI_KEY": "<YOUR_API_KEY>"
}
}
}
}
}Replace <YOUR_API_KEY> with the key from your dashboard.
Cline setup: hosted server
Open the MCP Servers panel → Configure → Advanced MCP Settings and add the block below to cline_mcp_settings.json. It connects through the mcp-remote bridge, which opens the connect page in your browser the first time. Needs Node.js 18+.
cline_mcp_settings.json
{
"mcpServers": {
"commoditypriceapi": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://mcp.commoditypriceapi.com/mcp"]
}
}
}Have your API key ready for the connect page. Find it in your dashboard.
Cline setup: local server (npx)
Open the MCP Servers panel → Configure → Advanced MCP Settings, add the block below to cline_mcp_settings.json, then restart Cline.
cline_mcp_settings.json
{
"mcpServers": {
"commoditypriceapi": {
"command": "npx",
"args": ["-y", "@commoditypriceapi/mcp"],
"env": {
"COMMODITYPRICEAPI_KEY": "<YOUR_API_KEY>"
}
}
}
}Replace <YOUR_API_KEY> with the key from your dashboard.
Codex CLI setup: hosted server
Add the server, then log in. codex mcp login opens the connect page in your browser; enter your API key there. Confirm with codex mcp list.
Terminal
codex mcp add commoditypriceapi --url https://mcp.commoditypriceapi.com/mcp
codex mcp login commoditypriceapiHave your API key ready for the connect page. Find it in your dashboard.
Codex CLI setup: local server (npx)
Run this one command in your terminal, then start a new Codex session. Confirm with codex mcp list.
Terminal
codex mcp add commoditypriceapi \
--env COMMODITYPRICEAPI_KEY=<YOUR_API_KEY> \
-- npx -y @commoditypriceapi/mcpReplace <YOUR_API_KEY> with the key from your dashboard.
Other setup: hosted server
Any client that supports remote MCP servers over Streamable HTTP with OAuth can connect with the details below; it discovers the sign-in endpoints from the URL on its own. If your client only supports stdio servers, use the mcp-remote bridge config shown on the Cline tab.
Remote MCP server
URL: https://mcp.commoditypriceapi.com/mcp
Transport: Streamable HTTP
Auth: OAuth 2.1 (dynamic client registration, PKCE)Have your API key ready for the connect page. Find it in your dashboard.
Other setup: local server (npx)
Any MCP-compatible client works — register a stdio server with this config wherever your client keeps its MCP settings.
MCP server config
{
"command": "npx",
"args": ["-y", "@commoditypriceapi/mcp"],
"env": {
"COMMODITYPRICEAPI_KEY": "<YOUR_API_KEY>"
}
}Replace <YOUR_API_KEY> with the key from your dashboard.
Verify it works
After setup, try these prompts — each one should trigger the tool listed next to it.
| Prompt | Expected tool |
|---|---|
| "What's the current gold price?" | get_gold_price |
| "Get the latest silver and Brent crude prices." | get_latest_rates |
| "Show gold's hourly price on November 4th, 2026." | get_intraday_rates |
| "What was the gold price on January 2nd, 2020?" | get_historical_rates |
| "Show daily gold prices for the first week of August 2026." | get_time_series |
| "How much did gold change between January and August 2026?" | get_fluctuation |
| "Which commodity symbols do you support?" | list_symbols |
| "How much of my API quota is left?" | get_usage |
Tool reference
9 tools, the full API surface — every CommodityPriceAPI v3 endpoint is exposed as an MCP tool your assistant can call. Parameters marked * are required.
| Tool | Endpoint | Parameters | What it does |
|---|---|---|---|
get_latest_rates | /v3/rates/latest | symbols*, quote | Latest rates for one or more symbols. Rates may lag up to 10 minutes depending on plan. |
get_gold_price | /v3/rates/latest/xau | quote, include | Shortcut for the latest gold (XAU) rate, including bid/ask. include=gram, tola or carat adds a per-gram, per-tola or per-carat breakdown next to the troy-ounce rate. |
get_silver_price | /v3/rates/latest/xag | quote, include | Shortcut for the latest silver (XAG) rate, including bid/ask. include=gram, tola or carat adds a per-gram, per-tola or per-carat breakdown next to the troy-ounce rate. |
get_intraday_rates | /v3/rates/intraday | symbol*, interval*, date*, startTime | Rates of one symbol through one UTC day, at an interval from 1m to 1d. Each point is the rate recorded at that exact mark, not an OHLC bar. Up to 100 points per call; pass nextStartTime back as startTime to page through the day. Advanced and Enterprise plans only. |
get_historical_rates | /v3/rates/historical | symbols*, date* | Open/high/low/close rates on a specific past date, back to 1990-01-01. If no rate exists for the exact date, the most recent earlier rate is returned together with its own date. |
get_time_series | /v3/rates/time-series | symbols*, startDate*, endDate* | Daily historical rates between two dates. Maximum span: 1 year. |
get_fluctuation | /v3/rates/fluctuation | symbols*, startDate*, endDate* | How each symbol changed between two dates: start rate, end rate, absolute change, and percent change. |
list_symbols | /v3/symbols | — | All 520+ supported symbols with name, category, quote currency, unit, and update frequency. Call this before rate tools when unsure of a symbol. |
get_usage | /v3/usage | — | Current plan, quota, and usage for the configured API key. |
symbolstakes a comma-separated list, e.g.XAU,XAG,BRENTOIL-SPOT. There are 520+ symbols across Metals, Energy, Agriculture, and more — see the full list of supported symbols.- Symbols that cannot be returned are never dropped silently. The result includes an
unresolvedmap keyed by the symbol you sent: asuggestionslist for ambiguous or unknown codes (HTTP 206, the valid rates are still inrates), orresolvedTowhen a code had exactly one match, e.g.GOLDis answered asXAU(HTTP 200). If nothing resolves, the tool returns aSYMBOL_NOT_FOUNDerror carrying the same map. quotereturns the rate in the currency you want. Ask "What is the gold price in euros?" and the assistant passesquote=EUR, so the rate comes back in EUR. Without it, each symbol is returned in its default currency. Available on the Standard, Advanced and Enterprise plans; the Basic plan and the legacy Lite plan ignore it and return the default quote for each symbol.get_intraday_ratestakes a singlesymboland anintervalof1m,5m,10m,15m,30m,45m,1h,2h,4h,8h,12hor1d. Symbols updated every 10 minutes accept only multiples of 10 minutes, and symbols updated hourly or less often have no intraday data. A call returns at most 100 points; whennextStartTimeis not null, the assistant passes it back asstartTimefor the next page. Rates come in the symbol's own currency (noquote). See the intraday endpoint docs for details.- Dates use
YYYY-MM-DDformat; intradaystartTimeusesHH:mmUTC.
Example prompts & output
Things you can ask — anything the API can answer, your assistant can answer.
Live prices
- "What's the current gold price?"
- "Get the latest prices for silver, 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 & price changes
- "Show gold's hourly price on November 4th, 2026."
- "When did Brent crude peak during yesterday's session?"
- "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 & account
- "Which commodity symbols do you support for energy?"
- "How much of my API quota is left this month?"
What the tool returns
Ask "What's the current gold price?" and get_gold_price returns structured JSON your assistant turns into a plain-English answer — e.g. "Gold (XAU) is currently trading at $4,386.23 per troy ounce (bid $4,385.93 / ask $4,386.23)."
Tool output
{
"success": true,
"timestamp": 1786617187,
"rates": {
"XAU": {
"rate": 4386.23,
"bid": 4385.93,
"ask": 4386.23
}
},
"metadata": {
"XAU": {
"unit": "T.oz",
"quote": "USD"
}
}
}Error codes
Tool calls never crash the server. Upstream errors come back as structured results with error, code, message, a guidance field and, for symbol errors, the unresolved map, so your assistant can explain what went wrong instead of echoing a status code. Partial results (HTTP 206) are not errors: they arrive as normal results with the valid rates plus unresolved.
| Code | Meaning |
|---|---|
400 | VALIDATION_ERROR — a required parameter is missing, a date is not in YYYY-MM-DD format, the start date is after the end date, a time-series range exceeds 365 days, include is not gram, tola or carat, or an intraday interval, date or startTime is not valid for the symbol. BAD_REQUEST — the symbol has no intraday data (it is updated hourly or less often). |
401 | UNAUTHORIZED — no API key was sent. Local server: check that COMMODITYPRICEAPI_KEY is set in your client config's env block. Hosted server: your client is not signed in, or its token has expired; reconnect from your client. |
402 | PAYMENT_REQUIRED — your trial has ended, your subscription is inactive, the request asks for more symbols than your plan allows per request, or get_intraday_rates was called on a plan below Advanced. |
403 | LIMIT_REACHED — monthly request quota used up. Upgrade or wait for the quota to reset. |
404 | USER_NOT_FOUND — the API key is invalid. SYMBOL_NOT_FOUND — none of the requested symbols resolved; the result carries an unresolved map with suggestions. QUOTE_NOT_FOUND — unsupported quote currency. RATE_NOT_FOUND / DATA_NOT_FOUND — the symbols are valid but have no data for that date, range or intraday window. |
429 | Rate limited — wait a minute and retry. |
499 | Request to the upstream API timed out (see COMMODITYPRICEAPI_REQUEST_TIMEOUT_MS). |
502 | Server could not reach the upstream API. |
Example error result for an invalid symbol:
Error result
{
"error": "SYMBOL_NOT_FOUND",
"code": 404,
"message": "The symbol is not supported, please visit the documentation for a list of supported symbols",
"unresolved": {
"ZW": {
"message": "Did you mean ZW-SPOT (Wheat Spot) or ZW-FUT (Wheat Futures)?",
"suggestions": ["ZW-SPOT", "ZW-FUT"]
},
"XYZ": {
"message": "We don't recognise this symbol code and could not match it to any commodity we carry. See our symbols page for the symbols this API uses."
}
},
"guidance": "None of the requested symbols are valid. Check the 'unresolved' map above for suggested symbols, or call list_symbols to see all valid commodity symbols."
}Environment variables
For the local server only: set these in the env block of your MCP client config. The hosted server needs no configuration.
| Variable | Required | Default | Description |
|---|---|---|---|
COMMODITYPRICEAPI_KEY | Yes | — | Your CommodityPriceAPI key. |
COMMODITYPRICEAPI_REQUEST_TIMEOUT_MS | No | 15000 | Upstream request timeout in milliseconds. |
Troubleshooting
The most common issues and their fixes. Still stuck? Contact support or open an issue on GitHub.
Hosted: the connect page says the API key isn't valid
Copy the key again from your dashboard and paste it without spaces. If you regenerated the key, the old one no longer works.
Hosted: tools stop working with invalid_token or 401
The client's access token has expired or was revoked. Clear the server's authentication in your client (in Claude Code: /mcp → Clear authentication) and connect again; the client registers itself and asks for your key once more.
Hosted: my client can't connect to a remote server
Some clients only run local stdio servers. Use the mcp-remote bridge from the Cline tab under Set up your client, or switch to the local server.
Local: client uses an old tool list after updating
Restart the client and confirm it loaded the latest npm version.
401 UNAUTHORIZED or 404 USER_NOT_FOUND
401 means no key reached the API: with the local server, check that COMMODITYPRICEAPI_KEY is set in your MCP client config's env block. 404 USER_NOT_FOUND means a key was sent but it is not valid: copy it again from your dashboard.
A symbol you asked for is missing from the response
Look at the unresolved map in the result; it is keyed by the symbol you sent. An entry with suggestions means the code was ambiguous or unknown — pick one of the suggested symbols, e.g. BRENTOIL-SPOT for Brent crude. An entry with resolvedTo means the rate was returned under that symbol instead. An entry saying the symbol is supported but has no rate means there is no data for that request. Call list_symbols to browse valid codes.
499 timeouts
The upstream API did not respond in time. On the local server, increase COMMODITYPRICEAPI_REQUEST_TIMEOUT_MS (default: 15000 ms). On the hosted server, retry the request.