@commoditypriceapi/mcp 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,17 +1,29 @@
1
1
  # CommodityPriceAPI MCP Server
2
2
 
3
- Official MCP server for [CommodityPriceAPI](https://commoditypriceapi.com). Exposes 8 MCP tools for real-time and historical commodity rates — gold, silver, oil, and 130+ other commodities — to any MCP-compatible client (Claude Desktop, Cursor, Windsurf, VS Code, Cline, etc).
3
+ [![npm version](https://img.shields.io/npm/v/%40commoditypriceapi%2Fmcp?logo=npm&label=npm&color=CB3837)](https://www.npmjs.com/package/@commoditypriceapi/mcp)
4
+ [![GitHub](https://img.shields.io/badge/GitHub-Commodity--Price--API-181717?logo=github)](https://github.com/Commodity-Price-API/commoditypriceapi-mcp)
5
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D18-5FA04E?logo=node.js&logoColor=white)](https://nodejs.org/)
6
+ [![License](https://img.shields.io/badge/license-MIT-16A34A)](https://github.com/Commodity-Price-API/commoditypriceapi-mcp/blob/main/LICENSE)
4
7
 
5
- | Item | Value |
6
- | --------- | ------------------------ |
7
- | Package | `@commoditypriceapi/mcp` |
8
- | Transport | `stdio` |
9
- | Node.js | `>=18` |
8
+ Official MCP server for [CommodityPriceAPI](https://commoditypriceapi.com). Exposes 8 MCP tools for real-time 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.
9
+
10
+ Works with Claude Desktop, Claude Code, Cursor, Windsurf, VS Code, Cline, Codex, and any other MCP-compatible client.
11
+
12
+ | Item | Value |
13
+ |------|-------|
14
+ | Package | `@commoditypriceapi/mcp` |
15
+ | Transport | `stdio` |
16
+ | Node.js | `>=18` |
10
17
 
11
18
  ## Quick Start
12
19
 
13
- 1. [Get a free CommodityPriceAPI key](https://commoditypriceapi.com/auth/signup)
14
- 2. Add this to your MCP client config:
20
+ 1. [Get a free CommodityPriceAPI key](https://commoditypriceapi.com/auth/signup) — free 7-day trial, 2,000 requests, no card required.
21
+
22
+ 2. Cursor users can install in one click:
23
+
24
+ [![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/install-mcp?name=commoditypriceapi&config=eyJjb21tYW5kIjoibnB4IC15IEBjb21tb2RpdHlwcmljZWFwaS9tY3AiLCJlbnYiOnsiQ09NTU9ESVRZUFJJQ0VBUElfS0VZIjoiIn19)
25
+
26
+ 3. Everyone else: add this to your MCP client config (see [Install by Client](#install-by-client) for the exact file path):
15
27
 
16
28
  ```json
17
29
  {
@@ -27,20 +39,161 @@ Official MCP server for [CommodityPriceAPI](https://commoditypriceapi.com). Expo
27
39
  }
28
40
  ```
29
41
 
30
- 3. Restart your client.
31
- 4. Test it: ask **"What's the current gold price?"**
42
+ 4. Restart your client.
43
+
44
+ 5. Test it: ask **"What's the current gold price?"**
45
+
46
+ ## Table of Contents
47
+
48
+ - [Quick Start](#quick-start)
49
+ - [Install by Client](#install-by-client)
50
+ - [Verify It Works](#verify-it-works)
51
+ - [Tool Reference](#tool-reference)
52
+ - [Prompt Examples](#prompt-examples)
53
+ - [Example Answers and Tool Output](#example-answers-and-tool-output)
54
+ - [Error Codes](#error-codes)
55
+ - [How It Works](#how-it-works)
56
+ - [Environment Variables](#environment-variables)
57
+ - [Building from Source](#building-from-source)
58
+ - [Troubleshooting](#troubleshooting)
59
+ - [Pricing](#pricing)
60
+ - [Links](#links)
61
+ - [License](#license)
32
62
 
33
63
  ## Install by Client
34
64
 
65
+ ### Requirements
66
+
67
+ - Node.js 18 or later
68
+ - `npx` available in your terminal
69
+ - A CommodityPriceAPI key — [sign up free](https://commoditypriceapi.com/auth/signup)
70
+
35
71
  ### Claude Desktop
36
72
 
37
- Add the block above to `claude_desktop_config.json`, then restart Claude Desktop.
73
+ Add to `claude_desktop_config.json` (Settings → Developer → Edit Config):
38
74
 
39
- ### Cursor / Windsurf / Cline / VS Code
75
+ ```json
76
+ {
77
+ "mcpServers": {
78
+ "commoditypriceapi": {
79
+ "command": "npx",
80
+ "args": ["-y", "@commoditypriceapi/mcp"],
81
+ "env": {
82
+ "COMMODITYPRICEAPI_KEY": "<YOUR_API_KEY>"
83
+ }
84
+ }
85
+ }
86
+ }
87
+ ```
40
88
 
41
- Add the same `commoditypriceapi` block to that client's MCP server config file and restart the client.
89
+ Restart Claude Desktop after saving.
42
90
 
43
- ### Any other MCP client
91
+ ### Claude Code
92
+
93
+ ```bash
94
+ claude mcp add commoditypriceapi --env COMMODITYPRICEAPI_KEY=<YOUR_API_KEY> -- npx -y @commoditypriceapi/mcp
95
+ ```
96
+
97
+ Start a new Claude Code session after adding the server.
98
+
99
+ ### Cursor
100
+
101
+ One-click install:
102
+
103
+ [![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/install-mcp?name=commoditypriceapi&config=eyJjb21tYW5kIjoibnB4IC15IEBjb21tb2RpdHlwcmljZWFwaS9tY3AiLCJlbnYiOnsiQ09NTU9ESVRZUFJJQ0VBUElfS0VZIjoiIn19)
104
+
105
+ Or add to `.cursor/mcp.json` manually:
106
+
107
+ ```json
108
+ {
109
+ "mcpServers": {
110
+ "commoditypriceapi": {
111
+ "command": "npx",
112
+ "args": ["-y", "@commoditypriceapi/mcp"],
113
+ "env": {
114
+ "COMMODITYPRICEAPI_KEY": "<YOUR_API_KEY>"
115
+ }
116
+ }
117
+ }
118
+ }
119
+ ```
120
+
121
+ Restart Cursor after saving.
122
+
123
+ ### Windsurf
124
+
125
+ Add to `~/.codeium/windsurf/mcp_config.json`:
126
+
127
+ ```json
128
+ {
129
+ "mcpServers": {
130
+ "commoditypriceapi": {
131
+ "command": "npx",
132
+ "args": ["-y", "@commoditypriceapi/mcp"],
133
+ "env": {
134
+ "COMMODITYPRICEAPI_KEY": "<YOUR_API_KEY>"
135
+ }
136
+ }
137
+ }
138
+ }
139
+ ```
140
+
141
+ Restart Windsurf after saving.
142
+
143
+ ### VS Code / GitHub Copilot
144
+
145
+ Add to your VS Code `settings.json`:
146
+
147
+ ```json
148
+ {
149
+ "mcp": {
150
+ "servers": {
151
+ "commoditypriceapi": {
152
+ "command": "npx",
153
+ "args": ["-y", "@commoditypriceapi/mcp"],
154
+ "env": {
155
+ "COMMODITYPRICEAPI_KEY": "<YOUR_API_KEY>"
156
+ }
157
+ }
158
+ }
159
+ }
160
+ }
161
+ ```
162
+
163
+ Restart VS Code after saving.
164
+
165
+ ### Cline
166
+
167
+ Open MCP Servers panel → **Configure** → **Advanced MCP Settings**. Add to `cline_mcp_settings.json`:
168
+
169
+ ```json
170
+ {
171
+ "mcpServers": {
172
+ "commoditypriceapi": {
173
+ "command": "npx",
174
+ "args": ["-y", "@commoditypriceapi/mcp"],
175
+ "env": {
176
+ "COMMODITYPRICEAPI_KEY": "<YOUR_API_KEY>"
177
+ }
178
+ }
179
+ }
180
+ }
181
+ ```
182
+
183
+ Restart Cline after saving.
184
+
185
+ ### Codex CLI
186
+
187
+ ```bash
188
+ codex mcp add commoditypriceapi --env COMMODITYPRICEAPI_KEY=<YOUR_API_KEY> -- npx -y @commoditypriceapi/mcp
189
+ codex mcp list
190
+ ```
191
+
192
+ Start a new Codex session after adding the server.
193
+
194
+ ### Any Other MCP Client
195
+
196
+ Use this config:
44
197
 
45
198
  ```json
46
199
  {
@@ -52,38 +205,235 @@ Add the same `commoditypriceapi` block to that client's MCP server config file a
52
205
  }
53
206
  ```
54
207
 
55
- ## Tools
208
+ ## Verify It Works
209
+
210
+ Try these after setup:
211
+
212
+ | Prompt | Expected tool |
213
+ |--------|---------------|
214
+ | What's the current gold price? | `get_gold_price` |
215
+ | Get the latest silver and Brent crude prices. | `get_latest_rates` with `symbols=XAG,BRENTOIL-SPOT` |
216
+ | What was the gold price on January 2nd, 2020? | `get_historical_rates` |
217
+ | Show daily gold prices for the first week of August 2026. | `get_time_series` |
218
+ | How much did gold change between January and August 2026? | `get_fluctuation` |
219
+ | Which commodity symbols do you support? | `list_symbols` |
220
+ | How much of my API quota is left? | `get_usage` |
221
+
222
+ ## Tool Reference
223
+
224
+ All 8 tools map 1:1 to CommodityPriceAPI v3 endpoints. Tools that take `symbols` accept a comma-separated list (e.g. `XAU,XAG,BRENTOIL-SPOT`). Use `list_symbols` to look up valid symbols — there are 148 across Metals, Energy, Agriculture, and more.
225
+
226
+ ### get_latest_rates
227
+
228
+ `GET /v3/rates/latest` — latest rates for one or more symbols. Rates may lag up to 10 minutes depending on plan.
229
+
230
+ | Parameter | Required | Description |
231
+ |-----------|----------|-------------|
232
+ | `symbols` | Yes | Comma-separated symbols, e.g. `XAU,XAG,BRENTOIL-SPOT` |
233
+ | `quote` | No | Target quote currency (e.g. `EUR`). Premium/Plus plans only; omit for each symbol's default currency. |
234
+
235
+ Note: if some symbols in a multi-symbol request are invalid, the API returns the valid rates (HTTP 206) plus an `unresolved` map — one entry per missing symbol with a message and, where available, `suggestions` ("did you mean"). If no symbol resolves, the tool returns a `SYMBOL_NOT_FOUND` error carrying the same `unresolved` map. The same applies to `get_historical_rates`, `get_time_series`, and `get_fluctuation`.
236
+
237
+ ### get_gold_price
238
+
239
+ `GET /v3/rates/latest/xau` — shortcut for the latest gold (XAU) rate, including bid/ask.
240
+
241
+ | Parameter | Required | Description |
242
+ |-----------|----------|-------------|
243
+ | `quote` | No | Target quote currency. Premium/Plus plans only. |
244
+
245
+ ### get_silver_price
246
+
247
+ `GET /v3/rates/latest/xag` — shortcut for the latest silver (XAG) rate.
248
+
249
+ | Parameter | Required | Description |
250
+ |-----------|----------|-------------|
251
+ | `quote` | No | Target quote currency. Premium/Plus plans only. |
252
+
253
+ ### get_historical_rates
254
+
255
+ `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.
256
+
257
+ | Parameter | Required | Description |
258
+ |-----------|----------|-------------|
259
+ | `symbols` | Yes | Comma-separated symbols |
260
+ | `date` | Yes | `YYYY-MM-DD` |
261
+
262
+ ### get_time_series
263
+
264
+ `GET /v3/rates/time-series` — daily historical rates for one or more symbols between two dates. Max span: 1 year.
265
+
266
+ | Parameter | Required | Description |
267
+ |-----------|----------|-------------|
268
+ | `symbols` | Yes | Comma-separated symbols |
269
+ | `startDate` | Yes | `YYYY-MM-DD` |
270
+ | `endDate` | Yes | `YYYY-MM-DD` |
271
+
272
+ ### get_fluctuation
273
+
274
+ `GET /v3/rates/fluctuation` — how each symbol changed between two dates: start rate, end rate, absolute change, and percent change.
275
+
276
+ | Parameter | Required | Description |
277
+ |-----------|----------|-------------|
278
+ | `symbols` | Yes | Comma-separated symbols |
279
+ | `startDate` | Yes | `YYYY-MM-DD` |
280
+ | `endDate` | Yes | `YYYY-MM-DD` |
281
+
282
+ ### list_symbols
283
+
284
+ `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.
285
+
286
+ ### get_usage
287
+
288
+ `GET /v3/usage` — current plan, quota, and usage for the configured API key. Takes no parameters.
289
+
290
+ ## Prompt Examples
291
+
292
+ ### Live prices
293
+
294
+ - What's the current gold price?
295
+ - Get the latest prices for silver, copper, and WTI crude.
296
+ - What's gold trading at in euros?
297
+
298
+ ### Historical data
299
+
300
+ - What was the price of wheat on January 2nd, 2026?
301
+ - Compare gold and silver prices over the last 30 days.
302
+ - Show me daily natural gas prices for Q1 2026.
303
+
304
+ ### Price changes
305
+
306
+ - How much did Brent crude fluctuate this quarter?
307
+ - Did gold go up or down since the start of the year, and by how much?
308
+
309
+ ### Discovery and account
310
+
311
+ - Which commodity symbols do you support for energy?
312
+ - How much of my API quota is left this month?
313
+
314
+ ## Example Answers and Tool Output
315
+
316
+ The text answers show what a client might say; exact wording depends on the model. JSON blocks are raw tool output.
317
+
318
+ ### Latest gold price
319
+
320
+ **Prompt:** What's the current gold price?
321
+
322
+ **Example answer:** Gold (XAU) is currently trading at $4,386.23 per troy ounce (bid $4,385.93 / ask $4,386.23).
323
+
324
+ ```json
325
+ {
326
+ "success": true,
327
+ "timestamp": 1786617187,
328
+ "rates": {
329
+ "XAU": {
330
+ "rate": 4386.23,
331
+ "bid": 4385.93,
332
+ "ask": 4386.23
333
+ }
334
+ },
335
+ "metadata": {
336
+ "XAU": {
337
+ "unit": "T.oz",
338
+ "quote": "USD"
339
+ }
340
+ }
341
+ }
342
+ ```
343
+
344
+ ### Historical rate
345
+
346
+ **Prompt:** What was the gold price on January 2nd, 2020?
347
+
348
+ **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).
349
+
350
+ ```json
351
+ {
352
+ "success": true,
353
+ "date": "2020-01-02",
354
+ "rates": {
355
+ "XAU": {
356
+ "date": "2020-01-02",
357
+ "open": 1518.26,
358
+ "high": 1531.31,
359
+ "low": 1517.15,
360
+ "close": 1528.76
361
+ }
362
+ }
363
+ }
364
+ ```
365
+
366
+ ### Fluctuation
367
+
368
+ **Prompt:** How much did gold change between January 2nd and August 12th, 2026?
369
+
370
+ **Example answer:** Gold rose from $4,332.01 to $4,400.12 per troy ounce — up $68.11, or +1.57%.
371
+
372
+ ```json
373
+ {
374
+ "success": true,
375
+ "startDate": "2026-01-02",
376
+ "endDate": "2026-08-12",
377
+ "rates": {
378
+ "XAU": {
379
+ "startRate": 4332.01,
380
+ "endRate": 4400.12,
381
+ "change": 68.11,
382
+ "changePercent": 1.57
383
+ }
384
+ }
385
+ }
386
+ ```
387
+
388
+ ## Error Codes
56
389
 
57
- | Tool | Endpoint | What it does |
58
- | ---------------------- | ---------------------------- | ----------------------------------------------------------------|
59
- | `get_usage` | `GET /v2/usage` | Current plan, quota, and usage |
60
- | `list_symbols` | `GET /v2/symbols` | All supported commodity symbols with category/currency/unit |
61
- | `get_latest_rates` | `GET /v2/rates/latest` | Latest rates for one or more symbols |
62
- | `get_gold_price` | `GET /v2/rates/latest/xau` | Shortcut for the latest gold rate |
63
- | `get_silver_price` | `GET /v2/rates/latest/xag` | Shortcut for the latest silver rate |
64
- | `get_historical_rates` | `GET /v2/rates/historical` | OHLC rates for one or more symbols on a specific past date |
65
- | `get_time_series` | `GET /v2/rates/time-series` | Daily rates between two dates (max 1 year span) |
66
- | `get_fluctuation` | `GET /v2/rates/fluctuation` | Start/end rate, change, and % change over a date range |
390
+ 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.
67
391
 
68
- All tools that take `symbols` accept a comma-separated list (e.g. `XAU,XAG,BRENTOIL`). Use `list_symbols` to look up valid symbols.
392
+ | Code | Meaning |
393
+ |------|---------|
394
+ | `401` | Missing or invalid API key — check `COMMODITYPRICEAPI_KEY` in your client config |
395
+ | `402` | Your trial or subscription doesn't cover this request (e.g. `quote` conversion on a non-Premium plan) |
396
+ | `403` | API key usage limit reached — upgrade or wait for quota reset |
397
+ | `404` | Symbol not found — call `list_symbols` for valid symbols |
398
+ | `429` | Rate limited — wait a minute and retry |
399
+ | `499` | Request to the upstream API timed out (see `COMMODITYPRICEAPI_REQUEST_TIMEOUT_MS`) |
400
+ | `502` | Server could not reach the upstream API |
401
+
402
+ Example error result for an invalid symbol:
403
+
404
+ ```json
405
+ {
406
+ "error": "SYMBOL_NOT_FOUND",
407
+ "code": 404,
408
+ "message": "The symbol is not supported, please visit the documentation for a list of supported symbols",
409
+ "guidance": "Call list_symbols to see valid commodity symbols."
410
+ }
411
+ ```
69
412
 
70
- ## Authentication
413
+ ## How It Works
71
414
 
72
- 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.
415
+ This is a stdio MCP server that wraps the CommodityPriceAPI v3 REST API.
73
416
 
74
- | Variable | Required | Description |
75
- | ------------------------ | -------- | ---------------------------------- |
76
- | `COMMODITYPRICEAPI_KEY` | Yes | Your CommodityPriceAPI key |
77
- | `COMMODITYPRICEAPI_REQUEST_TIMEOUT_MS` | No | Upstream request timeout in ms (default `15000`) |
417
+ At runtime:
78
418
 
79
- ## Error Handling
419
+ 1. Your MCP client starts the server process via `npx`.
420
+ 2. The client reads the tool list.
421
+ 3. When a prompt matches a tool, the client calls it.
422
+ 4. The server validates inputs, calls the CommodityPriceAPI, and returns structured JSON.
80
423
 
81
- Tool calls never crash the server. Upstream errors (invalid symbol, missing date, quota exceeded, etc.) are returned as structured tool results with `error`, `code`, `message`, and a `guidance` field so the client can explain what went wrong instead of just echoing a status code.
424
+ 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.
425
+
426
+ ## Environment Variables
427
+
428
+ | Variable | Required | Default | Description |
429
+ |----------|----------|---------|-------------|
430
+ | `COMMODITYPRICEAPI_KEY` | Yes | | Your CommodityPriceAPI key |
431
+ | `COMMODITYPRICEAPI_REQUEST_TIMEOUT_MS` | No | `15000` | Upstream request timeout in ms |
82
432
 
83
433
  ## Building from Source
84
434
 
85
435
  ```bash
86
- git clone https://github.com/commoditypriceapi/commoditypriceapi-mcp.git
436
+ git clone https://github.com/Commodity-Price-API/commoditypriceapi-mcp.git
87
437
  cd commoditypriceapi-mcp
88
438
  npm install
89
439
  npm run build
@@ -101,6 +451,30 @@ Inspect with the MCP Inspector:
101
451
  COMMODITYPRICEAPI_KEY=<YOUR_KEY> npx @modelcontextprotocol/inspector node dist/cli.js
102
452
  ```
103
453
 
454
+ ## Troubleshooting
455
+
456
+ **Client uses an old tool list after updating:** Restart the client and confirm it loaded the latest npm version.
457
+
458
+ **401 errors:** Check that `COMMODITYPRICEAPI_KEY` is set in your MCP client config's `env` block.
459
+
460
+ **A symbol is missing from a multi-symbol response:** Look at the `unresolved` map in the result — each missing symbol has a message and usually `suggestions` (e.g. `BRENTOIL` → `BRENTOIL-SPOT`). If there are no suggestions, call `list_symbols` to find the correct symbol.
461
+
462
+ **499 timeouts:** The upstream API did not respond in time. Increase `COMMODITYPRICEAPI_REQUEST_TIMEOUT_MS` (default: 15000 ms).
463
+
464
+ ## Pricing
465
+
466
+ Free 7-day trial with 2,000 requests, no card required. For plan details, see the [CommodityPriceAPI pricing page](https://commoditypriceapi.com/pricing).
467
+
468
+ ## Links
469
+
470
+ - [CommodityPriceAPI Website](https://commoditypriceapi.com)
471
+ - [API Documentation](https://commoditypriceapi.com/docs)
472
+ - [Supported Symbols](https://commoditypriceapi.com/symbols)
473
+ - [MCP Integration Guide](https://commoditypriceapi.com/integrations/mcp)
474
+ - [Pricing](https://commoditypriceapi.com/pricing)
475
+ - [Sign Up Free](https://commoditypriceapi.com/auth/signup)
476
+ - [GitHub Repository](https://github.com/Commodity-Price-API/commoditypriceapi-mcp)
477
+
104
478
  ## License
105
479
 
106
- MIT
480
+ [MIT](LICENSE)
package/dist/client.js CHANGED
@@ -1,14 +1,16 @@
1
- const BASE_URL = "https://api.commoditypriceapi.com/v2";
1
+ const BASE_URL = "https://api.commoditypriceapi.com/v3";
2
2
  export class CommodityApiError extends Error {
3
3
  code;
4
4
  errorType;
5
5
  path;
6
- constructor(code, errorType, message, path) {
6
+ unresolved;
7
+ constructor(code, errorType, message, path, unresolved) {
7
8
  super(message);
8
9
  this.name = "CommodityApiError";
9
10
  this.code = code;
10
11
  this.errorType = errorType;
11
12
  this.path = path;
13
+ this.unresolved = unresolved;
12
14
  }
13
15
  }
14
16
  function getApiKey() {
@@ -19,9 +21,13 @@ function getApiKey() {
19
21
  return key;
20
22
  }
21
23
  /**
22
- * Calls a CommodityPriceAPI v2 endpoint.
24
+ * Calls a CommodityPriceAPI v3 endpoint.
23
25
  * Sends the API key via both the x-api-key header AND the apiKey query
24
26
  * param, since the upstream API accepts either.
27
+ *
28
+ * v3 answers 206 (still `response.ok`) with an `unresolved` map appended to
29
+ * the body when some requested symbols could not be returned; the body is
30
+ * passed through as-is so tool results include those suggestions.
25
31
  */
26
32
  export async function callCommodityApi(path, params = {}) {
27
33
  const apiKey = getApiKey();
@@ -64,7 +70,7 @@ export async function callCommodityApi(path, params = {}) {
64
70
  throw new CommodityApiError(response.status, "INVALID_RESPONSE", `CommodityPriceAPI returned a non-JSON response: ${text.slice(0, 500)}`);
65
71
  }
66
72
  if (!response.ok) {
67
- throw new CommodityApiError(response.status, body.error ?? "UNKNOWN_ERROR", body.message ?? `CommodityPriceAPI request failed with status ${response.status}.`, body.path);
73
+ throw new CommodityApiError(response.status, body.error ?? "UNKNOWN_ERROR", body.message ?? `CommodityPriceAPI request failed with status ${response.status}.`, body.path, body.unresolved);
68
74
  }
69
75
  return body;
70
76
  }
package/dist/server.js CHANGED
@@ -3,7 +3,7 @@ import { z } from "zod";
3
3
  import { callCommodityApi, CommodityApiError } from "./client.js";
4
4
  const symbolsParam = z
5
5
  .string()
6
- .describe("Comma-separated commodity symbols, e.g. 'XAU,XAG,BRENTOIL'. See the list_symbols tool for valid values.");
6
+ .describe("Comma-separated commodity symbols, e.g. 'XAU,XAG,BRENTOIL-SPOT'. See the list_symbols tool for valid values. If some symbols cannot be resolved, the response still succeeds (HTTP 206) with the valid rates plus an 'unresolved' map giving a message and 'did you mean' suggestions for each missing symbol. If none resolve, the error result carries the same 'unresolved' map.");
7
7
  const dateParam = z.string().describe("Date in YYYY-MM-DD format.");
8
8
  function textResult(data) {
9
9
  return {
@@ -26,6 +26,7 @@ function errorResult(err) {
26
26
  error: err.errorType,
27
27
  code: err.code,
28
28
  message: err.message,
29
+ ...(err.unresolved ? { unresolved: err.unresolved } : {}),
29
30
  guidance: guidanceFor(err.code, err.errorType),
30
31
  }, null, 2),
31
32
  },
@@ -52,7 +53,7 @@ function guidanceFor(code, errorType) {
52
53
  return "You've hit your API key's usage limit. Upgrade your plan or wait for the quota to reset.";
53
54
  case 404:
54
55
  if (errorType === "SYMBOL_NOT_FOUND") {
55
- return "Call list_symbols to see valid commodity symbols.";
56
+ return "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.";
56
57
  }
57
58
  return "The requested resource was not found.";
58
59
  case 429:
@@ -64,7 +65,7 @@ function guidanceFor(code, errorType) {
64
65
  export function createServer() {
65
66
  const server = new McpServer({
66
67
  name: "commoditypriceapi-mcp",
67
- version: "1.0.0",
68
+ version: "1.1.0",
68
69
  });
69
70
  server.registerTool("get_usage", {
70
71
  title: "Get API usage",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commoditypriceapi/mcp",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Official MCP server for CommodityPriceAPI \u2014 real-time and historical commodity rates (gold, silver, oil, and 130+ more) as MCP tools for Claude, Cursor, Windsurf, and any MCP client.",
5
5
  "keywords": [
6
6
  "mcp",
@@ -13,10 +13,10 @@
13
13
  "ai-tools"
14
14
  ],
15
15
  "homepage": "https://commoditypriceapi.com",
16
- "bugs": "https://github.com/commoditypriceapi/commoditypriceapi-mcp/issues",
16
+ "bugs": "https://github.com/Commodity-Price-API/commoditypriceapi-mcp/issues",
17
17
  "repository": {
18
18
  "type": "git",
19
- "url": "git+https://github.com/commoditypriceapi/commoditypriceapi-mcp.git"
19
+ "url": "git+https://github.com/Commodity-Price-API/commoditypriceapi-mcp.git"
20
20
  },
21
21
  "license": "MIT",
22
22
  "author": "CommodityPriceAPI",