mcp-zenskar 1.0.9 → 1.0.10

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.js +13 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-zenskar",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "Model Context Protocol (MCP) server for Zenskar API - customer management, invoicing, and billing operations",
5
5
  "main": "src/server.js",
6
6
  "bin": {
package/src/server.js CHANGED
@@ -431,7 +431,11 @@ async function executeAPICall(tool, args) {
431
431
  const authToken = userContext?.authorization ||
432
432
  userContext?.headers?.['authorization'] ||
433
433
  userContext?.headers?.['Authorization'] ||
434
- (process.env.ZENSKAR_AUTH_TOKEN ? `Bearer ${process.env.ZENSKAR_AUTH_TOKEN}` : null);
434
+ process.env.ZENSKAR_AUTH_TOKEN;
435
+ const apiKey = userContext?.apiKey ||
436
+ userContext?.headers?.['x-api-key'] ||
437
+ process.env.ZENSKAR_API_KEY ||
438
+ process.env.ZENSKAR_AUTH_TOKEN; // Fallback: use AUTH_TOKEN as API key if it looks like one
435
439
 
436
440
  if (orgId) {
437
441
  headers['organisation'] = orgId;
@@ -440,18 +444,16 @@ async function executeAPICall(tool, args) {
440
444
  throw new Error('Organization ID is required for API access. Set ZENSKAR_ORGANIZATION env var or provide in user context.');
441
445
  }
442
446
 
443
- if (authToken) {
447
+ // Determine auth method: Bearer token for JWT, x-api-key for sandbox keys
448
+ if (authToken && authToken.startsWith('eyJ')) {
449
+ // JWT token - use Bearer auth
444
450
  headers['Authorization'] = authToken.startsWith('Bearer ') ? authToken : `Bearer ${authToken}`;
451
+ } else if (apiKey) {
452
+ // API key (sandbox_* or other) - use x-api-key header
453
+ headers['x-api-key'] = apiKey;
445
454
  } else {
446
- logger.error(`[${tool.name}] SECURITY ERROR: No authorization token provided`);
447
- throw new Error('Authorization token is required for API access. Set ZENSKAR_AUTH_TOKEN env var or provide in user context.');
448
- }
449
-
450
- // Also support legacy x-api-key if provided (optional)
451
- if (userContext?.apiKey) {
452
- headers['x-api-key'] = userContext.apiKey;
453
- } else if (userContext?.headers?.['x-api-key']) {
454
- headers['x-api-key'] = userContext.headers['x-api-key'];
455
+ logger.error(`[${tool.name}] SECURITY ERROR: No authorization provided`);
456
+ throw new Error('Authorization is required. Set ZENSKAR_AUTH_TOKEN (JWT) or ZENSKAR_API_KEY env var.');
455
457
  }
456
458
 
457
459
  // Add any other headers from user context