@blackbelt-technology/pi-dashboard-mcp-client-plugin 0.9.0 → 0.11.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/README.md +1 -1
- package/package.json +9 -4
- package/src/client/FolderMcpPage.tsx +207 -45
- package/src/client/FolderMcpSection.tsx +5 -4
- package/src/client/McpSettings.tsx +56 -39
- package/src/client/ProjectSettings.tsx +217 -0
- package/src/client/ServerEditor.tsx +2 -2
- package/src/client/ServerList.tsx +431 -170
- package/src/client/api.ts +52 -2
- package/src/client/folder-view.ts +30 -8
- package/src/client/hooks.ts +40 -5
- package/src/client/index.tsx +0 -2
- package/src/client/schema.ts +1 -1
- package/src/client/settings-ui.ts +19 -0
- package/src/core/index.ts +8 -66
- package/src/server/index.ts +26 -4
- package/src/server/pi-runner.ts +1 -1
- package/src/server/routes.ts +238 -50
- package/schema/mcp-config.schema.json +0 -54
- package/src/core/config-io.ts +0 -70
- package/src/core/config-writer.ts +0 -407
- package/src/core/effective-view.ts +0 -197
- package/src/core/layers.ts +0 -61
- package/src/core/live-state.ts +0 -134
- package/src/core/path-utils.ts +0 -29
- package/src/core/pi-rules.ts +0 -220
- package/src/core/schema-validation.ts +0 -52
- package/src/core/service.ts +0 -96
- package/src/core/types.ts +0 -200
|
@@ -10,23 +10,34 @@
|
|
|
10
10
|
* own rows (pi skips the whole file).
|
|
11
11
|
*
|
|
12
12
|
* The switch writes `enabled` at the row's scope (pending until the write
|
|
13
|
-
* completes, reverting with an inline error on failure).
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* completes, reverting with an inline error on failure). On a Pi-global row at
|
|
14
|
+
* folder scope it shows the EFFECTIVE state and writes only a project override;
|
|
15
|
+
* an override shows as text badges ("Off in this folder") with Reset to global,
|
|
16
|
+
* and an overflow menu offers "Project settings…" and "Replace with folder
|
|
17
|
+
* entry…". Orphaned / invalid override rows offer only Remove. A folder-scope
|
|
18
|
+
* enable of a whole-entry copy that needs re-entered secrets surfaces the
|
|
19
|
+
* needs-choice result; a legacy copy shows an info strip with Convert.
|
|
16
20
|
*
|
|
17
21
|
* Folder-page rows are keyed `${provenance}:${name}` — two rows can share a
|
|
18
22
|
* name (the folder entry replaces the global one only when pi trusts it).
|
|
19
23
|
*
|
|
20
|
-
* See change: migrate-mcp-to-pi-builtin.
|
|
24
|
+
* See change: migrate-mcp-to-pi-builtin; mcp-client-project-overrides (D9).
|
|
21
25
|
*/
|
|
22
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
SettingsItem,
|
|
28
|
+
SettingsNotice,
|
|
29
|
+
SettingsStatusPill,
|
|
30
|
+
type SettingsStatusTone,
|
|
31
|
+
useT,
|
|
32
|
+
} from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
33
|
+
import { authModeOf, isProjectOverride } from "@blackbelt-technology/pi-dashboard-mcp-core/pi-rules.js";
|
|
34
|
+
import type { EffectiveServerView, LayerStatus, LiveState, Scope } from "@blackbelt-technology/pi-dashboard-mcp-core/types.js";
|
|
23
35
|
import type React from "react";
|
|
24
36
|
import { useEffect, useState } from "react";
|
|
25
|
-
import { authModeOf } from "../core/pi-rules.js";
|
|
26
|
-
import type { EffectiveServerView, LayerStatus, LiveState, Scope } from "../core/types.js";
|
|
27
37
|
import { ApiError, convertServer, scopeToWire, setEnabled } from "./api.js";
|
|
28
|
-
import { provenanceLabel } from "./folder-view.js";
|
|
38
|
+
import { overrideBadges, provenanceLabel } from "./folder-view.js";
|
|
29
39
|
import { invalidateEffective } from "./hooks.js";
|
|
40
|
+
import { BTN, BTN_PRIMARY, LINK } from "./settings-ui.js";
|
|
30
41
|
|
|
31
42
|
const GLOBAL_SCOPE: Scope = { kind: "global" };
|
|
32
43
|
|
|
@@ -56,6 +67,74 @@ function inactiveText(reason: string | undefined): string | null {
|
|
|
56
67
|
}
|
|
57
68
|
}
|
|
58
69
|
|
|
70
|
+
/** Human word + tone for pi's reported connection state; the raw enum is kept only as `data-status`. */
|
|
71
|
+
function livePill(
|
|
72
|
+
liveRow: { state: string; tools: number } | undefined,
|
|
73
|
+
): { tone: SettingsStatusTone; text: string; status?: string } {
|
|
74
|
+
if (!liveRow) return { tone: "neutral", text: "State unknown" };
|
|
75
|
+
const tools = `${liveRow.tools} ${liveRow.tools === 1 ? "tool" : "tools"}`;
|
|
76
|
+
switch (liveRow.state) {
|
|
77
|
+
case "not-checked-by-pi":
|
|
78
|
+
return { tone: "neutral", text: "Not checked by pi", status: liveRow.state };
|
|
79
|
+
case "connected":
|
|
80
|
+
return { tone: "success", text: `Connected · ${tools}`, status: liveRow.state };
|
|
81
|
+
case "needs-auth":
|
|
82
|
+
return { tone: "warning", text: "Sign-in needed", status: liveRow.state };
|
|
83
|
+
case "failed":
|
|
84
|
+
case "error":
|
|
85
|
+
return { tone: "error", text: "Connection failed", status: liveRow.state };
|
|
86
|
+
default: {
|
|
87
|
+
const word = liveRow.state.replace(/[-_]+/g, " ");
|
|
88
|
+
const human = word.charAt(0).toUpperCase() + word.slice(1);
|
|
89
|
+
return { tone: "neutral", text: liveRow.tools > 0 ? `${human} · ${tools}` : human, status: liveRow.state };
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Kit-styled enable switch (no label row): immediate write, `aria-checked` carries the state. */
|
|
95
|
+
function RowSwitch({
|
|
96
|
+
name,
|
|
97
|
+
testId,
|
|
98
|
+
checked,
|
|
99
|
+
pending,
|
|
100
|
+
disabled,
|
|
101
|
+
title,
|
|
102
|
+
onToggle,
|
|
103
|
+
}: {
|
|
104
|
+
name: string;
|
|
105
|
+
testId: string;
|
|
106
|
+
checked: boolean;
|
|
107
|
+
pending: boolean;
|
|
108
|
+
disabled: boolean;
|
|
109
|
+
title?: string;
|
|
110
|
+
onToggle: (next: boolean) => void;
|
|
111
|
+
}): React.ReactElement {
|
|
112
|
+
return (
|
|
113
|
+
<span className="inline-flex min-h-11 min-w-11 flex-none items-center justify-center sm:min-h-0 sm:min-w-0">
|
|
114
|
+
<button
|
|
115
|
+
type="button"
|
|
116
|
+
role="switch"
|
|
117
|
+
aria-checked={checked}
|
|
118
|
+
aria-label={`Enable ${name}`}
|
|
119
|
+
aria-busy={pending}
|
|
120
|
+
disabled={pending || disabled}
|
|
121
|
+
title={title}
|
|
122
|
+
data-testid={testId}
|
|
123
|
+
onClick={() => onToggle(!checked)}
|
|
124
|
+
className={`focus-ring relative h-[22px] w-10 shrink-0 rounded-full border transition-colors disabled:cursor-not-allowed disabled:opacity-60 ${
|
|
125
|
+
checked ? "border-[var(--accent-solid)] bg-[var(--accent-solid)]" : "border-[var(--border-strong)] bg-[var(--bg-tertiary)]"
|
|
126
|
+
}`}
|
|
127
|
+
>
|
|
128
|
+
<span
|
|
129
|
+
className={`absolute left-0.5 top-0.5 h-4 w-4 rounded-full transition-transform ${
|
|
130
|
+
checked ? "translate-x-[18px] bg-white" : "translate-x-0 bg-[var(--text-secondary)]"
|
|
131
|
+
}`}
|
|
132
|
+
/>
|
|
133
|
+
</button>
|
|
134
|
+
</span>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
59
138
|
interface ServerRowProps {
|
|
60
139
|
server: EffectiveServerView;
|
|
61
140
|
/** Write scope for the enable switch (default global). */
|
|
@@ -71,11 +150,27 @@ interface ServerRowProps {
|
|
|
71
150
|
*/
|
|
72
151
|
writeShadowed?: boolean;
|
|
73
152
|
onNeedsChoice?: (row: RowRef, omitted: string[]) => void;
|
|
74
|
-
onOmitted?: (row: RowRef, omitted: string[]) => void;
|
|
75
153
|
/** Folder page: remove the whole folder entry for this server. */
|
|
76
154
|
onRemoveOverride?: (name: string) => void;
|
|
77
155
|
/** Folder page: the chip's inline remove control hides below 640px. */
|
|
78
156
|
chipsRemovable?: boolean;
|
|
157
|
+
/** Folder page: open the "Project settings…" panel for a Pi-global row. */
|
|
158
|
+
onProjectSettings?: (name: string) => void;
|
|
159
|
+
/** Folder page: remove the project override (exact undo is the page's job). */
|
|
160
|
+
onReset?: (name: string) => void;
|
|
161
|
+
/** Folder page: convert a legacy folder copy to a project override. */
|
|
162
|
+
onConvertLegacy?: (name: string) => void;
|
|
163
|
+
/** Folder page: the project is not trusted, so an override applies later. */
|
|
164
|
+
untrusted?: boolean;
|
|
165
|
+
/** Folder page: the raw override of this name that pi will only read once trusted. */
|
|
166
|
+
pendingOverride?: Record<string, unknown>;
|
|
167
|
+
/** Below 640px: badges are display-only, row actions live in the row's sheet. */
|
|
168
|
+
narrow?: boolean;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** An override-shaped folder entry (no command/url/type): never a server of its own. */
|
|
172
|
+
function isOverrideRow(server: EffectiveServerView): boolean {
|
|
173
|
+
return server.provenance === "pi-folder" && isProjectOverride(server.entry);
|
|
79
174
|
}
|
|
80
175
|
|
|
81
176
|
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: one row = write state + pi vocabulary (live, auth, leftovers, inactive reasons)
|
|
@@ -87,11 +182,17 @@ function ServerRow({
|
|
|
87
182
|
onOpen,
|
|
88
183
|
onChanged,
|
|
89
184
|
onNeedsChoice,
|
|
90
|
-
onOmitted,
|
|
91
185
|
onRemoveOverride,
|
|
92
186
|
chipsRemovable = true,
|
|
93
187
|
writeShadowed = false,
|
|
188
|
+
onProjectSettings,
|
|
189
|
+
onReset,
|
|
190
|
+
onConvertLegacy,
|
|
191
|
+
untrusted = false,
|
|
192
|
+
pendingOverride,
|
|
193
|
+
narrow = false,
|
|
94
194
|
}: ServerRowProps): React.ReactElement {
|
|
195
|
+
const t = useT();
|
|
95
196
|
const { name, entry } = server;
|
|
96
197
|
const folder = scope.kind === "project";
|
|
97
198
|
const key = keyOf(server, folder);
|
|
@@ -100,6 +201,8 @@ function ServerRow({
|
|
|
100
201
|
const [optimistic, setOptimistic] = useState<boolean | null>(null);
|
|
101
202
|
const [pending, setPending] = useState(false);
|
|
102
203
|
const [error, setError] = useState<string | null>(null);
|
|
204
|
+
const [menuOpen, setMenuOpen] = useState(false);
|
|
205
|
+
const [savedPending, setSavedPending] = useState(false);
|
|
103
206
|
// A persisted value change (the reload landing) releases the optimistic value.
|
|
104
207
|
// biome-ignore lint/correctness/useExhaustiveDependencies: keyed on the persisted value only
|
|
105
208
|
useEffect(() => setOptimistic(null), [persistedEnabled]);
|
|
@@ -125,8 +228,10 @@ function ServerRow({
|
|
|
125
228
|
onNeedsChoice?.({ key, name, provenance: server.provenance }, result.omitted);
|
|
126
229
|
return;
|
|
127
230
|
}
|
|
128
|
-
if (
|
|
129
|
-
|
|
231
|
+
if (folder && untrusted) {
|
|
232
|
+
// pi does not read the folder file yet: the row keeps showing the global state.
|
|
233
|
+
setOptimistic(null);
|
|
234
|
+
setSavedPending(true);
|
|
130
235
|
}
|
|
131
236
|
invalidateEffective(folder ? scope.cwd : undefined);
|
|
132
237
|
onChanged();
|
|
@@ -152,155 +257,280 @@ function ServerRow({
|
|
|
152
257
|
}
|
|
153
258
|
}
|
|
154
259
|
|
|
155
|
-
const
|
|
260
|
+
const overrideRow = folder && isOverrideRow(server);
|
|
261
|
+
const globalRow = folder && server.provenance === "pi-global";
|
|
262
|
+
const overrideRaw = server.projectOverride?.raw ?? pendingOverride ?? (overrideRow ? entry : undefined);
|
|
263
|
+
const badges = overrideRaw ? overrideBadges(overrideRaw) : [];
|
|
264
|
+
const hasOverride = globalRow && overrideRaw !== undefined;
|
|
265
|
+
const legacyCopy = folder && server.legacyCopy === true;
|
|
266
|
+
const pendingNote = globalRow && untrusted && (pendingOverride !== undefined || savedPending);
|
|
267
|
+
const actionLabel = folder && server.provenance !== "pi-folder" ? "Replace with folder entry…" : "Edit";
|
|
156
268
|
const actionTestId = folder ? `mcp-folder-action-${key}` : `mcp-server-action-${name}`;
|
|
157
269
|
const description = typeof entry.description === "string" ? entry.description : null;
|
|
158
270
|
const inactiveReason = inactiveText(server.inactiveReason);
|
|
159
271
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
<
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
{
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
<
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
: "OAuth"}
|
|
199
|
-
</span>
|
|
200
|
-
)}
|
|
201
|
-
<span className="flex items-center gap-1 flex-wrap">
|
|
202
|
-
<span
|
|
203
|
-
data-testid={`mcp-badge-${key}-${provenanceLabel(server.provenance)}`}
|
|
204
|
-
className="inline-flex items-center gap-0.5 text-[10px] px-1.5 py-0.5 rounded-full border border-[var(--border-secondary)] text-[var(--text-secondary)]"
|
|
205
|
-
>
|
|
206
|
-
{provenanceLabel(server.provenance)}
|
|
207
|
-
</span>
|
|
208
|
-
{server.overridesGlobal && (
|
|
209
|
-
<span
|
|
210
|
-
data-testid={`mcp-badge-${key}-overrides Pi global`}
|
|
211
|
-
className="inline-flex items-center text-[10px] px-1.5 py-0.5 rounded-full border border-[var(--accent-primary,#60a5fa)] text-[var(--accent-primary,#60a5fa)]"
|
|
272
|
+
const menuItemCls = "focus-ring px-2 py-1 min-h-11 sm:min-h-8 text-left text-xs text-[var(--text-primary)] hover:bg-[var(--bg-hover)]";
|
|
273
|
+
const livePillInfo = live !== undefined && !(liveLoading && live === null) ? livePill(liveRow) : null;
|
|
274
|
+
|
|
275
|
+
const pills = (
|
|
276
|
+
<>
|
|
277
|
+
<SettingsStatusPill tone="neutral" icon={null} testId={`mcp-transport-${key}`}>
|
|
278
|
+
{typeof entry.command === "string" ? "command" : "url"}
|
|
279
|
+
</SettingsStatusPill>
|
|
280
|
+
<SettingsStatusPill tone="neutral" icon={null} testId={`mcp-exposure-${key}`}>
|
|
281
|
+
{server.exposure}
|
|
282
|
+
</SettingsStatusPill>
|
|
283
|
+
{authMode && (
|
|
284
|
+
<SettingsStatusPill tone="neutral" icon={null} testId={`mcp-authmode-${key}`}>
|
|
285
|
+
{authMode.kind === "provider" ? `auth: ${authMode.provider}` : authMode.kind === "header" ? "header" : "OAuth"}
|
|
286
|
+
</SettingsStatusPill>
|
|
287
|
+
)}
|
|
288
|
+
<SettingsStatusPill
|
|
289
|
+
tone="neutral"
|
|
290
|
+
icon={null}
|
|
291
|
+
testId={`mcp-badge-${key}-${provenanceLabel(server.provenance)}`}
|
|
292
|
+
>
|
|
293
|
+
{provenanceLabel(server.provenance)}
|
|
294
|
+
</SettingsStatusPill>
|
|
295
|
+
{server.overridesGlobal && (
|
|
296
|
+
<SettingsStatusPill tone="info" icon={null} testId={`mcp-badge-${key}-overrides Pi global`}>
|
|
297
|
+
overrides Pi global
|
|
298
|
+
</SettingsStatusPill>
|
|
299
|
+
)}
|
|
300
|
+
{folder && server.provenance === "pi-folder" && !overrideRow && (
|
|
301
|
+
<SettingsStatusPill tone="info" icon={null} testId={`mcp-folder-override-chip-${key}`}>
|
|
302
|
+
folder entry
|
|
303
|
+
{chipsRemovable && onRemoveOverride && (
|
|
304
|
+
<button
|
|
305
|
+
type="button"
|
|
306
|
+
aria-label={`Remove folder override for ${name}`}
|
|
307
|
+
data-testid={`mcp-folder-chip-remove-${key}`}
|
|
308
|
+
onClick={() => onRemoveOverride(name)}
|
|
309
|
+
className="focus-ring px-1 min-h-11 min-w-11 sm:min-h-0 sm:min-w-0"
|
|
212
310
|
>
|
|
213
|
-
|
|
214
|
-
</
|
|
311
|
+
✕
|
|
312
|
+
</button>
|
|
215
313
|
)}
|
|
216
|
-
|
|
314
|
+
</SettingsStatusPill>
|
|
315
|
+
)}
|
|
316
|
+
{badges.map((b) => (
|
|
317
|
+
<SettingsStatusPill key={b.key} tone="info" icon={null} testId={`mcp-override-badge-${key}-${b.key}`}>
|
|
318
|
+
{b.text}
|
|
319
|
+
</SettingsStatusPill>
|
|
320
|
+
))}
|
|
321
|
+
{hasOverride && !narrow && onReset && (
|
|
322
|
+
<button
|
|
323
|
+
type="button"
|
|
324
|
+
data-testid={`mcp-folder-reset-${key}`}
|
|
325
|
+
disabled={pending || writeShadowed}
|
|
326
|
+
onClick={() => onReset(name)}
|
|
327
|
+
className={LINK}
|
|
328
|
+
>
|
|
329
|
+
Reset to global
|
|
330
|
+
</button>
|
|
331
|
+
)}
|
|
332
|
+
{livePillInfo && (
|
|
333
|
+
<SettingsStatusPill tone={livePillInfo.tone} testId={`mcp-live-${key}`} status={livePillInfo.status}>
|
|
334
|
+
{livePillInfo.text}
|
|
335
|
+
</SettingsStatusPill>
|
|
336
|
+
)}
|
|
337
|
+
{needsAuth && (
|
|
338
|
+
<span data-testid={`mcp-signin-hint-${key}`} className="text-xs text-[var(--text-secondary)]">
|
|
339
|
+
Sign in with <code>/mcp login {name}</code>
|
|
340
|
+
</span>
|
|
341
|
+
)}
|
|
342
|
+
{server.adapterLeftovers.length > 0 && (!folder || server.provenance === "pi-folder") && (
|
|
343
|
+
<span title={`pi ignores: ${server.adapterLeftovers.join(", ")}`}>
|
|
344
|
+
<SettingsStatusPill tone="warning" testId={`mcp-leftovers-${key}`}>
|
|
345
|
+
ignored by pi: {server.adapterLeftovers.join(", ")}
|
|
346
|
+
</SettingsStatusPill>
|
|
347
|
+
</span>
|
|
348
|
+
)}
|
|
349
|
+
</>
|
|
350
|
+
);
|
|
351
|
+
|
|
352
|
+
const actions = (
|
|
353
|
+
<>
|
|
354
|
+
{server.adapterLeftovers.length > 0 && (!folder || server.provenance === "pi-folder") && (
|
|
355
|
+
<button
|
|
356
|
+
type="button"
|
|
357
|
+
aria-label={`Convert ${name} to pi's entry shape`}
|
|
358
|
+
data-testid={`mcp-convert-${key}`}
|
|
359
|
+
disabled={pending}
|
|
360
|
+
onClick={() => void convert()}
|
|
361
|
+
className={BTN}
|
|
362
|
+
>
|
|
363
|
+
Convert
|
|
364
|
+
</button>
|
|
365
|
+
)}
|
|
366
|
+
{overrideRow ? (
|
|
367
|
+
<button type="button" onClick={() => onRemoveOverride?.(name)} data-testid={actionTestId} className={BTN}>
|
|
368
|
+
Remove
|
|
369
|
+
</button>
|
|
370
|
+
) : globalRow || (legacyCopy && narrow) ? (
|
|
371
|
+
<span className="relative">
|
|
372
|
+
<button
|
|
373
|
+
type="button"
|
|
374
|
+
aria-haspopup="menu"
|
|
375
|
+
aria-expanded={menuOpen}
|
|
376
|
+
disabled={writeShadowed}
|
|
377
|
+
title={writeShadowed ? "The folder entry of the same name is the folder-scope write target — edit that row" : undefined}
|
|
378
|
+
onClick={() => setMenuOpen((o) => !o)}
|
|
379
|
+
data-testid={`mcp-folder-menu-${key}`}
|
|
380
|
+
className={BTN}
|
|
381
|
+
>
|
|
382
|
+
⋯ <span className="hidden sm:inline">{t("mcpFolderActions", undefined, "Actions")}</span>
|
|
383
|
+
</button>
|
|
384
|
+
{menuOpen && (
|
|
217
385
|
<span
|
|
218
|
-
|
|
219
|
-
|
|
386
|
+
role="menu"
|
|
387
|
+
data-testid={`mcp-folder-menu-pop-${key}`}
|
|
388
|
+
onKeyDown={(e) => {
|
|
389
|
+
if (e.key === "Escape") setMenuOpen(false);
|
|
390
|
+
}}
|
|
391
|
+
className="absolute right-0 top-full z-10 mt-1 flex min-w-56 flex-col rounded border border-[var(--border-secondary)] bg-[var(--bg-secondary)] p-1 text-left"
|
|
220
392
|
>
|
|
221
|
-
|
|
222
|
-
|
|
393
|
+
{globalRow && (
|
|
394
|
+
<button
|
|
395
|
+
type="button"
|
|
396
|
+
role="menuitem"
|
|
397
|
+
data-testid={`mcp-folder-project-settings-${key}`}
|
|
398
|
+
onClick={() => {
|
|
399
|
+
setMenuOpen(false);
|
|
400
|
+
onProjectSettings?.(name);
|
|
401
|
+
}}
|
|
402
|
+
className={menuItemCls}
|
|
403
|
+
>
|
|
404
|
+
Project settings…
|
|
405
|
+
</button>
|
|
406
|
+
)}
|
|
407
|
+
{globalRow && hasOverride && narrow && onReset && (
|
|
223
408
|
<button
|
|
224
409
|
type="button"
|
|
225
|
-
|
|
226
|
-
data-testid={`mcp-folder-
|
|
227
|
-
onClick={() =>
|
|
228
|
-
|
|
410
|
+
role="menuitem"
|
|
411
|
+
data-testid={`mcp-folder-reset-${key}`}
|
|
412
|
+
onClick={() => {
|
|
413
|
+
setMenuOpen(false);
|
|
414
|
+
onReset(name);
|
|
415
|
+
}}
|
|
416
|
+
className={menuItemCls}
|
|
229
417
|
>
|
|
230
|
-
|
|
418
|
+
Reset to global
|
|
419
|
+
</button>
|
|
420
|
+
)}
|
|
421
|
+
<button
|
|
422
|
+
type="button"
|
|
423
|
+
role="menuitem"
|
|
424
|
+
data-testid={actionTestId}
|
|
425
|
+
onClick={() => {
|
|
426
|
+
setMenuOpen(false);
|
|
427
|
+
onOpen(name, server.provenance);
|
|
428
|
+
}}
|
|
429
|
+
className={menuItemCls}
|
|
430
|
+
>
|
|
431
|
+
{actionLabel}
|
|
432
|
+
</button>
|
|
433
|
+
{legacyCopy && narrow && (
|
|
434
|
+
<button
|
|
435
|
+
type="button"
|
|
436
|
+
role="menuitem"
|
|
437
|
+
data-testid={`mcp-folder-convert-${key}`}
|
|
438
|
+
onClick={() => {
|
|
439
|
+
setMenuOpen(false);
|
|
440
|
+
onConvertLegacy?.(name);
|
|
441
|
+
}}
|
|
442
|
+
className={menuItemCls}
|
|
443
|
+
>
|
|
444
|
+
Convert to project override
|
|
231
445
|
</button>
|
|
232
446
|
)}
|
|
233
447
|
</span>
|
|
234
448
|
)}
|
|
235
449
|
</span>
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
{liveRow ? `${liveRow.state} · ${liveRow.tools} tools` : "state unknown"}
|
|
239
|
-
</span>
|
|
240
|
-
)}
|
|
241
|
-
{needsAuth && (
|
|
242
|
-
<span
|
|
243
|
-
data-testid={`mcp-signin-hint-${key}`}
|
|
244
|
-
className="text-[10px] text-[var(--text-secondary)] flex-none"
|
|
245
|
-
>
|
|
246
|
-
sign in: /mcp login {name}
|
|
247
|
-
</span>
|
|
248
|
-
)}
|
|
249
|
-
{server.adapterLeftovers.length > 0 && (!folder || server.provenance === "pi-folder") && (
|
|
250
|
-
<span className="inline-flex items-center gap-1 flex-none">
|
|
251
|
-
<span
|
|
252
|
-
data-testid={`mcp-leftovers-${key}`}
|
|
253
|
-
className="inline-flex items-center text-[10px] px-1.5 py-0.5 rounded-full border border-amber-500 text-amber-500"
|
|
254
|
-
title={`pi ignores: ${server.adapterLeftovers.join(", ")}`}
|
|
255
|
-
>
|
|
256
|
-
ignored by pi: {server.adapterLeftovers.join(", ")}
|
|
257
|
-
</span>
|
|
258
|
-
<button
|
|
259
|
-
type="button"
|
|
260
|
-
aria-label={`Convert ${name} to pi's entry shape`}
|
|
261
|
-
data-testid={`mcp-convert-${key}`}
|
|
262
|
-
disabled={pending}
|
|
263
|
-
onClick={() => void convert()}
|
|
264
|
-
className="text-[10px] px-1.5 py-0.5 min-h-11 min-w-11 sm:min-h-0 sm:min-w-0 rounded border border-[var(--border-secondary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] disabled:opacity-50"
|
|
265
|
-
>
|
|
266
|
-
Convert
|
|
267
|
-
</button>
|
|
268
|
-
</span>
|
|
269
|
-
)}
|
|
270
|
-
<button
|
|
271
|
-
type="button"
|
|
272
|
-
onClick={() => onOpen(name, server.provenance)}
|
|
273
|
-
disabled={writeShadowed}
|
|
274
|
-
title={writeShadowed ? "The folder entry of the same name is the folder-scope write target — edit that row" : undefined}
|
|
275
|
-
data-testid={actionTestId}
|
|
276
|
-
className="ml-auto text-[11px] px-2 py-1 min-h-11 min-w-11 sm:min-h-0 sm:min-w-0 rounded border border-[var(--border-secondary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] disabled:opacity-50"
|
|
277
|
-
>
|
|
450
|
+
) : (
|
|
451
|
+
<button type="button" onClick={() => onOpen(name, server.provenance)} data-testid={actionTestId} className={BTN}>
|
|
278
452
|
{actionLabel}
|
|
279
453
|
</button>
|
|
280
|
-
</div>
|
|
281
|
-
{server.piError && (
|
|
282
|
-
<p
|
|
283
|
-
data-testid={`mcp-pi-error-${key}`}
|
|
284
|
-
role="alert"
|
|
285
|
-
className="text-[11px] text-[var(--status-error,#f87171)] m-0"
|
|
286
|
-
>
|
|
287
|
-
{server.piError}
|
|
288
|
-
</p>
|
|
289
|
-
)}
|
|
290
|
-
{inactiveReason && (
|
|
291
|
-
<p data-testid={`mcp-inactive-${key}`} className="text-[11px] text-[var(--text-secondary)] m-0">
|
|
292
|
-
{inactiveReason}
|
|
293
|
-
</p>
|
|
294
|
-
)}
|
|
295
|
-
{error && (
|
|
296
|
-
<p
|
|
297
|
-
role="alert"
|
|
298
|
-
data-testid={`mcp-server-error-${key}`}
|
|
299
|
-
className="text-[11px] text-[var(--status-error,#f87171)]"
|
|
300
|
-
>
|
|
301
|
-
{error}
|
|
302
|
-
</p>
|
|
303
454
|
)}
|
|
455
|
+
</>
|
|
456
|
+
);
|
|
457
|
+
|
|
458
|
+
const hasNotes = Boolean(server.piError || pendingNote || legacyCopy || inactiveReason || error);
|
|
459
|
+
|
|
460
|
+
return (
|
|
461
|
+
<li data-testid={folder ? `mcp-folder-row-${key}` : `mcp-server-row-${name}`} className="mb-2">
|
|
462
|
+
<SettingsItem
|
|
463
|
+
title={
|
|
464
|
+
<span className="inline-flex items-center gap-2">
|
|
465
|
+
<RowSwitch
|
|
466
|
+
name={name}
|
|
467
|
+
testId={`mcp-server-toggle-${key}`}
|
|
468
|
+
checked={enabled}
|
|
469
|
+
pending={pending}
|
|
470
|
+
disabled={writeShadowed || overrideRow}
|
|
471
|
+
title={
|
|
472
|
+
overrideRow
|
|
473
|
+
? `No Pi global server named ${name} to override`
|
|
474
|
+
: writeShadowed
|
|
475
|
+
? "The folder entry of the same name is the folder-scope write target"
|
|
476
|
+
: undefined
|
|
477
|
+
}
|
|
478
|
+
onToggle={(next) => void toggle(next)}
|
|
479
|
+
/>
|
|
480
|
+
{name}
|
|
481
|
+
</span>
|
|
482
|
+
}
|
|
483
|
+
subtitle={description ? <span data-testid={`mcp-server-description-${key}`}>{description}</span> : undefined}
|
|
484
|
+
status={pills}
|
|
485
|
+
actions={actions}
|
|
486
|
+
>
|
|
487
|
+
{hasNotes ? (
|
|
488
|
+
<div className="space-y-2">
|
|
489
|
+
{server.piError && (
|
|
490
|
+
<SettingsNotice tone="error" testId={`mcp-pi-error-${key}`}>
|
|
491
|
+
{server.piError}
|
|
492
|
+
</SettingsNotice>
|
|
493
|
+
)}
|
|
494
|
+
{pendingNote && (
|
|
495
|
+
<SettingsNotice tone="info" role="status" testId={`mcp-folder-pending-${key}`}>
|
|
496
|
+
Saved — applies once the project is trusted. pi still runs <code>{name}</code> from Pi global here.
|
|
497
|
+
</SettingsNotice>
|
|
498
|
+
)}
|
|
499
|
+
{legacyCopy && (
|
|
500
|
+
<SettingsNotice
|
|
501
|
+
tone="info"
|
|
502
|
+
testId={`mcp-legacy-strip-${key}`}
|
|
503
|
+
actions={
|
|
504
|
+
!narrow ? (
|
|
505
|
+
<button
|
|
506
|
+
type="button"
|
|
507
|
+
data-testid={`mcp-folder-convert-${key}`}
|
|
508
|
+
disabled={pending}
|
|
509
|
+
onClick={() => onConvertLegacy?.(name)}
|
|
510
|
+
className={BTN}
|
|
511
|
+
>
|
|
512
|
+
Convert to project override
|
|
513
|
+
</button>
|
|
514
|
+
) : undefined
|
|
515
|
+
}
|
|
516
|
+
>
|
|
517
|
+
<b>{t("mcpLegacyTitle", undefined, "Copied from Pi global by an older dashboard, without credentials.")}</b>{" "}
|
|
518
|
+
{t("mcpLegacyBody", undefined, "A project override keeps the global credentials and only changes on/off here.")}
|
|
519
|
+
</SettingsNotice>
|
|
520
|
+
)}
|
|
521
|
+
{inactiveReason && (
|
|
522
|
+
<p data-testid={`mcp-inactive-${key}`} className="m-0 text-xs text-[var(--text-secondary)]">
|
|
523
|
+
{inactiveReason}
|
|
524
|
+
</p>
|
|
525
|
+
)}
|
|
526
|
+
{error && (
|
|
527
|
+
<SettingsNotice tone="error" testId={`mcp-server-error-${key}`}>
|
|
528
|
+
{error}
|
|
529
|
+
</SettingsNotice>
|
|
530
|
+
)}
|
|
531
|
+
</div>
|
|
532
|
+
) : null}
|
|
533
|
+
</SettingsItem>
|
|
304
534
|
</li>
|
|
305
535
|
);
|
|
306
536
|
}
|
|
@@ -311,7 +541,7 @@ function SkeletonRows(): React.ReactElement {
|
|
|
311
541
|
{[0, 1, 2].map((i) => (
|
|
312
542
|
<div
|
|
313
543
|
key={i}
|
|
314
|
-
className="h-5 rounded bg-[var(--bg-tertiary
|
|
544
|
+
className="h-5 rounded bg-[var(--bg-tertiary)] animate-pulse"
|
|
315
545
|
style={{ width: `${100 - i * 15}%` }}
|
|
316
546
|
/>
|
|
317
547
|
))}
|
|
@@ -335,12 +565,16 @@ export interface ServerListProps {
|
|
|
335
565
|
onChanged: () => void;
|
|
336
566
|
/** Folder page: a folder enable that needs re-entered secrets. */
|
|
337
567
|
onNeedsChoice?: (row: RowRef, omitted: string[]) => void;
|
|
338
|
-
/** Folder page:
|
|
339
|
-
onOmitted?: (row: RowRef, omitted: string[]) => void;
|
|
340
|
-
/** Folder page: remove the whole folder entry for this server. */
|
|
568
|
+
/** Folder page: remove the whole folder entry (or override) for this server. */
|
|
341
569
|
onRemoveOverride?: (name: string) => void;
|
|
342
570
|
/** Folder page: the chip's inline remove control hides below 640px. */
|
|
343
571
|
chipsRemovable?: boolean;
|
|
572
|
+
onProjectSettings?: (name: string) => void;
|
|
573
|
+
onReset?: (name: string) => void;
|
|
574
|
+
onConvertLegacy?: (name: string) => void;
|
|
575
|
+
/** Folder page: pi does not trust the project (an override applies once it does). */
|
|
576
|
+
untrusted?: boolean;
|
|
577
|
+
narrow?: boolean;
|
|
344
578
|
}
|
|
345
579
|
|
|
346
580
|
export function ServerList({
|
|
@@ -354,9 +588,13 @@ export function ServerList({
|
|
|
354
588
|
onAdd,
|
|
355
589
|
onChanged,
|
|
356
590
|
onNeedsChoice,
|
|
357
|
-
onOmitted,
|
|
358
591
|
onRemoveOverride,
|
|
359
592
|
chipsRemovable,
|
|
593
|
+
onProjectSettings,
|
|
594
|
+
onReset,
|
|
595
|
+
onConvertLegacy,
|
|
596
|
+
untrusted,
|
|
597
|
+
narrow,
|
|
360
598
|
}: ServerListProps): React.ReactElement {
|
|
361
599
|
const t = useT();
|
|
362
600
|
if (loading && servers.length === 0 && layers.every((l) => l.ok)) return <SkeletonRows />;
|
|
@@ -364,23 +602,32 @@ export function ServerList({
|
|
|
364
602
|
const sorted = [...servers].sort(
|
|
365
603
|
(a, b) => (a.name === b.name ? a.provenance.localeCompare(b.provenance) : a.name.localeCompare(b.name)),
|
|
366
604
|
);
|
|
367
|
-
|
|
605
|
+
// Whole-entry folder entries shadow the global row; an override-shaped entry never does.
|
|
606
|
+
const folderNames = new Set(
|
|
607
|
+
sorted.filter((s) => s.provenance === "pi-folder" && !isOverrideRow(s)).map((s) => s.name),
|
|
608
|
+
);
|
|
609
|
+
// Untrusted: pi has not read the override yet, so the GLOBAL row carries it (badge, Reset, note).
|
|
610
|
+
const globalNames = new Set(sorted.filter((s) => s.provenance === "pi-global").map((s) => s.name));
|
|
611
|
+
const pendingOverrides = new Map<string, Record<string, unknown>>();
|
|
612
|
+
if (untrusted) {
|
|
613
|
+
for (const s of sorted) {
|
|
614
|
+
if (isOverrideRow(s) && globalNames.has(s.name)) pendingOverrides.set(s.name, s.entry);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
const visible = sorted.filter((s) => !(isOverrideRow(s) && pendingOverrides.has(s.name)));
|
|
368
618
|
const brokenLayers = layers.filter((l) => !l.ok);
|
|
369
619
|
const empty = sorted.length === 0 && brokenLayers.length === 0;
|
|
370
620
|
|
|
371
621
|
return (
|
|
372
622
|
<ul data-testid="mcp-server-list" className="list-none m-0 p-0">
|
|
373
623
|
{brokenLayers.map((l) => (
|
|
374
|
-
<li
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
className="text-[11px] py-1.5 border-b border-[var(--border-secondary)] text-[var(--status-error,#f87171)]"
|
|
379
|
-
>
|
|
380
|
-
<code>{l.path}</code>: {l.message} — pi skips this file.
|
|
624
|
+
<li key={l.path} className="mb-2">
|
|
625
|
+
<SettingsNotice tone="warning" role="alert" testId="mcp-layer-error">
|
|
626
|
+
<code>{l.path}</code>: {l.message} — pi skips this file.
|
|
627
|
+
</SettingsNotice>
|
|
381
628
|
</li>
|
|
382
629
|
))}
|
|
383
|
-
{
|
|
630
|
+
{visible.map((s) => (
|
|
384
631
|
<ServerRow
|
|
385
632
|
key={`${s.provenance}:${s.name}`}
|
|
386
633
|
server={s}
|
|
@@ -390,34 +637,48 @@ export function ServerList({
|
|
|
390
637
|
onOpen={onOpen}
|
|
391
638
|
onChanged={onChanged}
|
|
392
639
|
onNeedsChoice={onNeedsChoice}
|
|
393
|
-
onOmitted={onOmitted}
|
|
394
640
|
onRemoveOverride={onRemoveOverride}
|
|
395
641
|
chipsRemovable={chipsRemovable}
|
|
642
|
+
onProjectSettings={onProjectSettings}
|
|
643
|
+
onReset={onReset}
|
|
644
|
+
onConvertLegacy={onConvertLegacy}
|
|
645
|
+
untrusted={untrusted}
|
|
646
|
+
narrow={narrow}
|
|
647
|
+
{...(pendingOverrides.has(s.name) && s.provenance === "pi-global"
|
|
648
|
+
? { pendingOverride: pendingOverrides.get(s.name) as Record<string, unknown> }
|
|
649
|
+
: {})}
|
|
396
650
|
writeShadowed={scope?.kind === "project" && s.provenance === "pi-global" && folderNames.has(s.name)}
|
|
397
651
|
/>
|
|
398
652
|
))}
|
|
399
653
|
{empty && (
|
|
400
|
-
<li
|
|
401
|
-
|
|
402
|
-
|
|
654
|
+
<li
|
|
655
|
+
data-testid="mcp-empty"
|
|
656
|
+
className="flex flex-col items-center gap-2 rounded-lg border border-dashed border-[var(--border-secondary)] px-4 py-6 text-center"
|
|
657
|
+
>
|
|
658
|
+
<p className="m-0 text-sm font-semibold text-[var(--text-primary)]">
|
|
659
|
+
{t("mcpEmptyState", undefined, "No MCP servers yet")}
|
|
403
660
|
</p>
|
|
404
|
-
|
|
405
|
-
<
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
661
|
+
{scope?.kind !== "project" && (
|
|
662
|
+
<p className="m-0 text-xs text-[var(--text-secondary)]">
|
|
663
|
+
{t(
|
|
664
|
+
"mcpEmptyHelp",
|
|
665
|
+
undefined,
|
|
666
|
+
"Add a server to give sessions its tools. Servers are shared by every pi session on this computer.",
|
|
667
|
+
)}
|
|
668
|
+
</p>
|
|
669
|
+
)}
|
|
670
|
+
<div className="flex flex-wrap items-center justify-center gap-3">
|
|
671
|
+
<button type="button" onClick={onAdd} data-testid="mcp-empty-add" className={BTN_PRIMARY}>
|
|
672
|
+
{t("mcpAddServer", undefined, "Add server")}
|
|
412
673
|
</button>
|
|
413
674
|
<a
|
|
414
675
|
href="https://github.com/earendil-works/pi/blob/main/docs/mcp.md"
|
|
415
676
|
target="_blank"
|
|
416
677
|
rel="noreferrer"
|
|
417
678
|
data-testid="mcp-docs-link"
|
|
418
|
-
className=
|
|
679
|
+
className={LINK}
|
|
419
680
|
>
|
|
420
|
-
MCP configuration
|
|
681
|
+
{t("mcpDocsLink", undefined, "How MCP configuration works")}
|
|
421
682
|
</a>
|
|
422
683
|
</div>
|
|
423
684
|
</li>
|