CommodityPriceAPI

io.github.Commodity-Price-API由 GitHub 账号 Commodity-Price-API 发布v1.2.3更新于 Oct 29, 2026

Real-time and historical prices for gold, silver, oil, and 130+ other commodities.

发布方自己的服务:PriceWin

已验证STDIO仅桌面金融数据与分析

概览

AI 生成的概览

CommodityPriceAPI 官方 MCP 服务器,让助手查询黄金、白银、原油等 140 多种商品的实时、日内与历史价格。

可以做什么
  • 获取一个或多个商品代码的最新报价,并提供黄金、白银快捷工具,含买卖价及按克、克拉或托拉计价选项
  • 按 1 分钟到 1 天的间隔获取单一商品的日内价格,可按起始时间分页
  • 查询可回溯至 1990 年的某日开高低收、最长一年的每日时间序列,以及两个日期之间的涨跌幅
  • 列出支持的 245 个商品代码及其名称、类别、计价单位和更新频率
  • 查看当前 API 密钥对应的套餐、配额与用量
适用场景
适合希望用自然语言询问金属、能源或农产品行情时使用,例如当前金价、某段历史价格,或某商品在一段时间内的涨跌幅度,无需自己编写 API 调用。
运行要求
通过 npx 以 stdio 在本地运行,需要 Node.js 18 或更高版本及 npx。必须在 COMMODITYPRICEAPI_KEY 环境变量中提供 CommodityPriceAPI 密钥,官方提供 7 天免费试用、2000 次请求。需要能访问 CommodityPriceAPI 服务的网络。可用 COMMODITYPRICEAPI_REQUEST_TIMEOUT_MS 调整上游超时(默认 15000 毫秒)。
安装前请注意
COMMODITYPRICEAPI_KEY 中的密钥会同时通过 x-api-key 请求头和 apiKey 查询参数发送给上游,可能出现在 URL 和日志中。部分功能受套餐限制:货币换算需 Premium/Plus,日内数据需 Advanced 或 Enterprise,否则返回 402。超出用量返回 403,触发限流返回 429。该服务器只读取行情数据,不执行交易。

安装

在 SourceWeft 中

  1. 打开 控制台中的 CommodityPriceAPI,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

CommodityPriceAPI MCP Server

[npm version] [GitHub] [Node.js] [License]

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.

ItemValue
Package@commoditypriceapi/mcp
Transportstdio
Node.js>=18

Quick Start

  1. Get a free CommodityPriceAPI key — free 7-day trial, 2,000 requests, no card required.

  2. Cursor users can install in one click:

    [Add to Cursor]

  3. Everyone else: add this to your MCP client config (see Install by Client for the exact file path):

json
{  "mcpServers": {    "commoditypriceapi": {      "command": "npx",      "args": ["-y", "@commoditypriceapi/mcp"],      "env": {        "COMMODITYPRICEAPI_KEY": "<YOUR_API_KEY>"      }    }  }}
  1. Restart your client.

  2. Test it: ask "What's the current gold price?"

Table of Contents

Install by Client

Requirements

  • Node.js 18 or later
  • npx available in your terminal
  • A CommodityPriceAPI key — sign up free

Claude Desktop

Add to claude_desktop_config.json (Settings → Developer → Edit Config):

json
{  "mcpServers": {    "commoditypriceapi": {      "command": "npx",      "args": ["-y", "@commoditypriceapi/mcp"],      "env": {        "COMMODITYPRICEAPI_KEY": "<YOUR_API_KEY>"      }    }  }}

Restart Claude Desktop after saving.

Claude Code

bash
claude mcp add commoditypriceapi --env COMMODITYPRICEAPI_KEY=<YOUR_API_KEY> -- npx -y @commoditypriceapi/mcp

Start a new Claude Code session after adding the server.

Cursor

One-click install:

[Add to Cursor]

Or add to .cursor/mcp.json manually:

