@edda-business/mcp 0.62.0 → 0.64.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 +20 -21
- package/src/index.js +3 -2
- package/src/server.js +219 -879
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -24,7 +24,10 @@ function resolvedEnv(name) {
|
|
|
24
24
|
return v;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
// Prefer the EDDA_* env vars; fall back to the legacy NOUS_* names so existing configs keep working.
|
|
28
|
+
const envKey = () => resolvedEnv("EDDA_API_KEY") ?? resolvedEnv("NOUS_API_KEY");
|
|
29
|
+
const envUrl = () => resolvedEnv("EDDA_API_URL") ?? resolvedEnv("NOUS_API_URL");
|
|
30
|
+
const API_URL = envUrl() || "https://api.opennous.cloud";
|
|
28
31
|
|
|
29
32
|
// Per-request key context for the hosted HTTP server. Empty in stdio mode.
|
|
30
33
|
export const apiKeyStore = new AsyncLocalStorage();
|
|
@@ -35,17 +38,16 @@ export function runWithApiKey(apiKey, fn) {
|
|
|
35
38
|
return apiKeyStore.run({ apiKey }, fn);
|
|
36
39
|
}
|
|
37
40
|
|
|
38
|
-
// Credential written by
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
//
|
|
41
|
+
// Credential written by the CLI login (the browser device-auth flow). The CLI and the MCP server
|
|
42
|
+
// share a config.json, so a user who runs the login command gets a key — and, for self-host, the
|
|
43
|
+
// API URL — the MCP picks up on the next call, with no paste and no env var. Checks ~/.edda first,
|
|
44
|
+
// then legacy ~/.nous.
|
|
42
45
|
function readFileConfig() {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return JSON.parse(fs.readFileSync(path.join(dir, "config.json"), "utf8"));
|
|
46
|
-
} catch {
|
|
47
|
-
return null;
|
|
46
|
+
const dirs = [resolvedEnv("EDDA_CONFIG_DIR"), resolvedEnv("NOUS_CONFIG_DIR"), path.join(os.homedir(), ".edda"), path.join(os.homedir(), ".nous")].filter(Boolean);
|
|
47
|
+
for (const dir of dirs) {
|
|
48
|
+
try { return JSON.parse(fs.readFileSync(path.join(dir, "config.json"), "utf8")); } catch { /* try next */ }
|
|
48
49
|
}
|
|
50
|
+
return null;
|
|
49
51
|
}
|
|
50
52
|
function clean(v) {
|
|
51
53
|
return v && !String(v).includes("${") ? v : undefined; // drop unresolved ${...} markers
|
|
@@ -54,25 +56,22 @@ function fileApiKey() { return clean(readFileConfig()?.apiKey); }
|
|
|
54
56
|
function fileApiUrl() { return clean(readFileConfig()?.apiUrl); }
|
|
55
57
|
|
|
56
58
|
function currentApiKey() {
|
|
57
|
-
return apiKeyStore.getStore()?.apiKey ??
|
|
59
|
+
return apiKeyStore.getStore()?.apiKey ?? envKey() ?? fileApiKey();
|
|
58
60
|
}
|
|
59
61
|
|
|
60
|
-
// Resolve the API base per call: env →
|
|
61
|
-
//
|
|
62
|
-
// gets the MCP pointed at their own instance automatically.
|
|
62
|
+
// Resolve the API base per call: env → config.json (set by the CLI login on self-host) → cloud
|
|
63
|
+
// default. So a self-hoster who logs in via the CLI gets the MCP pointed at their own instance.
|
|
63
64
|
function currentApiUrl() {
|
|
64
|
-
return
|
|
65
|
+
return envUrl() ?? fileApiUrl() ?? "https://api.opennous.cloud";
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
// stdio-only preflight. A key may come from the env OR
|
|
68
|
-
//
|
|
69
|
-
// the user can run the login command after installing the plugin, and the key
|
|
70
|
-
// is resolved per-call.
|
|
68
|
+
// stdio-only preflight. A key may come from the env OR the CLI login credential file. Advisory —
|
|
69
|
+
// the server still starts without one so the user can log in after installing, key resolved per-call.
|
|
71
70
|
export function validateConfig() {
|
|
72
|
-
if (!
|
|
71
|
+
if (!envKey() && !fileApiKey()) {
|
|
73
72
|
throw new Error(
|
|
74
73
|
"No Edda API key found. Run `npx @edda-business/cli login` to sign in (or `npx @edda-business/cli init` " +
|
|
75
|
-
"to set up from scratch), or set
|
|
74
|
+
"to set up from scratch), or set EDDA_API_KEY."
|
|
76
75
|
);
|
|
77
76
|
}
|
|
78
77
|
}
|
package/src/index.js
CHANGED
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
* variant see http.js; the tools themselves live in server.js.
|
|
9
9
|
*
|
|
10
10
|
* Required env:
|
|
11
|
-
*
|
|
11
|
+
* EDDA_API_KEY — workspace API key (Sources -> API Keys). Encodes the workspace + scope.
|
|
12
12
|
* Optional:
|
|
13
|
-
*
|
|
13
|
+
* EDDA_API_URL — API base URL for your instance, e.g. https://api.whitehayai.com
|
|
14
|
+
* (Legacy NOUS_API_KEY / NOUS_API_URL are still accepted as a fallback.)
|
|
14
15
|
*/
|
|
15
16
|
|
|
16
17
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|