@commoditypriceapi/mcp 1.2.0 → 1.2.2

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
@@ -233,6 +233,7 @@ Precious metals use ISO 4217 codes: `XAU` (gold), `XAG` (silver), `XPT` (platinu
233
233
  |-----------|----------|-------------|
234
234
  | `symbols` | Yes | Comma-separated symbols, e.g. `XAU,XAG,BRENTOIL-SPOT` |
235
235
  | `quote` | No | Target quote currency (e.g. `EUR`). Premium/Plus plans only; omit for each symbol's default currency. |
236
+ | `metadata` | No | `true` (default) or `false`. `false` omits the `metadata` map (per-symbol unit and quote currency) from the response. |
236
237
 
237
238
  Note on `unresolved`: v3 appends an `unresolved` map, keyed by the symbol you typed, in three cases. The same applies to `get_historical_rates`, `get_time_series`, and `get_fluctuation`.
238
239
 
@@ -250,6 +251,7 @@ Note on `unresolved`: v3 appends an `unresolved` map, keyed by the symbol you ty
250
251
  |-----------|----------|-------------|
251
252
  | `quote` | No | Target quote currency. Premium/Plus plans only. |
252
253
  | `include` | No | `gram`, `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. |
254
+ | `metadata` | No | `true` (default) or `false`. `false` omits the `metadata` map (per-symbol unit and quote currency) from the response. |
253
255
 
254
256
  ### get_silver_price
255
257
 
@@ -259,6 +261,7 @@ Note on `unresolved`: v3 appends an `unresolved` map, keyed by the symbol you ty
259
261
  |-----------|----------|-------------|
260
262
  | `quote` | No | Target quote currency. Premium/Plus plans only. |
261
263
  | `include` | No | `gram`, `carat`, or `tola` — adds a per-gram, per-carat, or per-tola rate alongside the ounce rate. |
264
+ | `metadata` | No | `true` (default) or `false`. `false` omits the `metadata` map (per-symbol unit and quote currency) from the response. |
262
265
 
263
266
  ### get_historical_rates
264
267
 
package/dist/server.js CHANGED
@@ -17,6 +17,14 @@ const includeParam = z
17
17
  .enum(["gram", "carat", "tola"])
18
18
  .optional()
19
19
  .describe("Add a per-unit breakdown alongside the per-troy-ounce rate: 'gram' adds a per-gram rate, 'tola' adds a per-tola rate, 'carat' adds per-gram rates at each purity from 24k down to 8k. Omit for the ounce rate only.");
20
+ const metadataParam = z
21
+ .boolean()
22
+ .optional()
23
+ .describe("Whether to include the 'metadata' map (per-symbol unit and quote currency) in the response. Defaults to true. Set false to omit it and get a smaller payload.");
24
+ /** v3 only honours an explicit `metadata=false`; anything else is the default (true). */
25
+ function metadataFlag(metadata) {
26
+ return metadata === false ? "false" : undefined;
27
+ }
20
28
  function textResult(data) {
21
29
  return {
22
30
  content: [
@@ -77,7 +85,7 @@ function guidanceFor(code, errorType) {
77
85
  export function createServer() {
78
86
  const server = new McpServer({
79
87
  name: "commoditypriceapi-mcp",
80
- version: "1.2.0",
88
+ version: "1.2.1",
81
89
  });
82
90
  server.registerTool("get_usage", {
83
91
  title: "Get API usage",
@@ -94,11 +102,29 @@ export function createServer() {
94
102
  });
95
103
  server.registerTool("list_symbols", {
96
104
  title: "List supported commodity symbols",
97
- description: "Returns all commodity symbols supported by CommodityPriceAPI, including category, default currency, and unit. Use this to look up a symbol before calling rate tools. Precious metals use ISO 4217 codes (XAU, XAG, XPT, XPD); copper is XCU.",
98
- inputSchema: {},
99
- }, async () => {
105
+ description: "Returns all commodity symbols supported by CommodityPriceAPI, including category, default currency, and unit. Use this to look up a symbol before calling rate tools. Precious metals use ISO 4217 codes (XAU, XAG, XPT, XPD); copper is XCU. " +
106
+ "Dated futures contracts (e.g. WTIOIL-FUT-DEC26, the December 2026 WTI contract) are listed as their own symbols with 'contract', 'deliveryMonth', 'expiresAt' and 'underlying' (the continuous parent such as WTIOIL-FUT); expired contracts are hidden unless includeExpired is set. Pass 'underlying' to list one parent's live months. A contract's latest price comes from get_latest_rates and its daily open/high/low/close (close = the exchange settlement) from get_historical_rates / get_time_series.",
107
+ inputSchema: {
108
+ underlying: z
109
+ .string()
110
+ .optional()
111
+ .describe("Only the dated futures contracts of this continuous parent symbol, e.g. 'WTIOIL-FUT'."),
112
+ contract: z
113
+ .enum(["spot", "futures"])
114
+ .optional()
115
+ .describe("Only symbols of this contract kind."),
116
+ includeExpired: z
117
+ .boolean()
118
+ .optional()
119
+ .describe("Also list expired futures contracts (hidden by default)."),
120
+ },
121
+ }, async ({ underlying, contract, includeExpired }) => {
100
122
  try {
101
- const data = await callCommodityApi("/symbols");
123
+ const data = await callCommodityApi("/symbols", {
124
+ underlying,
125
+ contract,
126
+ includeExpired: includeExpired ? "true" : undefined,
127
+ });
102
128
  return textResult(data);
103
129
  }
104
130
  catch (err) {
@@ -107,14 +133,19 @@ export function createServer() {
107
133
  });
108
134
  server.registerTool("get_latest_rates", {
109
135
  title: "Get latest commodity rates",
110
- description: "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). Common names with a single match (e.g. GOLD) are auto-resolved to the real symbol and flagged in 'unresolved' with 'resolvedTo'.",
136
+ description: "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). Common names with a single match (e.g. GOLD) are auto-resolved to the real symbol and flagged in 'unresolved' with 'resolvedTo'. Set 'metadata' to false to omit the per-symbol unit/quote map.",
111
137
  inputSchema: {
112
138
  symbols: symbolsParam,
113
139
  quote: quoteParam,
140
+ metadata: metadataParam,
114
141
  },
115
- }, async ({ symbols, quote }) => {
142
+ }, async ({ symbols, quote, metadata }) => {
116
143
  try {
117
- const data = await callCommodityApi("/rates/latest", { symbols, quote });
144
+ const data = await callCommodityApi("/rates/latest", {
145
+ symbols,
146
+ quote,
147
+ metadata: metadataFlag(metadata),
148
+ });
118
149
  return textResult(data);
119
150
  }
120
151
  catch (err) {
@@ -123,14 +154,19 @@ export function createServer() {
123
154
  });
124
155
  server.registerTool("get_gold_price", {
125
156
  title: "Get latest gold (XAU) price",
126
- description: "Shortcut for the latest gold (XAU) rate, with bid/ask, without needing to pass a symbols list. Use 'include' to add a per-gram, per-tola, or per-carat breakdown.",
157
+ description: "Shortcut for the latest gold (XAU) rate, with bid/ask, without needing to pass a symbols list. Use 'include' to add a per-gram, per-tola, or per-carat breakdown. Set 'metadata' to false to omit the unit/quote map.",
127
158
  inputSchema: {
128
159
  quote: quoteParam,
129
160
  include: includeParam,
161
+ metadata: metadataParam,
130
162
  },
131
- }, async ({ quote, include }) => {
163
+ }, async ({ quote, include, metadata }) => {
132
164
  try {
133
- const data = await callCommodityApi("/rates/latest/xau", { quote, include });
165
+ const data = await callCommodityApi("/rates/latest/xau", {
166
+ quote,
167
+ include,
168
+ metadata: metadataFlag(metadata),
169
+ });
134
170
  return textResult(data);
135
171
  }
136
172
  catch (err) {
@@ -139,14 +175,19 @@ export function createServer() {
139
175
  });
140
176
  server.registerTool("get_silver_price", {
141
177
  title: "Get latest silver (XAG) price",
142
- description: "Shortcut for the latest silver (XAG) rate, with bid/ask, without needing to pass a symbols list. Use 'include' to add a per-gram, per-tola, or per-carat breakdown.",
178
+ description: "Shortcut for the latest silver (XAG) rate, with bid/ask, without needing to pass a symbols list. Use 'include' to add a per-gram, per-tola, or per-carat breakdown. Set 'metadata' to false to omit the unit/quote map.",
143
179
  inputSchema: {
144
180
  quote: quoteParam,
145
181
  include: includeParam,
182
+ metadata: metadataParam,
146
183
  },
147
- }, async ({ quote, include }) => {
184
+ }, async ({ quote, include, metadata }) => {
148
185
  try {
149
- const data = await callCommodityApi("/rates/latest/xag", { quote, include });
186
+ const data = await callCommodityApi("/rates/latest/xag", {
187
+ quote,
188
+ include,
189
+ metadata: metadataFlag(metadata),
190
+ });
150
191
  return textResult(data);
151
192
  }
152
193
  catch (err) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commoditypriceapi/mcp",
3
- "version": "1.2.0",
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.",
3
+ "version": "1.2.2",
4
+ "description": "Official MCP server for CommodityPriceAPI — 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",
7
7
  "model-context-protocol",