kanban-zone-mcp-server 0.1.4 → 0.2.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.
- package/package.json +1 -1
- package/src/client.js +16 -0
- package/src/constants.js +1 -1
package/package.json
CHANGED
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
|
}
|
|
@@ -117,4 +132,5 @@ module.exports = {
|
|
|
117
132
|
makeApiRequest,
|
|
118
133
|
handleApiError,
|
|
119
134
|
safeRun,
|
|
135
|
+
runWithCredentials,
|
|
120
136
|
};
|