kanban-zone-mcp-server 0.1.4 → 0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kanban-zone-mcp-server",
3
- "version": "0.1.4",
3
+ "version": "0.2.1",
4
4
  "description": "Model Context Protocol server for the Kanban Zone public API",
5
5
  "license": "MIT",
6
6
  "homepage": "https://docs.kanbanzone.io/mcp",
package/src/client.js CHANGED
@@ -1,4 +1,5 @@
1
1
  const axios = require('axios');
2
+ const { AsyncLocalStorage } = require('node:async_hooks');
2
3
  const { DEFAULT_BASE_URL, REQUEST_TIMEOUT_MS } = require('./constants');
3
4
 
4
5
  // Throws on missing/malformed key so index.js can exit before opening the stdio transport.
@@ -17,7 +18,11 @@ const parseApiKey = raw => {
17
18
  return { accessId: raw.slice(0, idx), secret: raw.slice(idx + 1) };
18
19
  };
19
20
 
21
+ // stdio: the credential is read once from env at boot into this singleton.
20
22
  let clientConfig = null;
23
+ // A host that serves multiple credentials from one process can bind per-call credentials in this
24
+ // store instead of the boot singleton; see runWithCredentials.
25
+ const credentialStore = new AsyncLocalStorage();
21
26
 
22
27
  const initApiClient = () => {
23
28
  const { accessId, secret } = parseApiKey(process.env.KANBANZONE_API_KEY);
@@ -28,7 +33,17 @@ const initApiClient = () => {
28
33
  };
29
34
  };
30
35
 
36
+ // Run fn with call-scoped credentials ({ accessId, secret, baseUrl }) that override the boot
37
+ // singleton for the duration of fn's async execution — lets one process serve multiple tenants.
38
+ const runWithCredentials = (credentials, fn) => credentialStore.run(credentials, fn);
39
+
40
+ // A per-call store (if a host set one) wins; otherwise the boot singleton (stdio). Additive —
41
+ // the stdio path is unchanged when no store is present.
31
42
  const requireConfig = () => {
43
+ const scoped = credentialStore.getStore();
44
+ if (scoped) {
45
+ return scoped;
46
+ }
32
47
  if (!clientConfig) {
33
48
  throw new Error('API client not initialized — call initApiClient() before any tool handler.');
34
49
  }
@@ -47,18 +62,27 @@ const makeApiRequest = async (endpoint, { method = 'GET', body, query } = {}) =>
47
62
  ? Object.fromEntries(Object.entries(query).filter(([, value]) => value !== undefined && value !== null))
48
63
  : undefined;
49
64
 
50
- const response = await axios.request({
65
+ const requestConfig = {
51
66
  method,
52
67
  url: buildUrl(config.baseUrl, endpoint),
53
68
  data: body,
54
69
  params: cleanedQuery,
55
70
  timeout: REQUEST_TIMEOUT_MS,
56
- auth: { username: config.accessId, password: config.secret },
57
71
  headers: {
58
72
  'Content-Type': 'application/json',
59
73
  Accept: 'application/json',
60
74
  },
61
- });
75
+ };
76
+ // A multi-tenant host may bind an OAuth bearer token instead of an accessId/secret pair
77
+ // (runWithCredentials) — forward it as a Bearer header. Otherwise authenticate with HTTP Basic,
78
+ // exactly as the stdio path always has.
79
+ if (config.bearerToken) {
80
+ requestConfig.headers.Authorization = `Bearer ${config.bearerToken}`;
81
+ } else {
82
+ requestConfig.auth = { username: config.accessId, password: config.secret };
83
+ }
84
+
85
+ const response = await axios.request(requestConfig);
62
86
  return response.data;
63
87
  };
64
88
 
@@ -117,4 +141,5 @@ module.exports = {
117
141
  makeApiRequest,
118
142
  handleApiError,
119
143
  safeRun,
144
+ runWithCredentials,
120
145
  };
package/src/constants.js CHANGED
@@ -8,7 +8,7 @@ const DEFAULT_PAGE_SIZE = 20;
8
8
  const MAX_PAGE_SIZE = 100;
9
9
 
10
10
  const SERVER_NAME = 'kanban-zone-mcp-server';
11
- const SERVER_VERSION = '0.1.4';
11
+ const SERVER_VERSION = '0.2.1';
12
12
 
13
13
  const REQUEST_TIMEOUT_MS = 30000;
14
14