json
{  "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:

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:

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:

json
{  "mcpServers": {    "commoditypriceapi": {      "command": "npx",      "args": ["-y", "@commoditypriceapi/mcp"],      "env": {        "COMMODITYPRICEAPI_KEY": "<YOUR_API_KEY>"      }    }  }}

Restart Cline after saving.

Codex CLI

bash
codex mcp add commoditypriceapi --env COMMODITYPRICEAPI_KEY=<YOUR_API_KEY> -- npx -y @commoditypriceapi/mcpcodex mcp list

Start a new Codex session after adding the server.

Any Other MCP Client

Use this config:

json
{  "command": "npx",  "args": ["-y", "@commoditypriceapi/mcp"],  "env": {    "COMMODITYPRICEAPI_KEY": "<YOUR_API_KEY>"  }}

Verify It Works

Try these after setup:

PromptExpected tool
What's the current gold price?get_gold_price
Get the latest silver and Brent crude prices.get_latest_rates with symbols=XAG,BRENTOIL-SPOT
Show gold's hourly price on November 4th, 2026.get_intraday_rates with interval=1h
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

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.

ParameterRequiredDescription
symbolsYesComma-separated symbols, e.g. XAU,XAG,BRENTOIL-SPOT
quoteNoTarget quote currency (e.g. EUR). Premium/Plus plans only; omit for each symbol's default currency.
metadataNotrue (default) or false. false omits the metadata map (per-symbol unit and quote currency) from the response.

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.

CaseHTTPWhat the entry holds
Symbol is not a catalogue code but has exactly one match (e.g. GOLD, or retired PL)200message + resolvedTo — the rate was returned under resolvedTo in rates. Informational, not a failure.
Some symbols could not be returned206message + optional suggestions ("did you mean"). Valid rates are still in rates.
No symbol resolved404Tool returns a SYMBOL_NOT_FOUND error carrying the same unresolved map.

get_gold_price

GET /v3/rates/latest/xau — shortcut for the latest gold (XAU) rate, including bid/ask.

ParameterRequiredDescription
quoteNoTarget quote currency. Premium/Plus plans only.
includeNogram, carat, or tola — adds a per-gram rate, per-gram rates at each purity from 24k to 8k, or a per-tola rate alongside the ounce rate.
metadataNotrue (default) or false. false omits the metadata map (per-symbol unit and quote currency) from the response.

get_silver_price

GET /v3/rates/latest/xag — shortcut for the latest silver (XAG) rate, including bid/ask.

ParameterRequiredDescription
quoteNoTarget quote currency. Premium/Plus plans only.
includeNogram, carat, or tola — adds a per-gram, per-carat, or per-tola rate alongside the ounce rate.
metadataNotrue (default) or false. false omits the metadata map (per-symbol unit and quote currency) from the response.

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.

ParameterRequiredDescription
symbolYesExactly one symbol, e.g. XAU. Sent to the API as symbols.
intervalYes1m, 5m, 10m, 15m, 30m, 45m, 1h, 2h, 4h, 8h, 12h, or 1d. Symbols updated every 10 minutes accept only multiples of 10 minutes (10m, 30m, 1h, 2h, 4h, 8h, 12h, 1d).
dateYesUTC day, YYYY-MM-DD. Not in the future; for today, points stop at the current UTC minute.
startTimeNoFirst mark of the window, HH:mm UTC. Default 00:00. Must fall on a mark of the interval (14:30 works for 5m or 30m, not 1h; 1d only allows 00:00).
metadataNotrue (default) or false. false omits the metadata map (unit and quote currency) from the response.

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.

ParameterRequiredDescription
symbolsYesComma-separated symbols
dateYesYYYY-MM-DD

get_time_series

GET /v3/rates/time-series — daily historical rates for one or more symbols between two dates. Max span: 1 year.

ParameterRequiredDescription
symbolsYesComma-separated symbols
startDateYesYYYY-MM-DD
endDateYesYYYY-MM-DD

get_fluctuation

GET /v3/rates/fluctuation — how each symbol changed between two dates: start rate, end rate, absolute change, and percent change.

ParameterRequiredDescription
symbolsYesComma-separated symbols
startDateYesYYYY-MM-DD
endDateYesYYYY-MM-DD

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).

json
{  "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).

json
{  "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.

json
{  "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%.

json
{  "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.

json
{  "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.

CodeMeaning
400Invalid parameter — e.g. an intraday interval the symbol doesn't support, a startTime off the interval's marks, a future date, or a symbol with no intraday data
401Missing or invalid API key — check COMMODITYPRICEAPI_KEY in your client config
402Your trial or subscription doesn't cover this request (e.g. quote conversion on a non-Premium plan, or get_intraday_rates below the Advanced plan)
403API key usage limit reached — upgrade or wait for quota reset
404Symbol not found — call list_symbols for valid symbols. DATA_NOT_FOUND means the symbol is valid but has no data for that date or window.
429Rate limited — wait a minute and retry
499Request to the upstream API timed out (see COMMODITYPRICEAPI_REQUEST_TIMEOUT_MS)
502Server could not reach the upstream API

Example error result for an invalid symbol:

json
{  "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:

  1. Your MCP client starts the server process via npx.
  2. The client reads the tool list.
  3. When a prompt matches a tool, the client calls it.
  4. 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

VariableRequiredDefaultDescription
COMMODITYPRICEAPI_KEYYesYour CommodityPriceAPI key
COMMODITYPRICEAPI_REQUEST_TIMEOUT_MSNo15000Upstream request timeout in ms

Building from Source

bash
git clone https://github.com/Commodity-Price-API/commoditypriceapi-mcp.gitcd commoditypriceapi-mcpnpm installnpm run build

Run it directly:

bash
COMMODITYPRICEAPI_KEY=<YOUR_KEY> node dist/cli.js

Inspect with the MCP Inspector:

bash
COMMODITYPRICEAPI_KEY=<YOUR_KEY> npx @modelcontextprotocol/inspector node dist/cli.js

Troubleshooting

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

MIT

来源:README.md,提交 f666af3

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v1.2.3最新Oct 29, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分

其他 Price 集成