@bevel-software/platform-core-frontend 0.12.1 → 0.13.3
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 +2 -2
- package/src/modules/library/__tests__/McpServerSection.test.tsx +95 -0
- package/src/modules/library/__tests__/SkillPage.test.tsx +209 -5
- package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +31 -0
- package/src/modules/library/__tests__/ToolVarRow.test.tsx +18 -0
- package/src/modules/library/components/skill-page/SkillPage.tsx +178 -9
- package/src/modules/library/components/tool-page/McpServerSection.tsx +338 -65
- package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +25 -9
- package/src/modules/library/components/tool-page/ToolVarRow.tsx +8 -0
- package/src/modules/library/services/tools.api.ts +23 -1
- package/src/modules/secrets-vault/components/SecretsPage.tsx +321 -313
- package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +20 -11
- package/src/modules/secrets-vault/services/secrets.api.ts +2 -0
- package/src/modules/secrets-vault/services/tool-secrets.api.ts +6 -3
- package/src/modules/workspace/components/EditorTabs.tsx +9 -17
- package/src/modules/workspace/components/FileExplorer.tsx +10 -4
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +170 -1
- package/src/modules/workspace/utils/__tests__/fileTree.test.ts +58 -0
- package/src/modules/workspace/utils/fileTree.ts +10 -1
- package/src/shared/components/__tests__/usePointerMenuPosition.test.tsx +50 -0
- package/src/shared/components/index.ts +2 -0
- package/src/shared/components/usePointerMenuPosition.ts +92 -0
|
@@ -4,6 +4,7 @@ import { Badge, Banner, Button, Dialog } from '../../../../shared/components';
|
|
|
4
4
|
import {
|
|
5
5
|
getMcpServer,
|
|
6
6
|
putMcpServer,
|
|
7
|
+
type McpServerVariable,
|
|
7
8
|
type McpServerView,
|
|
8
9
|
type McpTransport,
|
|
9
10
|
} from '../../services/tools.api';
|
|
@@ -15,6 +16,13 @@ import { pathForTool } from '../../routes/library-paths';
|
|
|
15
16
|
* manuals (the GET 404s: those edit as files) and renders read-only facts for
|
|
16
17
|
* non-writers, whose editing surface this page has never been.
|
|
17
18
|
*
|
|
19
|
+
* WHAT THE FILES SAY IS WHAT THE PAGE SHOWS. One server's truth spans two
|
|
20
|
+
* files (mcp.json for the portable half, plugin.json's extensions block for
|
|
21
|
+
* ours), and the reader should not have to open either to know what is
|
|
22
|
+
* configured: the read-only view lists every stored fact — headers, declared
|
|
23
|
+
* variables, a sign-in's client id and endpoints — and the editor edits
|
|
24
|
+
* exactly those, so a save changes nothing the view didn't show.
|
|
25
|
+
*
|
|
18
26
|
* RENAME CONFIRMS, WITH THE COST NAMED. The server's name is the namespace
|
|
19
27
|
* its vault secrets bind to (`<name>_<VAR>`), so renaming disconnects every
|
|
20
28
|
* configured value and completed sign-in under the old name. The page already
|
|
@@ -49,7 +57,7 @@ export function McpServerSection({
|
|
|
49
57
|
const [literalHeaders, setLiteralHeaders] = useState('');
|
|
50
58
|
const [authHeaders, setAuthHeaders] = useState('');
|
|
51
59
|
const [local, setLocal] = useState(false);
|
|
52
|
-
const [variables, setVariables] = useState<
|
|
60
|
+
const [variables, setVariables] = useState<McpServerVariable[]>([]);
|
|
53
61
|
|
|
54
62
|
useEffect(() => {
|
|
55
63
|
let live = true;
|
|
@@ -83,6 +91,20 @@ export function McpServerSection({
|
|
|
83
91
|
setEditing(true);
|
|
84
92
|
};
|
|
85
93
|
|
|
94
|
+
/**
|
|
95
|
+
* A sign-in's token has to reach the server somehow — turning one on
|
|
96
|
+
* pre-fills the `Authorization` header the variable loader will fill,
|
|
97
|
+
* VISIBLY, in the auth-headers field the writer is already looking at.
|
|
98
|
+
* Never over an Authorization header that's already there.
|
|
99
|
+
*/
|
|
100
|
+
const suggestAuthHeader = (varName: string) => {
|
|
101
|
+
if (!varName) return;
|
|
102
|
+
const has = Object.keys(linesToHeaders(authHeaders)).some((h) => h.toLowerCase() === 'authorization');
|
|
103
|
+
if (has) return;
|
|
104
|
+
const line = `Authorization: Bearer \${${varName}}`;
|
|
105
|
+
setAuthHeaders((prev) => (prev.trim() ? `${prev.replace(/\n+$/, '')}\n${line}` : line));
|
|
106
|
+
};
|
|
107
|
+
|
|
86
108
|
const save = async () => {
|
|
87
109
|
const renaming = name.trim() !== server.name;
|
|
88
110
|
// EVERY rename confirms: this caller's page only knows their own and the
|
|
@@ -111,9 +133,7 @@ export function McpServerSection({
|
|
|
111
133
|
: { url: url.trim() }),
|
|
112
134
|
literalHeaders: linesToHeaders(literalHeaders),
|
|
113
135
|
authHeaders: linesToHeaders(authHeaders),
|
|
114
|
-
variables: variables
|
|
115
|
-
.map((v) => ({ ...v, name: v.name.trim(), label: v.label?.trim() || undefined }))
|
|
116
|
-
.filter((v) => v.name.length > 0),
|
|
136
|
+
variables: variables.map(normalizeVariable).filter((v) => v.name.length > 0),
|
|
117
137
|
...(server.description ? { description: server.description } : {}),
|
|
118
138
|
local,
|
|
119
139
|
});
|
|
@@ -144,31 +164,7 @@ export function McpServerSection({
|
|
|
144
164
|
|
|
145
165
|
{!editing && (
|
|
146
166
|
<div className="flex items-start justify-between gap-4 rounded-md border border-line px-3.5 py-2.5">
|
|
147
|
-
<
|
|
148
|
-
<div className="flex gap-2">
|
|
149
|
-
<dt className="shrink-0 font-semibold">Transport</dt>
|
|
150
|
-
<dd>{server.transport}</dd>
|
|
151
|
-
</div>
|
|
152
|
-
{server.url && (
|
|
153
|
-
<div className="flex gap-2">
|
|
154
|
-
<dt className="shrink-0 font-semibold">URL</dt>
|
|
155
|
-
<dd className="truncate">{server.url}</dd>
|
|
156
|
-
</div>
|
|
157
|
-
)}
|
|
158
|
-
{server.command && (
|
|
159
|
-
<div className="flex gap-2">
|
|
160
|
-
<dt className="shrink-0 font-semibold">Command</dt>
|
|
161
|
-
<dd className="truncate">
|
|
162
|
-
{server.command} {(server.args ?? []).join(' ')}
|
|
163
|
-
</dd>
|
|
164
|
-
</div>
|
|
165
|
-
)}
|
|
166
|
-
{server.local && (
|
|
167
|
-
<div className="mt-1 text-ink-faint">
|
|
168
|
-
Runs locally — served by the local knowledge server on each member's machine, never by the workspace.
|
|
169
|
-
</div>
|
|
170
|
-
)}
|
|
171
|
-
</dl>
|
|
167
|
+
<ServerFacts server={server} />
|
|
172
168
|
{server.canWrite && (
|
|
173
169
|
<Button variant="outline" size="sm" onClick={openEditor}>
|
|
174
170
|
Edit server
|
|
@@ -207,7 +203,7 @@ export function McpServerSection({
|
|
|
207
203
|
hint="One `Header: value` per line. Visible package data — no secrets here." />
|
|
208
204
|
<LabeledTextarea label="Auth headers" value={authHeaders} onChange={setAuthHeaders}
|
|
209
205
|
hint="One per line; values may use ${VAR} vault references, e.g. `Authorization: Bearer ${API_KEY}`." />
|
|
210
|
-
<VariablesEditor variables={variables} onChange={setVariables} />
|
|
206
|
+
<VariablesEditor variables={variables} onChange={setVariables} onSignInEnabled={suggestAuthHeader} />
|
|
211
207
|
{transport !== 'stdio' && (
|
|
212
208
|
<label className="flex items-center gap-2 text-detail text-ink-muted">
|
|
213
209
|
<input type="checkbox" checked={local} onChange={(e) => setLocal(e.target.checked)} />
|
|
@@ -248,6 +244,109 @@ export function McpServerSection({
|
|
|
248
244
|
);
|
|
249
245
|
}
|
|
250
246
|
|
|
247
|
+
/**
|
|
248
|
+
* Everything the two files store about this server, read-only. Facts are
|
|
249
|
+
* grouped the way the files split them — portable (mcp.json) first, then
|
|
250
|
+
* ours (plugin.json) — so a reader can tell where an edit by hand would land.
|
|
251
|
+
* Nothing is elided: a header, a declared variable, a sign-in's endpoints all
|
|
252
|
+
* appear here exactly as saved, or the editor would be changing invisible state.
|
|
253
|
+
*/
|
|
254
|
+
function ServerFacts({ server }: { server: McpServerView }) {
|
|
255
|
+
const literal = Object.entries(server.literalHeaders);
|
|
256
|
+
const auth = Object.entries(server.authHeaders);
|
|
257
|
+
return (
|
|
258
|
+
<dl className="min-w-0 flex-1 text-detail text-ink-muted" aria-label="Server configuration">
|
|
259
|
+
<Fact label="Transport">{server.transport}</Fact>
|
|
260
|
+
{server.url && <Fact label="URL" mono>{server.url}</Fact>}
|
|
261
|
+
{server.command && (
|
|
262
|
+
<Fact label="Command" mono>
|
|
263
|
+
{server.command} {(server.args ?? []).join(' ')}
|
|
264
|
+
</Fact>
|
|
265
|
+
)}
|
|
266
|
+
{server.description && <Fact label="Description">{server.description}</Fact>}
|
|
267
|
+
{literal.length > 0 && (
|
|
268
|
+
<Fact label="Headers">
|
|
269
|
+
<HeaderList entries={literal} />
|
|
270
|
+
</Fact>
|
|
271
|
+
)}
|
|
272
|
+
{auth.length > 0 && (
|
|
273
|
+
<Fact label="Auth headers">
|
|
274
|
+
<HeaderList entries={auth} />
|
|
275
|
+
</Fact>
|
|
276
|
+
)}
|
|
277
|
+
{server.variables.length > 0 && (
|
|
278
|
+
<Fact label="Variables">
|
|
279
|
+
<ul className="flex flex-col gap-1">
|
|
280
|
+
{server.variables.map((v) => (
|
|
281
|
+
<li key={v.name}>
|
|
282
|
+
<code className="rounded-sm bg-sunken px-1 py-0.5 font-mono text-meta text-ink">{`\${${v.name}}`}</code>{' '}
|
|
283
|
+
<span>{v.scope === 'user' ? 'each member their own' : 'one shared value'}</span>
|
|
284
|
+
{v.label && <span className="text-ink-faint"> — {v.label}</span>}
|
|
285
|
+
{v.oauth && <SignInFacts oauth={v.oauth} />}
|
|
286
|
+
</li>
|
|
287
|
+
))}
|
|
288
|
+
</ul>
|
|
289
|
+
</Fact>
|
|
290
|
+
)}
|
|
291
|
+
{server.local && (
|
|
292
|
+
<div className="mt-1 text-ink-faint">
|
|
293
|
+
Runs locally — served by the local knowledge server on each member's machine, never by the workspace.
|
|
294
|
+
</div>
|
|
295
|
+
)}
|
|
296
|
+
</dl>
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/** A declared sign-in, as stored: client id, where the endpoints come from, scopes, PKCE. */
|
|
301
|
+
function SignInFacts({ oauth }: { oauth: NonNullable<McpServerVariable['oauth']> }) {
|
|
302
|
+
const discovered = !oauth.authorizationUrl || !oauth.tokenUrl;
|
|
303
|
+
return (
|
|
304
|
+
<ul className="ml-4 mt-0.5 flex list-disc flex-col gap-0.5 text-ink-faint">
|
|
305
|
+
<li>
|
|
306
|
+
OAuth sign-in · client id <code className="font-mono text-ink-muted">{oauth.clientId}</code>
|
|
307
|
+
</li>
|
|
308
|
+
<li>
|
|
309
|
+
{discovered ? (
|
|
310
|
+
<>Endpoints: discovered from the server</>
|
|
311
|
+
) : (
|
|
312
|
+
<>
|
|
313
|
+
Authorize <code className="font-mono">{oauth.authorizationUrl}</code> · Token{' '}
|
|
314
|
+
<code className="font-mono">{oauth.tokenUrl}</code>
|
|
315
|
+
</>
|
|
316
|
+
)}
|
|
317
|
+
</li>
|
|
318
|
+
{oauth.scopes && oauth.scopes.length > 0 && <li>Scopes: {oauth.scopes.join(' ')}</li>}
|
|
319
|
+
<li>PKCE: {oauth.pkce === false ? 'off' : 'on'}</li>
|
|
320
|
+
{oauth.resource && (
|
|
321
|
+
<li>
|
|
322
|
+
Resource <code className="font-mono">{oauth.resource}</code>
|
|
323
|
+
</li>
|
|
324
|
+
)}
|
|
325
|
+
</ul>
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
function Fact({ label, mono, children }: { label: string; mono?: boolean; children: React.ReactNode }) {
|
|
330
|
+
return (
|
|
331
|
+
<div className="flex gap-2">
|
|
332
|
+
<dt className="shrink-0 font-semibold">{label}</dt>
|
|
333
|
+
<dd className={`min-w-0 ${mono ? 'truncate font-mono' : ''}`}>{children}</dd>
|
|
334
|
+
</div>
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
function HeaderList({ entries }: { entries: [string, string][] }) {
|
|
339
|
+
return (
|
|
340
|
+
<ul className="flex flex-col">
|
|
341
|
+
{entries.map(([k, v]) => (
|
|
342
|
+
<li key={k} className="truncate font-mono">
|
|
343
|
+
{k}: {v}
|
|
344
|
+
</li>
|
|
345
|
+
))}
|
|
346
|
+
</ul>
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
|
|
251
350
|
function LabeledInput({
|
|
252
351
|
label,
|
|
253
352
|
value,
|
|
@@ -303,51 +402,198 @@ function LabeledTextarea({
|
|
|
303
402
|
* by a tool writer) or `user` (each member their own, on the Connect page).
|
|
304
403
|
* The names must match the `${VAR}` references in the auth headers — the vault
|
|
305
404
|
* key is `<server>_<VAR>`, derived from exactly these names.
|
|
405
|
+
*
|
|
406
|
+
* A user-scoped variable can be an OAuth SIGN-IN instead of a typed value:
|
|
407
|
+
* the owner's OAuth app's client id, endpoints discovered from the server
|
|
408
|
+
* (or entered by hand for a provider that publishes none), scopes, PKCE. The
|
|
409
|
+
* fields mirror the `oauth` block plugin.json stores, one to one — what an
|
|
410
|
+
* agent would write into the file is what this form writes.
|
|
306
411
|
*/
|
|
307
412
|
function VariablesEditor({
|
|
308
413
|
variables,
|
|
309
414
|
onChange,
|
|
415
|
+
onSignInEnabled,
|
|
310
416
|
}: {
|
|
311
|
-
variables:
|
|
312
|
-
onChange(next:
|
|
417
|
+
variables: McpServerVariable[];
|
|
418
|
+
onChange(next: McpServerVariable[]): void;
|
|
419
|
+
/** A sign-in was just switched on for this variable name — the parent may wire its header. */
|
|
420
|
+
onSignInEnabled(varName: string): void;
|
|
313
421
|
}) {
|
|
314
|
-
const update = (i: number, patch: Partial<
|
|
422
|
+
const update = (i: number, patch: Partial<McpServerVariable>) =>
|
|
315
423
|
onChange(variables.map((v, j) => (j === i ? { ...v, ...patch } : v)));
|
|
424
|
+
const updateOAuth = (i: number, patch: Partial<NonNullable<McpServerVariable['oauth']>>) =>
|
|
425
|
+
onChange(
|
|
426
|
+
variables.map((v, j) =>
|
|
427
|
+
j === i && v.oauth ? { ...v, oauth: { ...v.oauth, ...patch } } : v,
|
|
428
|
+
),
|
|
429
|
+
);
|
|
316
430
|
return (
|
|
317
431
|
<div className="flex flex-col gap-1 text-detail">
|
|
318
432
|
<span className="font-semibold text-ink">Variables</span>
|
|
319
|
-
{variables.map((v, i) =>
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
433
|
+
{variables.map((v, i) => {
|
|
434
|
+
const n = i + 1;
|
|
435
|
+
const oauth = v.oauth;
|
|
436
|
+
const manualEndpoints = oauth !== undefined && oauth.authorizationUrl !== undefined;
|
|
437
|
+
return (
|
|
438
|
+
// Index keys are correct here: rows are edited in place and have no
|
|
439
|
+
// identity beyond their position until saved.
|
|
440
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
441
|
+
<div key={i} className="flex flex-col gap-1.5 rounded-md border border-line px-2.5 py-2">
|
|
442
|
+
<div className="flex items-center gap-2">
|
|
443
|
+
<input
|
|
444
|
+
aria-label={`Variable ${n} name`}
|
|
445
|
+
className="w-40 rounded-md border border-line bg-white px-2 py-1 font-mono text-ui"
|
|
446
|
+
value={v.name}
|
|
447
|
+
onChange={(e) => update(i, { name: e.target.value })}
|
|
448
|
+
/>
|
|
449
|
+
<select
|
|
450
|
+
aria-label={`Variable ${n} scope`}
|
|
451
|
+
className="rounded-md border border-line bg-white px-2 py-1 text-ui"
|
|
452
|
+
value={v.scope}
|
|
453
|
+
onChange={(e) => {
|
|
454
|
+
const scope = e.target.value as 'admin' | 'user';
|
|
455
|
+
// A sign-in is per-caller by nature; a shared token would
|
|
456
|
+
// hand one member's grant to everyone. Dropping it here is
|
|
457
|
+
// the same rule the save enforces, made visible early.
|
|
458
|
+
const next: McpServerVariable = { ...v, scope };
|
|
459
|
+
if (scope !== 'user') delete next.oauth;
|
|
460
|
+
onChange(variables.map((x, j) => (j === i ? next : x)));
|
|
461
|
+
}}
|
|
462
|
+
>
|
|
463
|
+
<option value="admin">admin — one shared value</option>
|
|
464
|
+
<option value="user">user — each member their own</option>
|
|
465
|
+
</select>
|
|
466
|
+
<input
|
|
467
|
+
aria-label={`Variable ${n} label`}
|
|
468
|
+
className="min-w-0 flex-1 rounded-md border border-line bg-white px-2 py-1 text-ui"
|
|
469
|
+
placeholder="Label shown in the secrets UI"
|
|
470
|
+
value={v.label ?? ''}
|
|
471
|
+
onChange={(e) => update(i, { label: e.target.value || undefined })}
|
|
472
|
+
/>
|
|
473
|
+
<Button variant="quiet" size="sm" onClick={() => onChange(variables.filter((_, j) => j !== i))}>
|
|
474
|
+
Remove
|
|
475
|
+
</Button>
|
|
476
|
+
</div>
|
|
477
|
+
{v.scope === 'user' && (
|
|
478
|
+
<label className="flex items-center gap-2 text-ink-muted">
|
|
479
|
+
<input
|
|
480
|
+
type="checkbox"
|
|
481
|
+
aria-label={`Variable ${n} OAuth sign-in`}
|
|
482
|
+
checked={oauth !== undefined}
|
|
483
|
+
onChange={(e) => {
|
|
484
|
+
if (e.target.checked) {
|
|
485
|
+
update(i, { oauth: { clientId: '' } });
|
|
486
|
+
onSignInEnabled(v.name.trim());
|
|
487
|
+
} else {
|
|
488
|
+
const next = { ...v };
|
|
489
|
+
delete next.oauth;
|
|
490
|
+
onChange(variables.map((x, j) => (j === i ? next : x)));
|
|
491
|
+
}
|
|
492
|
+
}}
|
|
493
|
+
/>
|
|
494
|
+
OAuth sign-in — members sign in with the provider instead of pasting a value
|
|
495
|
+
</label>
|
|
496
|
+
)}
|
|
497
|
+
{oauth && (
|
|
498
|
+
<div className="ml-5 flex flex-col gap-1.5 border-l-2 border-line pl-3">
|
|
499
|
+
<label className="flex flex-col gap-1">
|
|
500
|
+
<span className="font-semibold text-ink">Client ID</span>
|
|
501
|
+
<input
|
|
502
|
+
aria-label={`Variable ${n} client id`}
|
|
503
|
+
className="rounded-md border border-line bg-white px-2 py-1 font-mono text-ui"
|
|
504
|
+
value={oauth.clientId}
|
|
505
|
+
onChange={(e) => updateOAuth(i, { clientId: e.target.value })}
|
|
506
|
+
/>
|
|
507
|
+
<span className="text-ink-faint">
|
|
508
|
+
From the OAuth app you registered with the provider. Its client secret is
|
|
509
|
+
pasted on this page after saving — never in a file.
|
|
510
|
+
</span>
|
|
511
|
+
</label>
|
|
512
|
+
<div className="flex flex-col gap-1">
|
|
513
|
+
<span className="font-semibold text-ink">Endpoints</span>
|
|
514
|
+
<label className="flex items-center gap-2 text-ink-muted">
|
|
515
|
+
<input
|
|
516
|
+
type="radio"
|
|
517
|
+
name={`variable-${n}-endpoints`}
|
|
518
|
+
aria-label={`Variable ${n} endpoints discovered`}
|
|
519
|
+
checked={!manualEndpoints}
|
|
520
|
+
onChange={() => {
|
|
521
|
+
const next = { ...oauth };
|
|
522
|
+
delete next.authorizationUrl;
|
|
523
|
+
delete next.tokenUrl;
|
|
524
|
+
update(i, { oauth: next });
|
|
525
|
+
}}
|
|
526
|
+
/>
|
|
527
|
+
Discover from the server (MCP servers publish them)
|
|
528
|
+
</label>
|
|
529
|
+
<label className="flex items-center gap-2 text-ink-muted">
|
|
530
|
+
<input
|
|
531
|
+
type="radio"
|
|
532
|
+
name={`variable-${n}-endpoints`}
|
|
533
|
+
aria-label={`Variable ${n} endpoints by hand`}
|
|
534
|
+
checked={manualEndpoints}
|
|
535
|
+
onChange={() =>
|
|
536
|
+
updateOAuth(i, {
|
|
537
|
+
authorizationUrl: oauth.authorizationUrl ?? '',
|
|
538
|
+
tokenUrl: oauth.tokenUrl ?? '',
|
|
539
|
+
})
|
|
540
|
+
}
|
|
541
|
+
/>
|
|
542
|
+
Enter by hand (the provider publishes no OAuth metadata)
|
|
543
|
+
</label>
|
|
544
|
+
{manualEndpoints && (
|
|
545
|
+
<div className="ml-5 flex flex-col gap-1.5">
|
|
546
|
+
<input
|
|
547
|
+
aria-label={`Variable ${n} authorization URL`}
|
|
548
|
+
className="rounded-md border border-line bg-white px-2 py-1 font-mono text-ui"
|
|
549
|
+
placeholder="https://provider.example/oauth/authorize"
|
|
550
|
+
value={oauth.authorizationUrl ?? ''}
|
|
551
|
+
onChange={(e) => updateOAuth(i, { authorizationUrl: e.target.value })}
|
|
552
|
+
/>
|
|
553
|
+
<input
|
|
554
|
+
aria-label={`Variable ${n} token URL`}
|
|
555
|
+
className="rounded-md border border-line bg-white px-2 py-1 font-mono text-ui"
|
|
556
|
+
placeholder="https://provider.example/oauth/token"
|
|
557
|
+
value={oauth.tokenUrl ?? ''}
|
|
558
|
+
onChange={(e) => updateOAuth(i, { tokenUrl: e.target.value })}
|
|
559
|
+
/>
|
|
560
|
+
</div>
|
|
561
|
+
)}
|
|
562
|
+
</div>
|
|
563
|
+
<label className="flex flex-col gap-1">
|
|
564
|
+
<span className="font-semibold text-ink">Scopes</span>
|
|
565
|
+
<input
|
|
566
|
+
aria-label={`Variable ${n} scopes`}
|
|
567
|
+
className="rounded-md border border-line bg-white px-2 py-1 font-mono text-ui"
|
|
568
|
+
placeholder="space-separated, e.g. crm.objects.contacts.read"
|
|
569
|
+
value={(oauth.scopes ?? []).join(' ')}
|
|
570
|
+
onChange={(e) => {
|
|
571
|
+
// Split on save-shaped boundaries but keep the field
|
|
572
|
+
// typeable: a trailing space is a scope being started.
|
|
573
|
+
const scopes = e.target.value.split(/[\s,]+/);
|
|
574
|
+
updateOAuth(i, { scopes: scopes.length === 1 && scopes[0] === '' ? undefined : scopes });
|
|
575
|
+
}}
|
|
576
|
+
/>
|
|
577
|
+
</label>
|
|
578
|
+
<label className="flex items-center gap-2 text-ink-muted">
|
|
579
|
+
<input
|
|
580
|
+
type="checkbox"
|
|
581
|
+
aria-label={`Variable ${n} PKCE`}
|
|
582
|
+
checked={oauth.pkce !== false}
|
|
583
|
+
onChange={(e) => {
|
|
584
|
+
const next = { ...oauth };
|
|
585
|
+
if (e.target.checked) delete next.pkce;
|
|
586
|
+
else next.pkce = false;
|
|
587
|
+
update(i, { oauth: next });
|
|
588
|
+
}}
|
|
589
|
+
/>
|
|
590
|
+
PKCE (S256) — required by MCP servers; harmless for providers that ignore it
|
|
591
|
+
</label>
|
|
592
|
+
</div>
|
|
593
|
+
)}
|
|
594
|
+
</div>
|
|
595
|
+
);
|
|
596
|
+
})}
|
|
351
597
|
<div>
|
|
352
598
|
<Button variant="outline" size="sm" onClick={() => onChange([...variables, { name: '', scope: 'admin' }])}>
|
|
353
599
|
Add variable
|
|
@@ -361,6 +607,33 @@ function VariablesEditor({
|
|
|
361
607
|
);
|
|
362
608
|
}
|
|
363
609
|
|
|
610
|
+
/**
|
|
611
|
+
* The stored shape of one row: trimmed, empties dropped, the sign-in's
|
|
612
|
+
* endpoints sent as typed (a half pair is the backend's 422 to give, not
|
|
613
|
+
* something to silently complete or discard here).
|
|
614
|
+
*/
|
|
615
|
+
function normalizeVariable(v: McpServerVariable): McpServerVariable {
|
|
616
|
+
const label = v.label?.trim();
|
|
617
|
+
const base: McpServerVariable = { name: v.name.trim(), scope: v.scope, ...(label ? { label } : {}) };
|
|
618
|
+
if (!v.oauth || v.scope !== 'user') return base;
|
|
619
|
+
const o = v.oauth;
|
|
620
|
+
const authorizationUrl = o.authorizationUrl?.trim();
|
|
621
|
+
const tokenUrl = o.tokenUrl?.trim();
|
|
622
|
+
const scopes = (o.scopes ?? []).map((s) => s.trim()).filter(Boolean);
|
|
623
|
+
return {
|
|
624
|
+
...base,
|
|
625
|
+
oauth: {
|
|
626
|
+
...(authorizationUrl ? { authorizationUrl } : {}),
|
|
627
|
+
...(tokenUrl ? { tokenUrl } : {}),
|
|
628
|
+
clientId: o.clientId.trim(),
|
|
629
|
+
...(scopes.length > 0 ? { scopes } : {}),
|
|
630
|
+
...(o.authParams ? { authParams: o.authParams } : {}),
|
|
631
|
+
...(o.pkce === false ? { pkce: false } : {}),
|
|
632
|
+
...(o.resource ? { resource: o.resource } : {}),
|
|
633
|
+
},
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
|
|
364
637
|
function headersToLines(headers: Record<string, string>): string {
|
|
365
638
|
return Object.entries(headers)
|
|
366
639
|
.map(([k, v]) => `${k}: ${v}`)
|
|
@@ -14,11 +14,12 @@ import { ToolVarRow } from './ToolVarRow';
|
|
|
14
14
|
* from you on everyone's behalf.
|
|
15
15
|
*
|
|
16
16
|
* The setup banner above the rows exists because `oauth-manual` is the one
|
|
17
|
-
* state the rows CANNOT explain on their own:
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
17
|
+
* state the rows CANNOT explain on their own: the remote server wants a sign-in
|
|
18
|
+
* through an app the OWNER registers, so every row underneath is stuck through
|
|
19
|
+
* no fault of the person reading them. The banner names whose move it is — the
|
|
20
|
+
* owner's — and what the move is: declare the sign-in (the server editor on
|
|
21
|
+
* this page for an mcp.json server, the file itself for a `.tool`), then set
|
|
22
|
+
* its client secret. Once declared, only the secret remains and it says so.
|
|
22
23
|
*/
|
|
23
24
|
|
|
24
25
|
export interface ToolConnectionSectionProps {
|
|
@@ -40,6 +41,12 @@ export function ToolConnectionSection({ tool, onChanged, onError }: ToolConnecti
|
|
|
40
41
|
// No oauth variable at all is the un-started case, so it counts as unfinished.
|
|
41
42
|
const setupUnfinished =
|
|
42
43
|
setupKind === 'oauth-manual' && !tool.variables.some((v) => v.oauth && v.adminConfigured);
|
|
44
|
+
// Declared but not yet finished: the client id is in the file, the secret
|
|
45
|
+
// isn't in the vault. Different sentence — "set the secret", not "declare".
|
|
46
|
+
const signInDeclared = tool.variables.some((v) => v.oauth);
|
|
47
|
+
// An mcp.json server is edited in the server section of THIS page; only a
|
|
48
|
+
// `.tool` manual sends the owner to a file.
|
|
49
|
+
const isMcpJsonServer = tool.path.endsWith('/mcp.json');
|
|
43
50
|
|
|
44
51
|
/**
|
|
45
52
|
* The CONFIGURATION this tool is still missing, named.
|
|
@@ -96,13 +103,22 @@ export function ToolConnectionSection({ tool, onChanged, onError }: ToolConnecti
|
|
|
96
103
|
|
|
97
104
|
{setupUnfinished && (
|
|
98
105
|
<Banner tone="wait" role="status" className="mb-2.5">
|
|
99
|
-
{tool.canWrite ? (
|
|
106
|
+
{tool.canWrite && signInDeclared ? (
|
|
107
|
+
<>
|
|
108
|
+
Sign-in setup needed: the sign-in is declared — set its client secret below to
|
|
109
|
+
finish.
|
|
110
|
+
{tool.setup?.reason && <em className="mt-1 block">{tool.setup.reason}</em>}
|
|
111
|
+
</>
|
|
112
|
+
) : tool.canWrite ? (
|
|
100
113
|
<>
|
|
101
114
|
Sign-in setup needed: this server needs users to sign in, but Bevel couldn't set
|
|
102
|
-
that up automatically.
|
|
103
|
-
|
|
115
|
+
that up automatically. Register an OAuth app with the provider, then{' '}
|
|
116
|
+
{isMcpJsonServer
|
|
117
|
+
? 'add a user-scoped variable with an OAuth sign-in under "Edit server" below'
|
|
118
|
+
: 'declare the sign-in on a user-scoped variable in the tool file'}
|
|
119
|
+
, and set its client secret here.
|
|
104
120
|
{tool.setup?.reason && <em className="mt-1 block">{tool.setup.reason}</em>}
|
|
105
|
-
{kbDirName && (
|
|
121
|
+
{kbDirName && !isMcpJsonServer && (
|
|
106
122
|
<Button
|
|
107
123
|
variant="quiet"
|
|
108
124
|
size="tiny"
|
|
@@ -143,7 +143,15 @@ export function ToolVarRow({
|
|
|
143
143
|
|
|
144
144
|
if (variable.authorized && !variable.needsReauth) {
|
|
145
145
|
description = 'Each person sets their own';
|
|
146
|
+
// Connected is not final: a provider can widen what it grants after the
|
|
147
|
+
// fact (HubSpot's MCP tools do, and answer REQUIRES_REAUTHORIZATION
|
|
148
|
+
// until the user consents again), a grant can be revoked provider-side,
|
|
149
|
+
// or the owner can rotate the client. The caller needs a way back into
|
|
150
|
+
// consent that doesn't wait for the scope check to notice.
|
|
146
151
|
meta.push(
|
|
152
|
+
<Button key="reconnect" size="tiny" variant="quiet" disabled={busy} onClick={() => void signIn()}>
|
|
153
|
+
Reconnect
|
|
154
|
+
</Button>,
|
|
147
155
|
<Badge key="chip" tone="ok">
|
|
148
156
|
Connected
|
|
149
157
|
</Badge>,
|
|
@@ -67,6 +67,28 @@ export async function getToolDetail(slug: string): Promise<ToolManualDetail> {
|
|
|
67
67
|
*/
|
|
68
68
|
export type McpTransport = 'streamable-http' | 'sse' | 'stdio';
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* A declared `${VAR}` of an mcp.json server, exactly as plugin.json stores it.
|
|
72
|
+
* `oauth` makes it a sign-in (user-scoped only): the owner's OAuth app's client
|
|
73
|
+
* id, and optionally the provider endpoints — absent, they are discovered from
|
|
74
|
+
* the server's own OAuth metadata. PKCE is on unless `pkce: false`. The client
|
|
75
|
+
* SECRET is never here; it lives in the vault, set on the tool's page.
|
|
76
|
+
*/
|
|
77
|
+
export interface McpServerVariable {
|
|
78
|
+
name: string;
|
|
79
|
+
scope: 'admin' | 'user';
|
|
80
|
+
label?: string;
|
|
81
|
+
oauth?: {
|
|
82
|
+
authorizationUrl?: string;
|
|
83
|
+
tokenUrl?: string;
|
|
84
|
+
clientId: string;
|
|
85
|
+
scopes?: string[];
|
|
86
|
+
authParams?: Record<string, string>;
|
|
87
|
+
pkce?: boolean;
|
|
88
|
+
resource?: string;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
70
92
|
export interface McpServerView {
|
|
71
93
|
name: string;
|
|
72
94
|
transport: McpTransport;
|
|
@@ -77,7 +99,7 @@ export interface McpServerView {
|
|
|
77
99
|
env?: Record<string, string>;
|
|
78
100
|
literalHeaders: Record<string, string>;
|
|
79
101
|
authHeaders: Record<string, string>;
|
|
80
|
-
variables:
|
|
102
|
+
variables: McpServerVariable[];
|
|
81
103
|
description?: string;
|
|
82
104
|
local: boolean;
|
|
83
105
|
canWrite: boolean;
|