@commoditypriceapi/mcp 1.2.0 → 1.2.1

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",
@@ -107,14 +115,19 @@ export function createServer() {
107
115
  });
108
116
  server.registerTool("get_latest_rates", {
109
117
  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'.",
118
+ 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
119
  inputSchema: {
112
120
  symbols: symbolsParam,
113
121
  quote: quoteParam,
122
+ metadata: metadataParam,
114
123
  },
115
- }, async ({ symbols, quote }) => {
124
+ }, async ({ symbols, quote, metadata }) => {
116
125
  try {
117
- const data = await callCommodityApi("/rates/latest", { symbols, quote });
126
+ const data = await callCommodityApi("/rates/latest", {
127
+ symbols,
128
+ quote,
129
+ metadata: metadataFlag(metadata),
130
+ });
118
131
  return textResult(data);
119
132
  }
120
133
  catch (err) {
@@ -123,14 +136,19 @@ export function createServer() {
123
136
  });
124
137
  server.registerTool("get_gold_price", {
125
138
  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.",
139
+ 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
140
  inputSchema: {
128
141
  quote: quoteParam,
129
142
  include: includeParam,
143
+ metadata: metadataParam,
130
144
  },
131
- }, async ({ quote, include }) => {
145
+ }, async ({ quote, include, metadata }) => {
132
146
  try {
133
- const data = await callCommodityApi("/rates/latest/xau", { quote, include });
147
+ const data = await callCommodityApi("/rates/latest/xau", {
148
+ quote,
149
+ include,
150
+ metadata: metadataFlag(metadata),
151
+ });
134
152
  return textResult(data);
135
153
  }
136
154
  catch (err) {
@@ -139,14 +157,19 @@ export function createServer() {
139
157
  });
140
158
  server.registerTool("get_silver_price", {
141
159
  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.",
160
+ 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
161
  inputSchema: {
144
162
  quote: quoteParam,
145
163
  include: includeParam,
164
+ metadata: metadataParam,
146
165
  },
147
- }, async ({ quote, include }) => {
166
+ }, async ({ quote, include, metadata }) => {
148
167
  try {
149
- const data = await callCommodityApi("/rates/latest/xag", { quote, include });
168
+ const data = await callCommodityApi("/rates/latest/xag", {
169
+ quote,
170
+ include,
171
+ metadata: metadataFlag(metadata),
172
+ });
150
173
  return textResult(data);
151
174
  }
152
175
  catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commoditypriceapi/mcp",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
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",