@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
package/src/client/api.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* Wire shapes mirror the route handlers in `../server/routes.ts`.
|
|
9
9
|
* See change: migrate-mcp-to-pi-builtin.
|
|
10
10
|
*/
|
|
11
|
-
import type { EffectiveView, LiveState, Scope, SetEnabledResult } from "
|
|
11
|
+
import type { EffectiveView, LiveState, ProjectOverridePatch, Scope, SetEnabledResult } from "@blackbelt-technology/pi-dashboard-mcp-core/types.js";
|
|
12
12
|
|
|
13
13
|
const API_BASE = "/api/mcp-client";
|
|
14
14
|
|
|
@@ -18,22 +18,42 @@ export interface ScopeWire {
|
|
|
18
18
|
cwd?: string;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Wire form of a scope. Picks fields explicitly so a server-side `admission`
|
|
23
|
+
* token (request-scoped, never on the wire) can never be serialized, even if a
|
|
24
|
+
* caller hands in a scope that carries one. See change: harden-plugin-cwd-admission.
|
|
25
|
+
*/
|
|
21
26
|
export function scopeToWire(scope: Scope): ScopeWire {
|
|
22
27
|
return scope.kind === "global" ? { scope: "global" } : { scope: "project", cwd: scope.cwd };
|
|
23
28
|
}
|
|
24
29
|
|
|
30
|
+
/** The 503 code the server answers when it could not DECIDE cwd admission. */
|
|
31
|
+
const ADMISSION_UNAVAILABLE_CODE = "cwd-admission-unavailable";
|
|
32
|
+
|
|
25
33
|
/** A refusal from any route, carrying the closed `error` code + optional fields. */
|
|
26
34
|
export class ApiError extends Error {
|
|
27
35
|
readonly status: number;
|
|
28
36
|
readonly code: string;
|
|
29
37
|
readonly fields: string[];
|
|
38
|
+
/** Server-suggested base retry delay for a transient refusal (ms). */
|
|
39
|
+
readonly retryAfterMs: number | undefined;
|
|
30
40
|
|
|
31
|
-
constructor(status: number, code: string, message: string, fields?: string[]) {
|
|
41
|
+
constructor(status: number, code: string, message: string, fields?: string[], retryAfterMs?: number) {
|
|
32
42
|
super(message);
|
|
33
43
|
this.name = "ApiError";
|
|
34
44
|
this.status = status;
|
|
35
45
|
this.code = code;
|
|
36
46
|
this.fields = fields ?? [];
|
|
47
|
+
this.retryAfterMs = retryAfterMs;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The server could not decide cwd admission right now (503
|
|
52
|
+
* `cwd-admission-unavailable`). Transient: retry with backoff, and never read
|
|
53
|
+
* it as "not tracked". A genuine 403 stays {@link isNotAllowed}.
|
|
54
|
+
*/
|
|
55
|
+
get isTransient(): boolean {
|
|
56
|
+
return this.status === 503 && this.code === ADMISSION_UNAVAILABLE_CODE;
|
|
37
57
|
}
|
|
38
58
|
|
|
39
59
|
/** A cwd outside the dashboard's known-folder set (403 `not-allowed`). */
|
|
@@ -46,6 +66,7 @@ interface ErrorBody {
|
|
|
46
66
|
error?: unknown;
|
|
47
67
|
message?: unknown;
|
|
48
68
|
fields?: unknown;
|
|
69
|
+
retryAfterMs?: unknown;
|
|
49
70
|
}
|
|
50
71
|
|
|
51
72
|
async function failure(res: Response): Promise<ApiError> {
|
|
@@ -60,6 +81,7 @@ async function failure(res: Response): Promise<ApiError> {
|
|
|
60
81
|
typeof body.error === "string" ? body.error : `http-${res.status}`,
|
|
61
82
|
typeof body.message === "string" ? body.message : `request failed (${res.status})`,
|
|
62
83
|
Array.isArray(body.fields) ? body.fields.filter((f): f is string => typeof f === "string") : [],
|
|
84
|
+
typeof body.retryAfterMs === "number" && body.retryAfterMs > 0 ? body.retryAfterMs : undefined,
|
|
63
85
|
);
|
|
64
86
|
}
|
|
65
87
|
|
|
@@ -147,3 +169,31 @@ export async function convertServer(name: string, wire: ScopeWire): Promise<void
|
|
|
147
169
|
);
|
|
148
170
|
}
|
|
149
171
|
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* `PUT /servers/:name/project-override` — patch the project override of a global
|
|
175
|
+
* server (project scope only). Absent key = unchanged, `null` = delete the key.
|
|
176
|
+
* Resolves with the written override, or `removed: true` when none is left.
|
|
177
|
+
*/
|
|
178
|
+
export async function setProjectOverride(
|
|
179
|
+
name: string,
|
|
180
|
+
patch: ProjectOverridePatch,
|
|
181
|
+
wire: ScopeWire,
|
|
182
|
+
): Promise<{ ok: true; override?: Record<string, unknown>; removed?: true }> {
|
|
183
|
+
return readJson(
|
|
184
|
+
await fetch(
|
|
185
|
+
`${API_BASE}/servers/${encodeURIComponent(name)}/project-override`,
|
|
186
|
+
methodWith("PUT", { ...wire, ...patch }),
|
|
187
|
+
),
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** `POST /servers/:name/convert-to-override` — legacy folder copy → override; returns the previous raw entry. */
|
|
192
|
+
export async function convertToOverride(
|
|
193
|
+
name: string,
|
|
194
|
+
wire: ScopeWire,
|
|
195
|
+
): Promise<{ ok: true; previous: Record<string, unknown> }> {
|
|
196
|
+
return readJson(
|
|
197
|
+
await fetch(`${API_BASE}/servers/${encodeURIComponent(name)}/convert-to-override`, methodWith("POST", wire)),
|
|
198
|
+
);
|
|
199
|
+
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* mcp-client-plugin · folder-scope view helpers.
|
|
3
3
|
*
|
|
4
|
-
* The folder
|
|
5
|
-
*
|
|
6
|
-
* fields (`headers`, `env`,
|
|
7
|
-
*
|
|
8
|
-
* never sent back either).
|
|
4
|
+
* The "Replace with folder entry…" pre-fill: a project entry with a transport
|
|
5
|
+
* replaces a global entry WHOLE, so the editor starts from the complete global
|
|
6
|
+
* entry EXCEPT the secret-bearing fields (`headers`, `env`,
|
|
7
|
+
* `oauth.clientSecret`) and `auth` — those are left out and flagged, never
|
|
8
|
+
* copied silently (the server's redaction markers are never sent back either).
|
|
9
|
+
* Also the project-override presentation helpers (badge text, undo patch).
|
|
9
10
|
*
|
|
10
|
-
* See change: migrate-mcp-to-pi-builtin.
|
|
11
|
+
* See change: migrate-mcp-to-pi-builtin; mcp-client-project-overrides.
|
|
11
12
|
*/
|
|
12
|
-
import
|
|
13
|
+
import { displayExposure, OVERRIDE_KEYS } from "@blackbelt-technology/pi-dashboard-mcp-core/pi-rules.js";
|
|
14
|
+
import type { ProjectOverridePatch, Provenance } from "@blackbelt-technology/pi-dashboard-mcp-core/types.js";
|
|
13
15
|
import { stripRedacted } from "./schema.js";
|
|
14
16
|
|
|
15
17
|
/**
|
|
@@ -45,7 +47,7 @@ function deletePath(draft: Record<string, unknown>, path: string[]): void {
|
|
|
45
47
|
delete parent[path[path.length - 1] as string];
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
/** A copy of a global entry for a folder
|
|
50
|
+
/** A copy of a global entry for a whole-entry folder replace, without secrets or `auth`. */
|
|
49
51
|
export function folderOverrideDraftOf(entry: Record<string, unknown>): FolderOverridePrefill {
|
|
50
52
|
// Flag against the RAW entry (the server's redaction sentinels mark the
|
|
51
53
|
// secret fields), then strip the markers and the flagged paths.
|
|
@@ -65,3 +67,23 @@ export function provenanceLabel(provenance: Provenance): string {
|
|
|
65
67
|
export function isFolderOwned(provenance: Provenance): boolean {
|
|
66
68
|
return provenance === "pi-folder";
|
|
67
69
|
}
|
|
70
|
+
|
|
71
|
+
/** One text badge per overridden key ("Off in this folder", …) — text, never colour alone. */
|
|
72
|
+
export function overrideBadges(raw: Record<string, unknown>): Array<{ key: string; text: string }> {
|
|
73
|
+
const out: Array<{ key: string; text: string }> = [];
|
|
74
|
+
if (typeof raw.enabled === "boolean") {
|
|
75
|
+
out.push({ key: "enabled", text: raw.enabled ? "On in this folder" : "Off in this folder" });
|
|
76
|
+
}
|
|
77
|
+
if (raw.exposure !== undefined) {
|
|
78
|
+
out.push({ key: "exposure", text: `Exposure: ${displayExposure(raw.exposure)} in this folder` });
|
|
79
|
+
}
|
|
80
|
+
if (raw.toolExposure !== undefined) out.push({ key: "toolExposure", text: "Tool exposure set in this folder" });
|
|
81
|
+
return out;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** The patch that restores a removed override exactly: its raw keys, absent keys as `null`. */
|
|
85
|
+
export function overrideRestorePatch(removed: Record<string, unknown>): ProjectOverridePatch {
|
|
86
|
+
const patch: Record<string, unknown> = {};
|
|
87
|
+
for (const k of OVERRIDE_KEYS) patch[k] = removed[k] ?? null;
|
|
88
|
+
return patch as ProjectOverridePatch;
|
|
89
|
+
}
|
package/src/client/hooks.ts
CHANGED
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
*
|
|
12
12
|
* See change: migrate-mcp-to-pi-builtin.
|
|
13
13
|
*/
|
|
14
|
+
|
|
15
|
+
import type { EffectiveView, LiveState } from "@blackbelt-technology/pi-dashboard-mcp-core/types.js";
|
|
14
16
|
import { useCallback, useEffect, useState } from "react";
|
|
15
|
-
import type { EffectiveView, LiveState } from "../core/types.js";
|
|
16
17
|
import { ApiError, fetchEffective, fetchLive } from "./api.js";
|
|
17
18
|
|
|
18
19
|
// ─── effective config store ──────────────────────────────────────────────────
|
|
@@ -34,6 +35,35 @@ function keyOf(cwd?: string): string {
|
|
|
34
35
|
return cwd ?? "";
|
|
35
36
|
}
|
|
36
37
|
|
|
38
|
+
/** Retries after the first attempt when the server could not decide admission. */
|
|
39
|
+
const TRANSIENT_MAX_RETRIES = 3;
|
|
40
|
+
/** Base delay when the 503 carries no `retryAfterMs`. */
|
|
41
|
+
const TRANSIENT_BASE_MS = 1000;
|
|
42
|
+
|
|
43
|
+
/** Jittered exponential backoff: `base × 2^n × (0.75 + random × 0.5)` (~1 s, 2 s, 4 s ±25 %). */
|
|
44
|
+
function transientDelayMs(err: ApiError, attempt: number): number {
|
|
45
|
+
return (err.retryAfterMs ?? TRANSIENT_BASE_MS) * 2 ** attempt * (0.75 + Math.random() * 0.5);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* `fetchEffective` with the transient-503 retry chain. ONE chain per key: it
|
|
50
|
+
* lives inside the key's single in-flight promise, so N pills on one cwd make
|
|
51
|
+
* one chain. A transient error is retried while `isCurrent()` (a superseding
|
|
52
|
+
* `invalidate` / forced reload ends the chain); only after exhaustion is it
|
|
53
|
+
* surfaced, and it is NEVER recorded as "not tracked".
|
|
54
|
+
*/
|
|
55
|
+
async function fetchEffectiveWithRetry(cwd: string | undefined, isCurrent: () => boolean): Promise<EffectiveView> {
|
|
56
|
+
for (let attempt = 0; ; attempt++) {
|
|
57
|
+
try {
|
|
58
|
+
return await fetchEffective(cwd);
|
|
59
|
+
} catch (err) {
|
|
60
|
+
if (!(err instanceof ApiError && err.isTransient) || attempt >= TRANSIENT_MAX_RETRIES || !isCurrent()) throw err;
|
|
61
|
+
await new Promise<void>((resolve) => setTimeout(resolve, transientDelayMs(err, attempt)));
|
|
62
|
+
if (!isCurrent()) throw err;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
37
67
|
/** Test-only: drop every cached 403 so each test starts from a clean slate. */
|
|
38
68
|
export function __resetNotTrackedCache(): void {
|
|
39
69
|
notTracked.clear();
|
|
@@ -56,7 +86,7 @@ export function loadEffective(
|
|
|
56
86
|
const hit = cache.get(key);
|
|
57
87
|
if (hit) return Promise.resolve(hit);
|
|
58
88
|
}
|
|
59
|
-
const request =
|
|
89
|
+
const request: Promise<EffectiveView> = fetchEffectiveWithRetry(cwd, () => inflight.get(key) === request).then(
|
|
60
90
|
(view) => {
|
|
61
91
|
// A superseded request (invalidated, or replaced by a forced reload) must
|
|
62
92
|
// not repopulate the cache with a now-stale body.
|
|
@@ -68,9 +98,14 @@ export function loadEffective(
|
|
|
68
98
|
return view;
|
|
69
99
|
},
|
|
70
100
|
(err: unknown) => {
|
|
71
|
-
|
|
72
|
-
//
|
|
73
|
-
|
|
101
|
+
// A SUPERSEDED request (invalidated by a pin-list change, or replaced by a forced
|
|
102
|
+
// reload) must not write state either way: its late 403 would otherwise shadow the
|
|
103
|
+
// newer request's success, because `notTracked` is consulted before the view cache.
|
|
104
|
+
if (inflight.get(key) === request) {
|
|
105
|
+
inflight.delete(key);
|
|
106
|
+
// Remember a cwd refusal so a remount / sibling pill does not re-ask.
|
|
107
|
+
if (err instanceof ApiError && err.isNotAllowed) notTracked.set(key, err);
|
|
108
|
+
}
|
|
74
109
|
throw err;
|
|
75
110
|
},
|
|
76
111
|
);
|
package/src/client/index.tsx
CHANGED
package/src/client/schema.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*
|
|
15
15
|
* See change: migrate-mcp-to-pi-builtin.
|
|
16
16
|
*/
|
|
17
|
-
import { displayExposure, MCP_EXPOSURE_ALIASES } from "
|
|
17
|
+
import { displayExposure, MCP_EXPOSURE_ALIASES } from "@blackbelt-technology/pi-dashboard-mcp-core/pi-rules.js";
|
|
18
18
|
|
|
19
19
|
export type Transport = "command" | "url";
|
|
20
20
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mcp-client · settings-body class recipes (token-only, ≥ 12 px).
|
|
3
|
+
*
|
|
4
|
+
* Buttons / link follow the `ui-contract.md` recipes; status pills, notices and
|
|
5
|
+
* the item card come from the runtime settings kit. Kept in one place so the
|
|
6
|
+
* list toolbar, rows and empty state share one set of recipes.
|
|
7
|
+
* See change: retro-ux-plugin-settings-wave-2.
|
|
8
|
+
*/
|
|
9
|
+
const BTN_BASE =
|
|
10
|
+
"focus-ring inline-flex items-center justify-center gap-1 rounded-md px-3 min-h-[44px] sm:min-h-[32px] text-xs font-semibold disabled:cursor-not-allowed";
|
|
11
|
+
/** Secondary button. */
|
|
12
|
+
export const BTN =
|
|
13
|
+
`${BTN_BASE} border border-[var(--border-secondary)] bg-[var(--bg-tertiary)] text-[var(--text-primary)] hover:bg-[var(--bg-hover)] disabled:opacity-60`;
|
|
14
|
+
/** Primary button — exactly one per state. */
|
|
15
|
+
export const BTN_PRIMARY =
|
|
16
|
+
`${BTN_BASE} bg-[var(--accent-solid)] text-white hover:brightness-110 disabled:bg-[var(--bg-tertiary)] disabled:text-[var(--text-secondary)]`;
|
|
17
|
+
/** Inline text-button / link recipe (`--link`). */
|
|
18
|
+
export const LINK =
|
|
19
|
+
"focus-ring inline-flex min-h-[32px] items-center gap-1 rounded text-xs font-semibold text-[var(--link)] hover:text-[var(--link-hover)] hover:underline disabled:opacity-60";
|
package/src/core/index.ts
CHANGED
|
@@ -1,69 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* mcp-client-plugin ·
|
|
3
|
-
* MCP config.
|
|
2
|
+
* mcp-client-plugin · `./core` — DEPRECATED compatibility re-export.
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* The host-free MCP config logic moved to the non-plugin library
|
|
5
|
+
* `@blackbelt-technology/pi-dashboard-mcp-core`; import it from there. This
|
|
6
|
+
* entry is kept for one minor release, then removed.
|
|
7
|
+
* See change: decouple-plugins-from-core (task 2.2).
|
|
8
|
+
*
|
|
9
|
+
* @deprecated import from `@blackbelt-technology/pi-dashboard-mcp-core`.
|
|
8
10
|
*/
|
|
9
|
-
|
|
10
|
-
export { createRealConfigIO, writeFileAtomic } from "./config-io.js";
|
|
11
|
-
export {
|
|
12
|
-
type ConfigWriter,
|
|
13
|
-
type ConfigWriterDeps,
|
|
14
|
-
createConfigWriter,
|
|
15
|
-
FOLDER_COPY_OMITTED,
|
|
16
|
-
folderCopyOf,
|
|
17
|
-
NotAllowedCwdError,
|
|
18
|
-
} from "./config-writer.js";
|
|
19
|
-
export {
|
|
20
|
-
createEffectiveViewReader,
|
|
21
|
-
type EffectiveViewReader,
|
|
22
|
-
isSecretKey,
|
|
23
|
-
redactEntry,
|
|
24
|
-
} from "./effective-view.js";
|
|
25
|
-
export { defaultLayerPaths, type LayerPaths, piAgentDir, readLayer } from "./layers.js";
|
|
26
|
-
export {
|
|
27
|
-
createLiveStateReader,
|
|
28
|
-
LIVE_STATE_CACHE_TTL_MS,
|
|
29
|
-
LIVE_STATE_TIMEOUT_MS,
|
|
30
|
-
type LiveStateReader,
|
|
31
|
-
parseMcpListJson,
|
|
32
|
-
} from "./live-state.js";
|
|
33
|
-
export {
|
|
34
|
-
ADAPTER_ONLY_KEYS,
|
|
35
|
-
adapterLeftovers,
|
|
36
|
-
authModeOf,
|
|
37
|
-
displayExposure,
|
|
38
|
-
ignoredKeys,
|
|
39
|
-
isValidServerName,
|
|
40
|
-
MCP_EXPOSURE_ALIASES,
|
|
41
|
-
MCP_EXPOSURES,
|
|
42
|
-
type McpExposure,
|
|
43
|
-
mcpNamespace,
|
|
44
|
-
transportOf,
|
|
45
|
-
validatePiEntry,
|
|
46
|
-
} from "./pi-rules.js";
|
|
47
|
-
export { errorFields, mcpConfigSchema, type PatchValidation, validateServerEntry } from "./schema-validation.js";
|
|
48
|
-
export { createMcpClientConfigService, type McpClientConfigServiceDeps, type McpClientRuntime } from "./service.js";
|
|
49
|
-
export type {
|
|
50
|
-
AuthMode,
|
|
51
|
-
ConfigIO,
|
|
52
|
-
ConfigRefusal,
|
|
53
|
-
ConfigRefusalCode,
|
|
54
|
-
ConfigWriteResult,
|
|
55
|
-
EffectiveServerView,
|
|
56
|
-
EffectiveView,
|
|
57
|
-
InactiveReason,
|
|
58
|
-
LayerStatus,
|
|
59
|
-
LiveServerState,
|
|
60
|
-
LiveState,
|
|
61
|
-
McpClientConfigService,
|
|
62
|
-
ParseStatus,
|
|
63
|
-
PiMcpListRunner,
|
|
64
|
-
Provenance,
|
|
65
|
-
RemoveResult,
|
|
66
|
-
Scope,
|
|
67
|
-
ServerEntry,
|
|
68
|
-
SetEnabledResult,
|
|
69
|
-
} from "./types.js";
|
|
11
|
+
export * from "@blackbelt-technology/pi-dashboard-mcp-core";
|
package/src/server/index.ts
CHANGED
|
@@ -11,14 +11,19 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import type { ServerPluginContext } from "@blackbelt-technology/dashboard-plugin-runtime/server";
|
|
14
|
-
import { createRealConfigIO } from "
|
|
15
|
-
import { createMcpClientConfigService } from "
|
|
14
|
+
import { createRealConfigIO } from "@blackbelt-technology/pi-dashboard-mcp-core/config-io.js";
|
|
15
|
+
import { createMcpClientConfigService } from "@blackbelt-technology/pi-dashboard-mcp-core/service.js";
|
|
16
|
+
import { MCP_CLIENT_CONFIG_SERVICE_KEY, type ProjectTrustSource } from "@blackbelt-technology/pi-dashboard-mcp-core/types.js";
|
|
17
|
+
import type { IndeterminateInfo } from "@blackbelt-technology/pi-dashboard-shared/cwd-guard.js";
|
|
16
18
|
import { createPiMcpListRunner } from "./pi-runner.js";
|
|
17
19
|
import { mountMcpClientRoutes } from "./routes.js";
|
|
18
20
|
|
|
19
|
-
const SERVICE_KEY =
|
|
21
|
+
const SERVICE_KEY = MCP_CLIENT_CONFIG_SERVICE_KEY;
|
|
20
22
|
const HOST_KNOWN_FOLDERS = "host.knownFolderCwds";
|
|
21
23
|
const HOST_PROJECT_TRUST = "host.isProjectTrusted";
|
|
24
|
+
const HOST_PROJECT_TRUST_SOURCE = "host.projectTrustSource";
|
|
25
|
+
const HOST_COVER_INTERACTIVE = "host.piTrustCoverInteractive";
|
|
26
|
+
const HOST_CWD_ADMISSION_LOG = "host.cwdAdmissionOnIndeterminate";
|
|
22
27
|
|
|
23
28
|
async function registerPlugin(ctx: ServerPluginContext): Promise<void> {
|
|
24
29
|
ctx.logger.info("mcp-client server entry activated");
|
|
@@ -28,10 +33,16 @@ async function registerPlugin(ctx: ServerPluginContext): Promise<void> {
|
|
|
28
33
|
if (!hostTrust) {
|
|
29
34
|
ctx.logger.warn(`mcp-client: host service '${HOST_PROJECT_TRUST}' is unavailable — every project's .pi/mcp.json is shown as untrusted`);
|
|
30
35
|
}
|
|
36
|
+
// Optional additive disclosure: who decided the trust, and whether dashboard
|
|
37
|
+
// trust also covers interactive pi. See change: mirror-dashboard-trust-to-pi.
|
|
38
|
+
const trustSource = ctx.consume<(cwd: string) => ProjectTrustSource | undefined>(HOST_PROJECT_TRUST_SOURCE);
|
|
39
|
+
const coverInteractive = ctx.consume<() => boolean>(HOST_COVER_INTERACTIVE);
|
|
31
40
|
const runtime = createMcpClientConfigService({
|
|
32
41
|
configIO: createRealConfigIO(),
|
|
33
42
|
knownCwds,
|
|
34
43
|
...(hostTrust ? { isProjectTrusted: (cwd: string) => hostTrust(cwd) } : {}),
|
|
44
|
+
...(trustSource ? { projectTrustSource: (cwd: string) => trustSource(cwd) } : {}),
|
|
45
|
+
...(coverInteractive ? { coverInteractive: () => coverInteractive() } : {}),
|
|
35
46
|
runner: createPiMcpListRunner(),
|
|
36
47
|
});
|
|
37
48
|
|
|
@@ -39,7 +50,18 @@ async function registerPlugin(ctx: ServerPluginContext): Promise<void> {
|
|
|
39
50
|
// observes it during its own registration.
|
|
40
51
|
ctx.provide(SERVICE_KEY, runtime);
|
|
41
52
|
|
|
42
|
-
|
|
53
|
+
// Raise the access dialog on a user-initiated write for an unknown folder, and
|
|
54
|
+
// log undecidable admissions through the host's throttled sink. Both optional:
|
|
55
|
+
// a host without them keeps the plain 403 / no log.
|
|
56
|
+
// See change: harden-plugin-cwd-admission.
|
|
57
|
+
const onIndeterminate = ctx.consume<(info: IndeterminateInfo) => void>(HOST_CWD_ADMISSION_LOG);
|
|
58
|
+
mountMcpClientRoutes(ctx.fastify, {
|
|
59
|
+
runtime,
|
|
60
|
+
knownCwds,
|
|
61
|
+
networkGuard: ctx.networkGuard,
|
|
62
|
+
holdCwdDenial: ctx.holdCwdDenial,
|
|
63
|
+
admitOptions: onIndeterminate ? { onIndeterminate } : undefined,
|
|
64
|
+
});
|
|
43
65
|
}
|
|
44
66
|
|
|
45
67
|
export default registerPlugin;
|
package/src/server/pi-runner.ts
CHANGED
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
* See change: migrate-mcp-to-pi-builtin (D3 "Live state").
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
+
import type { PiMcpListRunner } from "@blackbelt-technology/pi-dashboard-mcp-core/types.js";
|
|
15
16
|
import { ToolResolver } from "@blackbelt-technology/pi-dashboard-shared/platform/binary-lookup.js";
|
|
16
17
|
import { spawn } from "@blackbelt-technology/pi-dashboard-shared/platform/exec.js";
|
|
17
18
|
import { killPidWithGroup, killProcess } from "@blackbelt-technology/pi-dashboard-shared/platform/process.js";
|
|
18
19
|
import { buildSpawnEnvForArgv } from "@blackbelt-technology/pi-dashboard-shared/platform/runner.js";
|
|
19
|
-
import type { PiMcpListRunner } from "../core/types.js";
|
|
20
20
|
|
|
21
21
|
/** stdout cap — a list of servers is small; anything larger is not pi's JSON. */
|
|
22
22
|
const MAX_STDOUT_BYTES = 4 * 1024 * 1024;
|