@blackbelt-technology/pi-dashboard-mcp-client-plugin 0.10.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 +7 -4
- package/src/client/FolderMcpPage.tsx +27 -3
- package/src/client/FolderMcpSection.tsx +3 -3
- package/src/client/ProjectSettings.tsx +2 -2
- package/src/client/ServerEditor.tsx +2 -2
- package/src/client/ServerList.tsx +2 -2
- package/src/client/api.ts +1 -1
- package/src/client/folder-view.ts +2 -2
- package/src/client/hooks.ts +2 -1
- package/src/client/schema.ts +1 -1
- package/src/core/index.ts +8 -78
- package/src/server/index.ts +4 -4
- package/src/server/pi-runner.ts +1 -1
- package/src/server/routes.ts +4 -4
- package/schema/mcp-config.schema.json +0 -64
- package/src/core/config-io.ts +0 -70
- package/src/core/config-writer.ts +0 -634
- package/src/core/effective-view.ts +0 -251
- package/src/core/layers.ts +0 -61
- package/src/core/live-state.ts +0 -134
- package/src/core/path-utils.ts +0 -41
- package/src/core/pi-rules.ts +0 -297
- package/src/core/schema-validation.ts +0 -57
- package/src/core/service.ts +0 -141
- package/src/core/types.ts +0 -278
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ view. Uses pi's BUILT-IN MCP (pi ≥ 1.0.0); no `pi-mcp-adapter`.
|
|
|
11
11
|
|---|---|
|
|
12
12
|
| `.` / `./client` | Settings claim + sidebar/worktree folder MCP section + `/folder/:cwd/mcp` page |
|
|
13
13
|
| `./server` | `registerPlugin` — provides `mcp-client.config`, mounts the REST surface |
|
|
14
|
-
| `./core` |
|
|
14
|
+
| `./core` | DEPRECATED re-export of `@blackbelt-technology/pi-dashboard-mcp-core` (the host-free logic now lives there; kept for one minor) |
|
|
15
15
|
|
|
16
16
|
## Two layers
|
|
17
17
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blackbelt-technology/pi-dashboard-mcp-client-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "First-party dashboard plugin managing pi's built-in MCP configuration: Pi-global + trusted-folder mcp.json view with live state from `pi mcp list`, validated atomic writes, and global + folder MCP management surfaces.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pi-dashboard-plugin"
|
|
7
|
+
],
|
|
5
8
|
"license": "MIT",
|
|
6
9
|
"publishConfig": {
|
|
7
10
|
"access": "public"
|
|
@@ -32,7 +35,6 @@
|
|
|
32
35
|
},
|
|
33
36
|
"files": [
|
|
34
37
|
"src/",
|
|
35
|
-
"schema/",
|
|
36
38
|
"!**/AGENTS.md",
|
|
37
39
|
"!**/*.AGENTS.md",
|
|
38
40
|
"!**/__tests__",
|
|
@@ -46,8 +48,9 @@
|
|
|
46
48
|
"wouter": ">=3.0.0"
|
|
47
49
|
},
|
|
48
50
|
"dependencies": {
|
|
49
|
-
"@blackbelt-technology/dashboard-plugin-runtime": "^0.
|
|
50
|
-
"@blackbelt-technology/pi-dashboard-
|
|
51
|
+
"@blackbelt-technology/dashboard-plugin-runtime": "^0.11.0",
|
|
52
|
+
"@blackbelt-technology/pi-dashboard-mcp-core": "^0.11.0",
|
|
53
|
+
"@blackbelt-technology/pi-dashboard-shared": "^0.11.0",
|
|
51
54
|
"@mdi/js": "^7.4.47",
|
|
52
55
|
"@mdi/react": "^1.6.1",
|
|
53
56
|
"ajv": "^8.17.1"
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
* See change: migrate-mcp-to-pi-builtin; mcp-client-project-overrides.
|
|
21
21
|
*/
|
|
22
22
|
import { useT } from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
23
|
+
import { isProjectOverride } from "@blackbelt-technology/pi-dashboard-mcp-core/pi-rules.js";
|
|
24
|
+
import type { EffectiveServerView, EffectiveView, Provenance, Scope } from "@blackbelt-technology/pi-dashboard-mcp-core/types.js";
|
|
23
25
|
import type React from "react";
|
|
24
26
|
import { useMemo, useState } from "react";
|
|
25
27
|
import { useLocation } from "wouter";
|
|
26
|
-
import { isProjectOverride } from "../core/pi-rules.js";
|
|
27
|
-
import type { EffectiveServerView, EffectiveView, Provenance, Scope } from "../core/types.js";
|
|
28
28
|
import { ApiError, convertToOverride, removeServer, saveServer, scopeToWire, setProjectOverride } from "./api.js";
|
|
29
29
|
import { folderOverrideDraftOf, isFolderOwned, overrideRestorePatch } from "./folder-view.js";
|
|
30
30
|
import { invalidateEffective, useEffectiveConfig } from "./hooks.js";
|
|
@@ -90,8 +90,28 @@ const SOURCE_LABEL: Record<string, string> = {
|
|
|
90
90
|
pinned: "pinned folder",
|
|
91
91
|
folderWorkspaces: "folder workspace",
|
|
92
92
|
accessGrants: "access grant",
|
|
93
|
+
yolo: "YOLO",
|
|
93
94
|
};
|
|
94
95
|
|
|
96
|
+
/**
|
|
97
|
+
* A live entry's lifetime phrase from the host ("until dashboard restarts",
|
|
98
|
+
* "YOLO until <ISO>", "YOLO while the server runs"), worded for the banner.
|
|
99
|
+
* YOLO's ISO instant renders as the viewer's local time; the "YOLO" prefix is
|
|
100
|
+
* dropped because the sentence already names YOLO.
|
|
101
|
+
*/
|
|
102
|
+
function lifetimePhrase(lifetime: string): string {
|
|
103
|
+
if (lifetime === "until dashboard restarts") return "until the dashboard restarts";
|
|
104
|
+
const yoloUntil = /^YOLO until (.+)$/.exec(lifetime);
|
|
105
|
+
if (yoloUntil) {
|
|
106
|
+
const at = new Date(yoloUntil[1]);
|
|
107
|
+
return Number.isNaN(at.getTime())
|
|
108
|
+
? lifetime
|
|
109
|
+
: `until ${at.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })}`;
|
|
110
|
+
}
|
|
111
|
+
const yoloOther = /^YOLO (.+)$/.exec(lifetime);
|
|
112
|
+
return yoloOther ? yoloOther[1] : lifetime;
|
|
113
|
+
}
|
|
114
|
+
|
|
95
115
|
/**
|
|
96
116
|
* Who trusts this folder, per the host's decision order: pi's trust store (naming
|
|
97
117
|
* the recorded path), the dashboard (naming source + folder, and the scope), or —
|
|
@@ -135,8 +155,12 @@ function trustText(
|
|
|
135
155
|
const scope = coverInteractive
|
|
136
156
|
? t("mcpFolderTrustedScopeAll", undefined, "This applies to every pi session on this machine.")
|
|
137
157
|
: t("mcpFolderTrustedScopeDashboard", undefined, "This applies to dashboard sessions, not terminal pi.");
|
|
158
|
+
// A live (server-lifetime) entry names its source and how long it lasts.
|
|
159
|
+
const through = source.lifetime
|
|
160
|
+
? `${t("mcpFolderTrustedThrough", undefined, "through")} ${label} ${t("mcpFolderTrustedFor", undefined, "for")} ${source.entry} ${lifetimePhrase(source.lifetime)}`
|
|
161
|
+
: `${label} ${source.entry}`;
|
|
138
162
|
return (
|
|
139
|
-
`${t("mcpFolderTrustedByDashboard", undefined, "This folder is trusted by the dashboard")} —
|
|
163
|
+
`${t("mcpFolderTrustedByDashboard", undefined, "This folder is trusted by the dashboard")} ${source.lifetime ? "" : "— "}${through}. ${scope} ` +
|
|
140
164
|
t("mcpFolderTrustedNotChecked", undefined, "Running pi mcp list here, outside the dashboard, still reports its servers as not loaded.")
|
|
141
165
|
);
|
|
142
166
|
}
|
|
@@ -49,7 +49,7 @@ function ErrorMarker({ name }: { name: string }): React.ReactElement {
|
|
|
49
49
|
data-testid="mcp-folder-pill-error"
|
|
50
50
|
role="img"
|
|
51
51
|
aria-label={name}
|
|
52
|
-
className="text-red-
|
|
52
|
+
className="text-[var(--accent-red-text)] flex-none"
|
|
53
53
|
>
|
|
54
54
|
⚠
|
|
55
55
|
</span>
|
|
@@ -130,7 +130,7 @@ function pillContent(t: Translate, state: PillState): PillContent {
|
|
|
130
130
|
body: (
|
|
131
131
|
<span
|
|
132
132
|
data-testid="mcp-folder-pill-loading"
|
|
133
|
-
className="inline-block h-[15px] w-16 rounded bg-[var(--bg-tertiary
|
|
133
|
+
className="inline-block h-[15px] w-16 rounded bg-[var(--bg-tertiary)] animate-pulse"
|
|
134
134
|
/>
|
|
135
135
|
),
|
|
136
136
|
};
|
|
@@ -160,7 +160,7 @@ function pillContent(t: Translate, state: PillState): PillContent {
|
|
|
160
160
|
{state.off > 0 && (
|
|
161
161
|
<>
|
|
162
162
|
<span className="text-[var(--text-tertiary)]">·</span>
|
|
163
|
-
<span data-testid="mcp-folder-pill-off" className="text-
|
|
163
|
+
<span data-testid="mcp-folder-pill-off" className="text-[var(--accent-orange-text)]">
|
|
164
164
|
{t("mcpFolderOffCount", { count: state.off }, `${state.off} off`)}
|
|
165
165
|
</span>
|
|
166
166
|
</>
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
* See change: mcp-client-project-overrides (D9).
|
|
10
10
|
*/
|
|
11
11
|
import { useT } from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
12
|
+
import { displayExposure, MCP_EXPOSURES } from "@blackbelt-technology/pi-dashboard-mcp-core/pi-rules.js";
|
|
13
|
+
import type { EffectiveServerView, Scope } from "@blackbelt-technology/pi-dashboard-mcp-core/types.js";
|
|
12
14
|
import type React from "react";
|
|
13
15
|
import { useEffect, useRef, useState } from "react";
|
|
14
|
-
import { displayExposure, MCP_EXPOSURES } from "../core/pi-rules.js";
|
|
15
|
-
import type { EffectiveServerView, Scope } from "../core/types.js";
|
|
16
16
|
import { ApiError, scopeToWire, setProjectOverride } from "./api.js";
|
|
17
17
|
import { invalidateEffective } from "./hooks.js";
|
|
18
18
|
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
* See change: migrate-mcp-to-pi-builtin.
|
|
21
21
|
*/
|
|
22
22
|
import { useT } from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
23
|
+
import { authModeOf, isValidServerName, transportOf } from "@blackbelt-technology/pi-dashboard-mcp-core/pi-rules.js";
|
|
24
|
+
import type { Scope } from "@blackbelt-technology/pi-dashboard-mcp-core/types.js";
|
|
23
25
|
import type React from "react";
|
|
24
26
|
import { useEffect, useRef, useState } from "react";
|
|
25
|
-
import { authModeOf, isValidServerName, transportOf } from "../core/pi-rules.js";
|
|
26
|
-
import type { Scope } from "../core/types.js";
|
|
27
27
|
import { ApiError, fetchSchema, saveServer, scopeToWire } from "./api.js";
|
|
28
28
|
import { invalidateEffective } from "./hooks.js";
|
|
29
29
|
import {
|
|
@@ -30,10 +30,10 @@ import {
|
|
|
30
30
|
type SettingsStatusTone,
|
|
31
31
|
useT,
|
|
32
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";
|
|
33
35
|
import type React from "react";
|
|
34
36
|
import { useEffect, useState } from "react";
|
|
35
|
-
import { authModeOf, isProjectOverride } from "../core/pi-rules.js";
|
|
36
|
-
import type { EffectiveServerView, LayerStatus, LiveState, Scope } from "../core/types.js";
|
|
37
37
|
import { ApiError, convertServer, scopeToWire, setEnabled } from "./api.js";
|
|
38
38
|
import { overrideBadges, provenanceLabel } from "./folder-view.js";
|
|
39
39
|
import { invalidateEffective } from "./hooks.js";
|
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, ProjectOverridePatch, 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
|
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
*
|
|
11
11
|
* See change: migrate-mcp-to-pi-builtin; mcp-client-project-overrides.
|
|
12
12
|
*/
|
|
13
|
-
import { displayExposure, OVERRIDE_KEYS } from "
|
|
14
|
-
import type { ProjectOverridePatch, Provenance } from "
|
|
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";
|
|
15
15
|
import { stripRedacted } from "./schema.js";
|
|
16
16
|
|
|
17
17
|
/**
|
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 ──────────────────────────────────────────────────
|
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
|
|
package/src/core/index.ts
CHANGED
|
@@ -1,81 +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
|
-
isLegacyFolderCopy,
|
|
18
|
-
NotAllowedCwdError,
|
|
19
|
-
} from "./config-writer.js";
|
|
20
|
-
export {
|
|
21
|
-
createEffectiveViewReader,
|
|
22
|
-
type EffectiveViewReader,
|
|
23
|
-
isSecretKey,
|
|
24
|
-
redactEntry,
|
|
25
|
-
} from "./effective-view.js";
|
|
26
|
-
export { defaultLayerPaths, type LayerPaths, piAgentDir, readLayer } from "./layers.js";
|
|
27
|
-
export {
|
|
28
|
-
createLiveStateReader,
|
|
29
|
-
LIVE_STATE_CACHE_TTL_MS,
|
|
30
|
-
LIVE_STATE_TIMEOUT_MS,
|
|
31
|
-
type LiveStateReader,
|
|
32
|
-
parseMcpListJson,
|
|
33
|
-
} from "./live-state.js";
|
|
34
|
-
export {
|
|
35
|
-
ADAPTER_ONLY_KEYS,
|
|
36
|
-
adapterLeftovers,
|
|
37
|
-
authModeOf,
|
|
38
|
-
classifyProjectEntry,
|
|
39
|
-
displayExposure,
|
|
40
|
-
ignoredKeys,
|
|
41
|
-
isFullEntry,
|
|
42
|
-
isProjectOverride,
|
|
43
|
-
isValidServerName,
|
|
44
|
-
type KeptGlobal,
|
|
45
|
-
keptGlobalOf,
|
|
46
|
-
MCP_EXPOSURE_ALIASES,
|
|
47
|
-
MCP_EXPOSURES,
|
|
48
|
-
type McpExposure,
|
|
49
|
-
mcpNamespace,
|
|
50
|
-
OVERRIDE_KEYS,
|
|
51
|
-
type ProjectEntryClass,
|
|
52
|
-
transportOf,
|
|
53
|
-
validatePiEntry,
|
|
54
|
-
} from "./pi-rules.js";
|
|
55
|
-
export { errorFields, mcpConfigSchema, type PatchValidation, validateServerEntry } from "./schema-validation.js";
|
|
56
|
-
export { createMcpClientConfigService, type McpClientConfigServiceDeps, type McpClientRuntime } from "./service.js";
|
|
57
|
-
export type {
|
|
58
|
-
AuthMode,
|
|
59
|
-
ConfigIO,
|
|
60
|
-
ConfigRefusal,
|
|
61
|
-
ConfigRefusalCode,
|
|
62
|
-
ConfigWriteResult,
|
|
63
|
-
ConvertLegacyResult,
|
|
64
|
-
EffectiveServerView,
|
|
65
|
-
EffectiveView,
|
|
66
|
-
InactiveReason,
|
|
67
|
-
LayerStatus,
|
|
68
|
-
LiveServerState,
|
|
69
|
-
LiveState,
|
|
70
|
-
McpClientConfigService,
|
|
71
|
-
OverrideIssue,
|
|
72
|
-
ParseStatus,
|
|
73
|
-
PiMcpListRunner,
|
|
74
|
-
ProjectOverridePatch,
|
|
75
|
-
ProjectOverrideResult,
|
|
76
|
-
Provenance,
|
|
77
|
-
RemoveResult,
|
|
78
|
-
Scope,
|
|
79
|
-
ServerEntry,
|
|
80
|
-
SetEnabledResult,
|
|
81
|
-
} from "./types.js";
|
|
11
|
+
export * from "@blackbelt-technology/pi-dashboard-mcp-core";
|
package/src/server/index.ts
CHANGED
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import type { ServerPluginContext } from "@blackbelt-technology/dashboard-plugin-runtime/server";
|
|
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";
|
|
14
17
|
import type { IndeterminateInfo } from "@blackbelt-technology/pi-dashboard-shared/cwd-guard.js";
|
|
15
|
-
import { createRealConfigIO } from "../core/config-io.js";
|
|
16
|
-
import { createMcpClientConfigService } from "../core/service.js";
|
|
17
|
-
import type { ProjectTrustSource } from "../core/types.js";
|
|
18
18
|
import { createPiMcpListRunner } from "./pi-runner.js";
|
|
19
19
|
import { mountMcpClientRoutes } from "./routes.js";
|
|
20
20
|
|
|
21
|
-
const SERVICE_KEY =
|
|
21
|
+
const SERVICE_KEY = MCP_CLIENT_CONFIG_SERVICE_KEY;
|
|
22
22
|
const HOST_KNOWN_FOLDERS = "host.knownFolderCwds";
|
|
23
23
|
const HOST_PROJECT_TRUST = "host.isProjectTrusted";
|
|
24
24
|
const HOST_PROJECT_TRUST_SOURCE = "host.projectTrustSource";
|
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;
|
package/src/server/routes.ts
CHANGED
|
@@ -22,6 +22,10 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import type { CwdHoldOrigin, ServerPluginContext } from "@blackbelt-technology/dashboard-plugin-runtime/server";
|
|
25
|
+
import { isValidServerName, OVERRIDE_KEYS } from "@blackbelt-technology/pi-dashboard-mcp-core/pi-rules.js";
|
|
26
|
+
import { errorFields, mcpConfigSchema, validateServerEntry } from "@blackbelt-technology/pi-dashboard-mcp-core/schema-validation.js";
|
|
27
|
+
import type { McpClientRuntime } from "@blackbelt-technology/pi-dashboard-mcp-core/service.js";
|
|
28
|
+
import type { ConfigRefusal, ProjectOverridePatch, Scope, ServerEntry } from "@blackbelt-technology/pi-dashboard-mcp-core/types.js";
|
|
25
29
|
import {
|
|
26
30
|
type AdmitCwdOptions,
|
|
27
31
|
admissionAllows,
|
|
@@ -30,10 +34,6 @@ import {
|
|
|
30
34
|
releaseAdmission,
|
|
31
35
|
} from "@blackbelt-technology/pi-dashboard-shared/cwd-guard.js";
|
|
32
36
|
import type { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
|
|
33
|
-
import { isValidServerName, OVERRIDE_KEYS } from "../core/pi-rules.js";
|
|
34
|
-
import { errorFields, mcpConfigSchema, validateServerEntry } from "../core/schema-validation.js";
|
|
35
|
-
import type { McpClientRuntime } from "../core/service.js";
|
|
36
|
-
import type { ConfigRefusal, ProjectOverridePatch, Scope, ServerEntry } from "../core/types.js";
|
|
37
37
|
|
|
38
38
|
export interface McpClientRouteDeps {
|
|
39
39
|
runtime: McpClientRuntime;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$id": "https://pi-dashboard.local/schemas/mcp-config.schema.json",
|
|
4
|
-
"title": "pi built-in MCP server entry",
|
|
5
|
-
"description": "Hand-authored from pi 1.1.0 dist/core/mcp-servers.d.ts (McpServerConfig). Describes one `mcpServers.<name>` entry of ~/.pi/agent/mcp.json or <cwd>/.pi/mcp.json so the dashboard client can render editors without hard-coding field lists. Annotations: x-transport marks the two mutually exclusive transports (command xor url); x-secret marks credential-bearing fields (masked in the editor, redacted when inherited, omitted from folder copies); x-global-only marks fields pi reads only from the global file. The writer additionally mirrors pi's validateMcpServerConfig rules (pi-rules.ts).",
|
|
6
|
-
"$defs": {
|
|
7
|
-
"Exposure": {
|
|
8
|
-
"enum": ["codemode", "deferred", "direct", "hidden", "codemode-deferred"],
|
|
9
|
-
"description": "How the server's tools reach the model. Default codemode. codemode-deferred is pi's legacy alias of codemode, accepted on read and preserved."
|
|
10
|
-
},
|
|
11
|
-
"OAuthConfig": {
|
|
12
|
-
"type": "object",
|
|
13
|
-
"additionalProperties": true,
|
|
14
|
-
"properties": {
|
|
15
|
-
"clientId": { "type": "string" },
|
|
16
|
-
"clientSecret": { "type": "string", "x-secret": true },
|
|
17
|
-
"callbackPort": { "type": "integer", "minimum": 1, "maximum": 65535 },
|
|
18
|
-
"callbackUrl": { "type": "string" },
|
|
19
|
-
"scope": { "type": "string" },
|
|
20
|
-
"clientName": { "type": "string", "minLength": 1 },
|
|
21
|
-
"authServerMetadataUrl": { "type": "string" }
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
"AuthConfig": {
|
|
25
|
-
"type": "object",
|
|
26
|
-
"additionalProperties": true,
|
|
27
|
-
"required": ["provider"],
|
|
28
|
-
"properties": {
|
|
29
|
-
"provider": { "type": "string", "minLength": 1 }
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
"ProjectOverride": {
|
|
33
|
-
"type": "object",
|
|
34
|
-
"additionalProperties": false,
|
|
35
|
-
"description": "A project-file entry with no command, url or type: overrides only enabled, exposure and toolExposure of the Pi-global server of the same name (pi >= 1.0.1).",
|
|
36
|
-
"properties": {
|
|
37
|
-
"exposure": { "$ref": "#/$defs/Exposure" },
|
|
38
|
-
"toolExposure": { "type": "object", "additionalProperties": { "$ref": "#/$defs/Exposure" } },
|
|
39
|
-
"enabled": { "type": "boolean" }
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
"ServerEntry": {
|
|
43
|
-
"type": "object",
|
|
44
|
-
"additionalProperties": true,
|
|
45
|
-
"description": "One pi MCP server entry: stdio (command) or streamable HTTP (url).",
|
|
46
|
-
"properties": {
|
|
47
|
-
"type": { "enum": ["stdio", "http", "streamable-http"] },
|
|
48
|
-
"description": { "type": "string" },
|
|
49
|
-
"command": { "type": "string", "x-transport": "command" },
|
|
50
|
-
"args": { "type": "array", "items": { "type": "string" } },
|
|
51
|
-
"env": { "type": "object", "additionalProperties": { "type": "string" }, "x-secret": true },
|
|
52
|
-
"cwd": { "type": "string" },
|
|
53
|
-
"url": { "type": "string", "x-transport": "url" },
|
|
54
|
-
"headers": { "type": "object", "additionalProperties": { "type": "string" }, "x-secret": true },
|
|
55
|
-
"oauth": { "$ref": "#/$defs/OAuthConfig" },
|
|
56
|
-
"auth": { "$ref": "#/$defs/AuthConfig", "x-global-only": true },
|
|
57
|
-
"exposure": { "$ref": "#/$defs/Exposure" },
|
|
58
|
-
"toolExposure": { "type": "object", "additionalProperties": { "$ref": "#/$defs/Exposure" } },
|
|
59
|
-
"timeout": { "type": "number", "exclusiveMinimum": 0 },
|
|
60
|
-
"enabled": { "type": "boolean" }
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
package/src/core/config-io.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* mcp-client-plugin · real filesystem ConfigIO.
|
|
3
|
-
*
|
|
4
|
-
* The hardened atomic write moved here from `apple-tools/src/env.ts` so the
|
|
5
|
-
* core owns it and every consumer (dashboard server, hostless installer CLI)
|
|
6
|
-
* shares one implementation:
|
|
7
|
-
* - `wx` + a random name: never follow or clobber a pre-planted symlink.
|
|
8
|
-
* - mode 0600: a rename carries the temp file's mode onto the destination.
|
|
9
|
-
* - fsync before rename: no zero-length config after a crash.
|
|
10
|
-
* - unlink the temp on failure: no leftovers on ENOSPC/EACCES.
|
|
11
|
-
*
|
|
12
|
-
* See change: extract-mcp-client-plugin (task 2.1).
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import { randomBytes } from "node:crypto";
|
|
16
|
-
import {
|
|
17
|
-
closeSync,
|
|
18
|
-
existsSync,
|
|
19
|
-
fsyncSync,
|
|
20
|
-
mkdirSync,
|
|
21
|
-
openSync,
|
|
22
|
-
readFileSync,
|
|
23
|
-
renameSync,
|
|
24
|
-
unlinkSync,
|
|
25
|
-
writeSync,
|
|
26
|
-
} from "node:fs";
|
|
27
|
-
import { dirname, join } from "node:path";
|
|
28
|
-
import type { ConfigIO } from "./types.js";
|
|
29
|
-
|
|
30
|
-
export function writeFileAtomic(path: string, content: string): void {
|
|
31
|
-
const dir = dirname(path);
|
|
32
|
-
mkdirSync(dir, { recursive: true });
|
|
33
|
-
const tmp = join(dir, `.${randomBytes(8).toString("hex")}.tmp`);
|
|
34
|
-
const fd = openSync(tmp, "wx", 0o600);
|
|
35
|
-
try {
|
|
36
|
-
const buf = Buffer.from(content, "utf8");
|
|
37
|
-
let off = 0;
|
|
38
|
-
while (off < buf.length) {
|
|
39
|
-
off += writeSync(fd, buf, off, buf.length - off);
|
|
40
|
-
}
|
|
41
|
-
fsyncSync(fd);
|
|
42
|
-
} catch (e) {
|
|
43
|
-
closeSync(fd);
|
|
44
|
-
try {
|
|
45
|
-
unlinkSync(tmp);
|
|
46
|
-
} catch {
|
|
47
|
-
/* best effort */
|
|
48
|
-
}
|
|
49
|
-
throw e;
|
|
50
|
-
}
|
|
51
|
-
closeSync(fd);
|
|
52
|
-
try {
|
|
53
|
-
renameSync(tmp, path);
|
|
54
|
-
} catch (e) {
|
|
55
|
-
try {
|
|
56
|
-
unlinkSync(tmp);
|
|
57
|
-
} catch {
|
|
58
|
-
/* best effort */
|
|
59
|
-
}
|
|
60
|
-
throw e;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** A ConfigIO wired to the real filesystem. */
|
|
65
|
-
export function createRealConfigIO(): ConfigIO {
|
|
66
|
-
return {
|
|
67
|
-
readFile: (p) => (existsSync(p) ? readFileSync(p, "utf8") : null),
|
|
68
|
-
writeFileAtomic,
|
|
69
|
-
};
|
|
70
|
-
}
|