clavarium 0.2.240-beta.1 → 0.2.241-beta.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/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/server/mcpx.mjs +14 -3
- package/web/app.js +15 -3
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.241-beta.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "clavarium",
|
|
9
|
-
"version": "0.2.
|
|
9
|
+
"version": "0.2.241-beta.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/package.json
CHANGED
package/server/mcpx.mjs
CHANGED
|
@@ -68,6 +68,17 @@ export async function mcpAdd({ tethers, secrets }, body = {}) {
|
|
|
68
68
|
return scrub(shown(r.data), key);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
/* Where a pasted block keeps its servers (20-11, the owner: not all say "mcpServers"): "mcpServers" (Claude, Cursor,
|
|
72
|
+
Windsurf), "servers" (VS Code's mcp.json), "mcp": { "servers" } (VS Code's settings), "mcp" (OpenCode),
|
|
73
|
+
"context_servers" (Zed), or one server by itself ({ "url": ... }). */
|
|
74
|
+
const OBJ = (x) => (x && typeof x === 'object' && !Array.isArray(x) ? x : null);
|
|
75
|
+
export function serversOf(j) {
|
|
76
|
+
if (!OBJ(j)) return null;
|
|
77
|
+
const one = j.url || j.serverUrl || j.httpUrl;
|
|
78
|
+
return OBJ(j.mcpServers) ?? OBJ(j.servers) ?? OBJ(OBJ(j.mcp)?.servers) ?? (OBJ(j.mcp) && !OBJ(j.mcp).servers ? j.mcp : null) ?? OBJ(j.context_servers) ?? (one ? { [j.name || 'mcp']: j } : null);
|
|
79
|
+
}
|
|
80
|
+
/* A program to start, whatever its tool calls it (OpenCode: "type": "local", its command a list). */
|
|
81
|
+
const isProgram = (s) => s.command !== undefined || s.args !== undefined || s.type === 'stdio' || s.type === 'local';
|
|
71
82
|
/* IMPORT a pasted { "mcpServers": { name: { url, headers: { Authorization: "Bearer ${NAME}" } } } }: each key a
|
|
72
83
|
reference to a secret of the vault (none written in it), no program to start. -> the targets made. */
|
|
73
84
|
export async function mcpImport({ tethers, secrets }, body = {}) {
|
|
@@ -75,13 +86,13 @@ export async function mcpImport({ tethers, secrets }, body = {}) {
|
|
|
75
86
|
if (typeof config === 'string') {
|
|
76
87
|
try { config = JSON.parse(config); } catch { throw new Refusal(400, 'That is not JSON: paste the whole { "mcpServers": ... } block.'); }
|
|
77
88
|
}
|
|
78
|
-
const all =
|
|
89
|
+
const all = serversOf(config);
|
|
79
90
|
if (!all || typeof all !== 'object' || Array.isArray(all) || !Object.keys(all).length) throw new Refusal(400, 'Paste a block like { "mcpServers": { "name": { "url": "https://...", "headers": { "Authorization": "Bearer ${SECRET}" } } } }.');
|
|
80
91
|
const servers = {};
|
|
81
92
|
for (const [name, s] of Object.entries(all)) {
|
|
82
93
|
const label = String(name).slice(0, 60);
|
|
83
94
|
if (!s || typeof s !== 'object' || Array.isArray(s)) throw new Refusal(400, `${label}: not a server.`);
|
|
84
|
-
if (s
|
|
95
|
+
if (isProgram(s)) throw new Refusal(400, `${label}: a program to start (stdio) is not run here. Only a server reached by its address.`);
|
|
85
96
|
const heads = s.headers && typeof s.headers === 'object' && !Array.isArray(s.headers) ? Object.entries(s.headers) : [];
|
|
86
97
|
if (heads.length > 1) throw new Refusal(400, `${label}: one header for the key at most.`);
|
|
87
98
|
for (const [h, v] of heads) {
|
|
@@ -91,7 +102,7 @@ export async function mcpImport({ tethers, secrets }, body = {}) {
|
|
|
91
102
|
if (!REF.test(m[2]) || !known(secrets, m[2])) throw new Refusal(400, `${label}: no secret named ${m[2].slice(0, 60)} here. Add it in Secrets first.`);
|
|
92
103
|
}
|
|
93
104
|
if (s.env && typeof s.env === 'object' && Object.keys(s.env).length) throw new Refusal(400, `${label}: "env" is for a program to start. Only a server reached by its address.`);
|
|
94
|
-
servers[name] = { url: s.url ?? s.serverUrl, ...(heads.length ? { headers: Object.fromEntries(heads) } : {}), ...(s.allowHttp === true ? { allowHttp: true } : {}) };
|
|
105
|
+
servers[name] = { url: s.url ?? s.serverUrl ?? s.httpUrl, ...(heads.length ? { headers: Object.fromEntries(heads) } : {}), ...(s.allowHttp === true ? { allowHttp: true } : {}) };
|
|
95
106
|
}
|
|
96
107
|
const r = await tethers.act('mcp-import', { config: { mcpServers: servers } }, '');
|
|
97
108
|
if (!r.ok) throw new Refusal(400, r.text);
|
package/web/app.js
CHANGED
|
@@ -10905,15 +10905,27 @@
|
|
|
10905
10905
|
naming its keys as secrets (${NAME}) is imported as it is; a program to start (stdio) is not run here. */
|
|
10906
10906
|
const mcpWord = (k, en, v) => uiSaid(k, en, v);
|
|
10907
10907
|
const mcpMask = (k) => (k.length <= 8 ? '••••' : `${k.slice(0, 4)}••••${k.slice(-3)}`);
|
|
10908
|
+
/* Where a pasted block keeps its servers (20-11, the owner: not all say "mcpServers"): "mcpServers" (Claude, Cursor,
|
|
10909
|
+
Windsurf), "servers" (VS Code's mcp.json), "mcp": { "servers" } (VS Code's settings), "mcp" (OpenCode),
|
|
10910
|
+
"context_servers" (Zed), or one server by itself ({ "url": ... }). */
|
|
10911
|
+
const OBJ = (x) => (x && typeof x === 'object' && !Array.isArray(x) ? x : null);
|
|
10912
|
+
function serversOf(j) {
|
|
10913
|
+
if (!OBJ(j)) return null;
|
|
10914
|
+
const one = j.url || j.serverUrl || j.httpUrl;
|
|
10915
|
+
return OBJ(j.mcpServers) ?? OBJ(j.servers) ?? OBJ(OBJ(j.mcp)?.servers) ?? (OBJ(j.mcp) && !OBJ(j.mcp).servers ? j.mcp : null) ?? OBJ(j.context_servers) ?? (one ? { [j.name || 'mcp']: j } : null);
|
|
10916
|
+
}
|
|
10917
|
+
/* A program to start, whatever its tool calls it (OpenCode: "type": "local", its command a list). */
|
|
10918
|
+
const isProgram = (s) => s.command !== undefined || s.args !== undefined || s.type === 'stdio' || s.type === 'local';
|
|
10919
|
+
|
|
10908
10920
|
function mcpRead(text) {
|
|
10909
10921
|
let j;
|
|
10910
10922
|
try { j = JSON.parse(text); } catch { return { error: mcpWord('set-mcp-notjson', 'Not JSON: paste the whole block.') }; }
|
|
10911
|
-
const all =
|
|
10923
|
+
const all = serversOf(j);
|
|
10912
10924
|
if (!all || typeof all !== 'object' || Array.isArray(all) || !Object.keys(all).length) return { error: mcpWord('set-mcp-noserver', 'No server in this block.') };
|
|
10913
10925
|
const servers = []; let refs = false;
|
|
10914
10926
|
for (const [name, s] of Object.entries(all)) {
|
|
10915
10927
|
if (!s || typeof s !== 'object') return { error: mcpWord('set-mcp-noserver', 'No server in this block.') };
|
|
10916
|
-
if (s
|
|
10928
|
+
if (isProgram(s)) return { error: mcpWord('set-mcp-program', '« {name} »: a program to start, refused here.', { name }) };
|
|
10917
10929
|
const heads = s.headers && typeof s.headers === 'object' ? Object.entries(s.headers) : [];
|
|
10918
10930
|
if (heads.length > 1) return { error: mcpWord('set-mcp-heads', '« {name} »: one header for its key at most.', { name }) };
|
|
10919
10931
|
let key = '', header = '';
|
|
@@ -10924,7 +10936,7 @@
|
|
|
10924
10936
|
if (h.toLowerCase() === 'authorization') { if (!bearer) return { error: mcpWord('set-mcp-basic', '« {name} »: not a « Bearer » key, fill in by hand.', { name }) }; key = bearer[1].trim(); }
|
|
10925
10937
|
else { key = value; header = h; }
|
|
10926
10938
|
}
|
|
10927
|
-
servers.push({ name: String(name).slice(0, 120), url: String(s.url ?? s.serverUrl ?? ''), key, header });
|
|
10939
|
+
servers.push({ name: String(name).slice(0, 120), url: String(s.url ?? s.serverUrl ?? s.httpUrl ?? ''), key, header });
|
|
10928
10940
|
}
|
|
10929
10941
|
return { servers, refs };
|
|
10930
10942
|
}
|