@shoppexio/mcp-commerce-server 0.3.0 → 0.4.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/server.mjs +18 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shoppexio/mcp-commerce-server",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Shoppex MCP server for commerce operations over the Dev API",
5
5
  "type": "module",
6
6
  "repository": {
package/src/server.mjs CHANGED
@@ -257,13 +257,29 @@ export class ShoppexCommerceDevApiClient {
257
257
  }
258
258
 
259
259
  const BaseToolSchema = {
260
- shop_api_key: z.string().trim().min(1),
260
+ shop_api_key: z.string().trim().min(1).optional(),
261
261
  api_base_url: z.string().trim().url().optional(),
262
262
  };
263
263
 
264
+ function resolveShopApiKey(explicitValue) {
265
+ if (typeof explicitValue === 'string' && explicitValue.trim()) {
266
+ return explicitValue.trim();
267
+ }
268
+ const fromEnv = process.env.SHOPPEX_SHOP_API_KEY?.trim()
269
+ || process.env.SHOPPEX_API_KEY?.trim()
270
+ || process.env.SHOP_API_KEY?.trim();
271
+ if (!fromEnv) {
272
+ throw new ShoppexCommerceDevApiError(
273
+ 'Missing Shoppex shop API key. Set SHOPPEX_SHOP_API_KEY in the MCP server env, or pass shop_api_key to the tool.',
274
+ { code: 'auth_error', retryable: false },
275
+ );
276
+ }
277
+ return fromEnv;
278
+ }
279
+
264
280
  function createClient(args) {
265
281
  return new ShoppexCommerceDevApiClient({
266
- shopApiKey: args.shop_api_key,
282
+ shopApiKey: resolveShopApiKey(args.shop_api_key),
267
283
  apiBaseUrl: args.api_base_url,
268
284
  });
269
285
  }