mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-09-07 08:27:12 +00:00
Some checks are pending
Rust / Format (push) Waiting to run
Rust / Clippy (push) Waiting to run
Rust / Generated Docs (push) Waiting to run
Rust / Test (Linux) (push) Waiting to run
Rust / Test (macOS) (push) Waiting to run
TypeScript / Typecheck (push) Waiting to run
TypeScript / Test (push) Waiting to run
TypeScript / Build (push) Waiting to run
## Summary
Adds a full CRUD management UI for server-managed MCP servers at
`/settings/mcps`, consuming the already-shipped `MCPServersApi` backend.
The implementation mirrors the existing `/settings/environments` pages
exactly in structure, naming, and component conventions.
## What changed
### Step 1 — Shared `KeyValueEditor` extracted
`KeyValueEditor`, `KeyValueEntry`, `entriesFromMap`, and
`mapFromEntries` are moved from `environment-form.tsx` into a new
`components/key-value-editor.tsx`. The component gains an optional
`renderEntryHint` prop so per-row warnings can be injected without
coupling the editor to credential logic. `Label` is promoted from
`environment-form.tsx` to `settings-panel.tsx` so both forms can use it.
### Step 2–4 — Query plumbing
- `query-keys.ts`: `mcpServers.{list, detail}` keys.
- `api-client.ts`: `mcpServersApi` instance (same pattern as
`environmentsApi`).
- `queries.ts`: `useMcpServers()` and `useMcpServer(id)` SWR hooks.
### Step 5 — Credential heuristics (`lib/credential-heuristics.ts`)
Pure functions `looksLikeCredential`, `secretNameForKey`,
`secretReference`. Key-name matching covers `authorization`, `password`,
`token`, `api[-_]?key`, `_key`/`_token`/`_secret` suffixes.
Value-entropy fallback fires for strings ≥ 20 chars, no spaces, mixed
case/digit classes. Template references (`{{ secrets.* }}`) are never
flagged.
### Step 6–7 — Form model + component (`components/mcp-server-form.tsx`)
- Flat `McpServerFormValues` discriminated on `McpTransportKind`.
- `defaultMcpServerFormValues`, `mcpServerToFormValues` (populates
`env`/`headers` from `env_keys`/`header_keys` with **empty values** —
the §5 write-only design), `createRequestFromForm`,
`replaceRequestFromForm`, `isMcpServerFormValid`, `credentialWarnings`.
- `McpServerFormFields` renders stdio / http / sandbox panels switching
on `values.transport`. Per-row credential nudge opens the secrets-new
page in a new tab and substitutes a `{{ secrets.NAME }}` reference; save
is never blocked by the heuristic.
- On edit, a row with a non-empty key and empty value blocks save with
an inline error (the intentional overwrite guard).
### Step 8–10 — Route pages
| File | Mirrors |
|---|---|
| `routes/settings-mcps.tsx` | `settings-environments.tsx` |
| `routes/settings-mcps-new.tsx` | `settings-environments-new.tsx` |
| `routes/settings-mcps-edit.tsx` | `settings-environments-edit.tsx` |
The edit page shows a write-only-values banner whenever the transport
has any `env_keys`/`header_keys`, uses `key={server.revision}` to
remount the form on external change, and translates 409 responses into
the `staleAwareMessage` pattern.
### Steps 11–12 — Router + nav
Three routes registered under `settings` children. `PuzzlePieceIcon` nav
entry added to the same section as Environments.
### Plan Summary
- Extract `KeyValueEditor` to shared component with hint-injection slot
- Credential heuristics library (pure, fully unit-tested)
- MCP form model: flat values ↔ discriminated API types, write-only-key
guard
- List / new / edit pages following environments pattern exactly
- Route registration and settings nav link
### Fabro Details
<details>
<summary>Ran 9 stages in 65m 58s for $20.54</summary>
| Stage | Duration | Cost | Retries |
|---|---|---|---|
| start | 0s | – | 0 |
| toolchain | 1s | – | 0 |
| preflight_compile | 2m 47s | – | 0 |
| preflight_lint | 4m 15s | – | 0 |
| implement | 26m 29s | $12.27 | 0 |
| simplify_opus | 7m 41s | $4.95 | 0 |
| simplify_gpt | 6m 51s | $2.69 | 0 |
| verify | 15m 44s | – | 0 |
| fixup | 1m 41s | $0.63 | 0 |
| **Total** | **65m 58s** | **$20.54** | **0** |
</details>
<details>
<summary>Ran <code>ImplementPlan.fabro</code> (11 nodes and 14
edges)</summary>
```dot
digraph ImplementPlan {
graph [
goal="Implement and simplify",
model_stylesheet="
* { model: claude-opus-4-8; }
"
]
rankdir=LR
start [shape=Mdiamond, label="Start"]
exit [shape=Msquare, label="Exit"]
toolchain [label="Toolchain", shape=parallelogram, script="command -v cargo >/dev/null || { curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && sudo ln -sf $HOME/.cargo/bin/* /usr/local/bin/; }; cargo --version 2>&1", max_retries=0]
preflight_compile [label="Preflight Compile", shape=parallelogram, script="cargo check -q --workspace 2>&1", max_retries=0]
preflight_lint [label="Preflight Lint", shape=parallelogram, script="cargo +nightly-2026-04-14 clippy -q --workspace --all-targets -- -D warnings 2>&1", max_retries=0]
fix_lints [label="Fix Lints", prompt="The preflight lint step failed. Read the build output from context and fix all clippy lint warnings.", max_visits=3]
implement [label="Implement", prompt="Read the plan file referenced in the goal and implement every step. Make all the code changes described in the plan. Use red/green TDD.", model="gpt-55", reasoning_effort="xhigh"]
simplify_opus [label="Simplify (Opus)", prompt="@prompts/simplify.md"]
simplify_gpt [label="Simplify (GPT-55)", prompt="@prompts/simplify.md", model="gpt-55"]
verify [label="Verify", shape=parallelogram, script="git fetch origin main 2>&1 && git merge --no-edit --no-stat origin/main 2>&1 && cargo +nightly-2026-04-14 fmt --all 2>&1 && cargo dev docs refresh 2>&1 && cargo +nightly-2026-04-14 fmt --check --all 2>&1 && { command -v rg >/dev/null 2>&1 || { echo 'rg is required for verify'; exit 127; }; } && ! rg -n 'AuthMode::Disabled|RunAuthMethod|RunSubjectProvenance|\bActorRef\b|\bActorKind\b|AuthenticatedSubject|AuthenticatedService|AuthorizeRunScoped|AuthorizeRunBlob|AuthorizeStageArtifact|AuthorizeCommandLog|auth_method\s*==\s*\"disabled\"' lib/crates apps lib/packages docs/public/api-reference/fabro-api.yaml 2>&1 && cargo +nightly-2026-04-14 clippy --workspace --all-targets -- -D warnings 2>&1 && cargo nextest run --workspace --status-level slow --profile ci 2>&1 && cargo dev docs check 2>&1 && bun install --frozen-lockfile 2>&1 && (cd apps/fabro-web && bun run typecheck) 2>&1 && (cd apps/fabro-web && bun run test) 2>&1 && (cd lib/packages/fabro-api-client && bun run typecheck) 2>&1 && cargo dev build -- -p fabro-cli --release 2>&1", goal_gate=true, retry_target="fixup"]
fixup [label="Fixup", prompt="The verify step failed. Read the build output from context and fix all format, clippy, Rust test, docs, TypeScript typecheck/test, and build failures.", max_visits=3]
start -> toolchain
toolchain -> preflight_compile [condition="outcome=succeeded"]
toolchain -> exit
preflight_compile -> preflight_lint [condition="outcome=succeeded"]
preflight_compile -> exit
preflight_lint -> implement [condition="outcome=succeeded"]
preflight_lint -> fix_lints
fix_lints -> preflight_lint
implement -> simplify_opus -> simplify_gpt -> verify
verify -> exit [condition="outcome=succeeded"]
verify -> fixup
fixup -> verify
}
```
</details>
⚒️ Generated with [Fabro](https://fabro.sh)
---------
Co-authored-by: Fabro <noreply@fabro.sh>
285 lines
7.1 KiB
TypeScript
285 lines
7.1 KiB
TypeScript
import type { ReactNode } from "react";
|
|
import type { ObjectStoreSettings } from "@qltysh/fabro-api-client";
|
|
|
|
export type SettingsView = "settings" | "json";
|
|
|
|
export function Panel({ title, children }: { title: string; children: ReactNode }) {
|
|
return (
|
|
<section className="overflow-hidden rounded-md border border-line bg-panel/40">
|
|
<header className="border-b border-line bg-overlay px-4 py-2.5">
|
|
<h2 className="text-xs font-medium uppercase tracking-wider text-fg-muted">
|
|
{title}
|
|
</h2>
|
|
</header>
|
|
<div className="divide-y divide-line">{children}</div>
|
|
</section>
|
|
);
|
|
}
|
|
|
|
export function PanelSkeleton() {
|
|
return (
|
|
<div className="overflow-hidden rounded-md border border-line bg-panel/40">
|
|
<div className="h-10 border-b border-line bg-overlay" />
|
|
<div className="space-y-4 px-4 py-6">
|
|
<div className="h-3 w-40 rounded bg-overlay-strong" />
|
|
<div className="h-3 w-64 rounded bg-overlay" />
|
|
<div className="h-3 w-52 rounded bg-overlay" />
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export function Row({
|
|
title,
|
|
help,
|
|
children,
|
|
}: {
|
|
title: ReactNode;
|
|
help?: ReactNode;
|
|
children: ReactNode;
|
|
}) {
|
|
return (
|
|
<div className="grid grid-cols-[minmax(0,5fr)_minmax(0,7fr)] items-start gap-x-6 gap-y-1 px-4 py-3.5">
|
|
<div className="min-w-0">
|
|
<div className="text-sm text-fg-2">{title}</div>
|
|
{help ? (
|
|
<div className="mt-0.5 text-xs/5 text-fg-3 text-pretty">{help}</div>
|
|
) : null}
|
|
</div>
|
|
<div className="min-w-0 self-center text-sm text-fg">{children}</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export function Label({
|
|
children,
|
|
required,
|
|
optional,
|
|
}: {
|
|
children: ReactNode;
|
|
required?: boolean;
|
|
optional?: boolean;
|
|
}) {
|
|
return (
|
|
<span className="inline-flex items-baseline gap-1.5">
|
|
<span>{children}</span>
|
|
{required ? (
|
|
<span aria-label="required" className="text-coral">
|
|
*
|
|
</span>
|
|
) : null}
|
|
{optional ? <span className="text-xs font-normal text-fg-muted">Optional</span> : null}
|
|
</span>
|
|
);
|
|
}
|
|
|
|
export function SettingsPageIntro({
|
|
description,
|
|
action,
|
|
view,
|
|
setView,
|
|
}: {
|
|
description: ReactNode;
|
|
action?: ReactNode;
|
|
view?: SettingsView;
|
|
setView?: (v: SettingsView) => void;
|
|
}) {
|
|
const trailing =
|
|
action ??
|
|
(view !== undefined && setView ? (
|
|
<ViewToggle view={view} setView={setView} />
|
|
) : null);
|
|
|
|
return (
|
|
<div className="flex items-start justify-between gap-6">
|
|
<p className="max-w-[64ch] text-sm/6 text-fg-3 text-pretty">{description}</p>
|
|
{trailing ? <div className="shrink-0">{trailing}</div> : null}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export function ViewToggle({
|
|
view,
|
|
setView,
|
|
}: {
|
|
view: SettingsView;
|
|
setView: (v: SettingsView) => void;
|
|
}) {
|
|
const btn = "rounded px-3 py-1.5 text-xs font-medium transition-colors";
|
|
return (
|
|
<div className="inline-flex shrink-0 rounded-md border border-line bg-panel/80 p-0.5">
|
|
<button
|
|
type="button"
|
|
onClick={() => setView("settings")}
|
|
aria-pressed={view === "settings"}
|
|
className={`${btn} ${view === "settings" ? "bg-overlay text-teal-500" : "text-fg-muted hover:text-fg-3"}`}
|
|
>
|
|
Settings
|
|
</button>
|
|
<button
|
|
type="button"
|
|
onClick={() => setView("json")}
|
|
aria-pressed={view === "json"}
|
|
className={`${btn} ${view === "json" ? "bg-overlay text-teal-500" : "text-fg-muted hover:text-fg-3"}`}
|
|
>
|
|
JSON
|
|
</button>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export function Mono({
|
|
children,
|
|
title,
|
|
}: {
|
|
children: ReactNode;
|
|
title?: string;
|
|
}) {
|
|
return (
|
|
<div
|
|
className="truncate font-mono text-xs text-fg-2"
|
|
title={title}
|
|
>
|
|
{children}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export function Muted({ children }: { children: ReactNode }) {
|
|
return <span className="text-fg-muted">{children}</span>;
|
|
}
|
|
|
|
export function Badge({ children }: { children: ReactNode }) {
|
|
return (
|
|
<span className="inline-flex items-center rounded-sm bg-overlay-strong px-1.5 py-0.5 font-mono text-[11px] text-fg-2">
|
|
{children}
|
|
</span>
|
|
);
|
|
}
|
|
|
|
export function NumberValue({ value }: { value: number }) {
|
|
return <span className="font-mono tabular-nums text-fg">{value}</span>;
|
|
}
|
|
|
|
export function Dot({ on }: { on: boolean }) {
|
|
return (
|
|
<span
|
|
className={`size-1.5 rounded-full ${on ? "bg-emerald-400" : "bg-fg-muted"}`}
|
|
aria-hidden="true"
|
|
/>
|
|
);
|
|
}
|
|
|
|
export function Toggle({ on }: { on: boolean }) {
|
|
return (
|
|
<span className="inline-flex items-center gap-2">
|
|
<Dot on={on} />
|
|
<span className={on ? "text-fg" : "text-fg-muted"}>
|
|
{on ? "Enabled" : "Disabled"}
|
|
</span>
|
|
</span>
|
|
);
|
|
}
|
|
|
|
export function UrlValue({ url }: { url: string }) {
|
|
return (
|
|
<a
|
|
href={url}
|
|
target="_blank"
|
|
rel="noreferrer"
|
|
className="truncate font-mono text-xs text-fg-2 hover:text-fg hover:underline"
|
|
title={url}
|
|
>
|
|
{url}
|
|
</a>
|
|
);
|
|
}
|
|
|
|
export function ObjectStoreRows({
|
|
store,
|
|
prefix,
|
|
}: {
|
|
store: ObjectStoreSettings;
|
|
prefix: string;
|
|
}) {
|
|
const prefixRow = (
|
|
<Row title="Prefix" help="Key prefix appended to every object path.">
|
|
{prefix ? <Mono>{prefix}</Mono> : <Muted>None</Muted>}
|
|
</Row>
|
|
);
|
|
|
|
if (store.type === "s3") {
|
|
return (
|
|
<>
|
|
<Row title="Type" help="Backend driver for this store.">
|
|
<Badge>s3</Badge>
|
|
</Row>
|
|
<Row title="Bucket" help="S3 bucket holding the objects.">
|
|
<Mono>{store.bucket}</Mono>
|
|
</Row>
|
|
<Row title="Region" help="AWS region the bucket lives in.">
|
|
<Mono>{store.region}</Mono>
|
|
</Row>
|
|
{store.endpoint ? (
|
|
<Row title="Endpoint" help="Custom S3-compatible endpoint URL.">
|
|
<Mono>{store.endpoint}</Mono>
|
|
</Row>
|
|
) : null}
|
|
{store.path_style ? (
|
|
<Row title="Path style" help="Use path-style addressing instead of virtual-hosted.">
|
|
<Toggle on={true} />
|
|
</Row>
|
|
) : null}
|
|
{prefixRow}
|
|
</>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<Row title="Type" help="Backend driver for this store.">
|
|
<Badge>local</Badge>
|
|
</Row>
|
|
<Row title="Root" help="Filesystem directory holding the objects.">
|
|
<Mono>{store.root}</Mono>
|
|
</Row>
|
|
{prefixRow}
|
|
</>
|
|
);
|
|
}
|
|
|
|
export function UsernameList({ names }: { names: string[] }) {
|
|
const visible = names.slice(0, 3);
|
|
const remaining = names.length - visible.length;
|
|
return (
|
|
<span className="inline-flex flex-wrap items-center gap-1.5">
|
|
{visible.map((n) => (
|
|
<Badge key={n}>{n}</Badge>
|
|
))}
|
|
{remaining > 0 ? (
|
|
<span className="text-xs text-fg-muted">+{remaining} more</span>
|
|
) : null}
|
|
</span>
|
|
);
|
|
}
|
|
|
|
export function Count({
|
|
n,
|
|
singular,
|
|
plural: pluralLabel,
|
|
suffix,
|
|
}: {
|
|
n: number;
|
|
singular: string;
|
|
plural: string;
|
|
suffix?: string;
|
|
}) {
|
|
if (n === 0) return <Muted>None</Muted>;
|
|
return (
|
|
<span className="text-fg-2">
|
|
<span className="font-mono tabular-nums text-fg">{n}</span>{" "}
|
|
{n === 1 ? singular : pluralLabel}
|
|
{suffix ? <span className="ml-1 text-fg-muted">{suffix}</span> : null}
|
|
</span>
|
|
);
|
|
}
|