Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat(extensions): look inside a plugin or MCP server — a file card on every detail page

rubenluetke10-beep1bbee2c78baa
diff --git a/jarvis/ui/web/frontend/src/components/extensions/FileCard.tsx b/jarvis/ui/web/frontend/src/components/extensions/FileCard.tsx
new file mode 100644
index 0000000000..7325dd1fca
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/extensions/FileCard.tsx
@@ -0,0 +1,199 @@
+/**
+ * The read-only file card of a detail page: a file picker ("plugin.json ▾ ·
+ * 3 files"), a preview/source toggle and the file itself. Markdown renders as
+ * prose in preview, JSON and everything else as monospace text; source is
+ * always the raw text.
+ *
+ * Plugins and MCP servers have no folder on disk, so the backend writes their
+ * defining pieces out as files (see `/api/marketplace/plugins/{id}/files` and
+ * `/api/mcps/{name}/files`); this card shows them the way the Skills card
+ * shows SKILL.md, so "what is this made of" reads the same across the section.
+ */
+import { useEffect, useMemo, useState, type ReactNode } from "react";
+import ReactMarkdown from "react-markdown";
+import remarkGfm from "remark-gfm";
+import { ChevronDown, Code2, Eye, FileCode, FileJson, FileText } from "lucide-react";
+import { cn } from "@/lib/utils";
+import { fill, useT } from "@/i18n";
+import { ActionMenu, Panel } from "@/components/extensions/primitives";
+
+export interface CardFile {
+ path: string;
+ text: string;
+ size?: number;
+ truncated?: boolean;
+}
+
+type ViewMode = "preview" | "source";
+
+function iconFor(path: string) {
+ if (/\.(md|markdown)$/i.test(path)) return FileText;
+ if (/\.json$/i.test(path)) return FileJson;
+ return FileCode;
+}
+
+/** Rendered markdown — the body of a SKILL.md, a usage card, a README. */
+export function MarkdownBody({ text }: { text: string }) {
+ return (
+ <article className="prose prose-neutral max-w-none text-[15px] leading-relaxed dark:prose-invert prose-headings:font-display prose-headings:tracking-tight prose-h1:text-2xl prose-h2:text-xl prose-h3:text-lg prose-a:text-primary prose-code:text-foreground prose-pre:border prose-pre:border-border prose-pre:bg-card/80">
+ <ReactMarkdown
+ remarkPlugins={[remarkGfm]}
+ components={{
+ a: ({ href, children, ...props }) => (
+ <a href={href} target="_blank" rel="noreferrer noopener" {...props}>
+ {children}
+ </a>
+ ),
+ }}
+ >
+ {text}
+ </ReactMarkdown>
+ </article>
+ );
+}
+
+export function ModeButton({
+ active,
+ label,
+ onClick,
+ children,
+}: {
+ active: boolean;
+ label: string;
+ onClick: () => void;
+ children: ReactNode;
+}) {
+ return (
+ <button
+ type="button"
+ role="tab"
+ aria-selected={active}
+ aria-label={label}
+ title={label}
+ onClick={onClick}
+ className={cn(
+ "grid h-7 w-8 place-items-center rounded transition-colors",
+ active ? "bg-sheen/[0.12] text-foreground" : "text-muted-foreground hover:text-foreground",
+ )}
+ >
+ {children}
+ </button>
+ );
+}
+
+export function FileCard({
+ files,
+ loading,
+ error,
+ emptyLabel,
+ className,
+}: {
+ files: CardFile[];
+ loading?: boolean;
+ error?: string | null;
+ emptyLabel?: string;
+ className?: string;
+}) {
+ const t = useT();
+ const [openPath, setOpenPath] = useState<string | null>(null);
+ const [mode, setMode] = useState<ViewMode>("preview");
+
+ // Follow the data: the first file once it arrives, and never a path that
+ // vanished from the list.
+ useEffect(() => {
+ if (files.length === 0) {
+ setOpenPath(null);
+ return;
+ }
+ if (!openPath || !files.some((f) => f.path === openPath)) setOpenPath(files[0].path);
+ }, [files, openPath]);
+
+ const open = useMemo(() => files.find((f) => f.path === openPath) ?? null, [files, openPath]);
+ const isMarkdown = open ? /\.(md|markdown)$/i.test(open.path) : false;
+ const OpenIcon = open ? iconFor(open.path) : FileText;
+
+ return (
+ <Panel className={className}>
+ <div className="flex items-center gap-3 border-b border-border/70 px-3 py-2">
+ <ActionMenu
+ label={t("extensions.files_menu")}
+ align="start"
+ actions={files.map((f) => {
+ const Icon = iconFor(f.path);
+ return {
+ id: f.path,
+ label: f.path,
+ icon: <Icon className="h-3.5 w-3.5" />,
+ onSelect: () => setOpenPath(f.path),
+ };
+ })}
+ trigger={({ open: menuOpen, toggle }) => (
+ <button
+ type="button"
+ onClick={toggle}
+ disabled={files.length === 0}
+ aria-expanded={menuOpen}
+ aria-haspopup="menu"
+ className="inline-flex h-8 max-w-[360px] items-center gap-2 rounded-md bg-sheen/[0.07] px-3 font-mono text-[13px] text-foreground hover:bg-sheen/[0.12] disabled:opacity-60"
+ >
+ <OpenIcon className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />
+ <span className="truncate">{open?.path ?? "—"}</span>
+ <ChevronDown
+ className={cn("h-3.5 w-3.5 shrink-0 transition-transform", menuOpen && "rotate-180")}
+ />
+ </button>
+ )}
+ />
+ <span className="text-sm text-muted-foreground">
+ {files.length === 1
+ ? t("extensions.file_one")
+ : fill(t("extensions.files"), { n: files.length })}
+ </span>
+ <div
+ className="ml-auto flex items-center rounded-md bg-sheen/[0.05] p-0.5"
+ role="tablist"
+ aria-label={t("extensions.view_mode")}
+ >
+ <ModeButton
+ active={mode === "preview"}
+ label={t("extensions.view_preview")}
+ onClick={() => setMode("preview")}
+ >
+ <Eye className="h-4 w-4" />
+ </ModeButton>
+ <ModeButton
+ active={mode === "source"}
+ label={t("extensions.view_source")}
+ onClick={() => setMode("source")}
+ >
+ <Code2 className="h-4 w-4" />
+ </ModeButton>
+ </div>
+ </div>
+
+ {loading && (
+ <div className="px-6 py-6 text-sm text-muted-foreground">{t("common.loading")}</div>
+ )}
+ {!loading && error && (
+ <div className="px-6 py-6 text-sm text-destructive">{error}</div>
+ )}
+ {!loading && !error && !open && (
+ <div className="px-6 py-6 text-sm text-muted-foreground">
+ {emptyLabel ?? t("extensions.no_files")}
+ </div>
+ )}
+ {!loading && !error && open && (
+ mode === "preview" && isMarkdown ? (
+ <div className="max-h-[60vh] overflow-auto px-6 py-5">
+ <MarkdownBody text={open.text} />
+ </div>
+ ) : (
+ <pre className="max-h-[60vh] overflow-auto whitespace-pre-wrap break-words px-6 py-5 font-mono text-[13px] leading-relaxed">
+ {open.text}
+ {open.truncated ? "\n…" : ""}
+ </pre>
+ )
+ )}
+ </Panel>
+ );
+}
diff --git a/jarvis/ui/web/frontend/src/components/extensions/primitives.tsx b/jarvis/ui/web/frontend/src/components/extensions/primitives.tsx
index 92b769a93c..0e910cf220 100644
--- a/jarvis/ui/web/frontend/src/components/extensions/primitives.tsx
+++ b/jarvis/ui/web/frontend/src/components/extensions/primitives.tsx
@@ -439,10 +439,10 @@ export function DetailHeader({
{leading}
<div className="min-w-0">
<div className="flex items-center gap-2">
- <h3 className="truncate text-base font-semibold leading-tight">{title}</h3>
+ <h3 className="truncate text-xl font-semibold leading-tight">{title}</h3>
{titleAccessory}
</div>
- {byline ? <p className="mt-0.5 text-xs text-muted-foreground">{byline}</p> : null}
+ {byline ? <p className="mt-1 text-sm text-muted-foreground">{byline}</p> : null}
</div>
</div>
{actions ? <div className="flex shrink-0 items-center gap-2">{actions}</div> : null}
@@ -475,7 +475,7 @@ export function ClampedText({
if (!text) return null;
return (
- <div className={cn("text-[13px] leading-relaxed text-foreground/85", className)}>
+ <div className={cn("text-[15px] leading-relaxed text-foreground/85", className)}>
<p ref={ref} className={cn(!expanded && "line-clamp-2")}>
{text}
{expanded && overflows && (
@@ -495,7 +495,7 @@ export function ClampedText({
<button
type="button"
onClick={() => setExpanded(true)}
- className="mt-0.5 text-xs text-primary hover:underline"
+ className="mt-0.5 text-sm text-primary hover:underline"
>
{moreLabel}
</button>
@@ -529,11 +529,11 @@ export function FactRows({
const visible = rows.filter((r) => r.value !== null && r.value !== undefined && r.value !== "");
if (visible.length === 0) return null;
return (
- <dl className={cn("grid grid-cols-[max-content_minmax(0,1fr)] gap-x-6 gap-y-2 text-sm", className)}>
+ <dl className={cn("grid grid-cols-[max-content_minmax(0,1fr)] gap-x-8 gap-y-2.5 text-[15px]", className)}>
{visible.map((r) => (
<div key={r.label} className="contents">
- <dt className="text-xs leading-5 text-muted-foreground">{r.label}</dt>
- <dd className="min-w-0 break-words leading-5">{r.value}</dd>
+ <dt className="text-sm leading-6 text-muted-foreground">{r.label}</dt>
+ <dd className="min-w-0 break-words leading-6">{r.value}</dd>
</div>
))}
</dl>
diff --git a/jarvis/ui/web/frontend/src/views/McpsView.test.tsx b/jarvis/ui/web/frontend/src/views/McpsView.test.tsx
index 6c7b59d5bf..f09e5017aa 100644
--- a/jarvis/ui/web/frontend/src/views/McpsView.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/McpsView.test.tsx
@@ -74,6 +74,15 @@ function installFetchMock(): Call[] {
text: async () => JSON.stringify(body),
}) as Response;
if (method === "GET" && url === "/api/mcps") return respond(SERVERS);
+ if (method === "GET" && url.endsWith("/files")) {
+ return respond({
+ config_path: "/tmp/mcp.json",
+ files: [
+ { path: "mcp.json", text: '{ "mcpServers": {} }', size: 20 },
+ { path: "definition.json", text: "{}", size: 2 },
+ ],
+ });
+ }
if (method === "POST" && url.endsWith("/disable")) return respond({ ok: true, enabled: false });
if (method === "POST" && url.endsWith("/enable")) return respond({ ok: true, enabled: true });
if (method === "POST" && url.endsWith("/check")) {
@@ -146,6 +155,9 @@ describe("McpsView — detail page", () => {
expect(screen.getByText("notebook_list")).toBeTruthy();
expect(screen.getByText("notebook_get")).toBeTruthy();
expect(screen.getByText("python -m notebooklm_mcp.server")).toBeTruthy();
+ // The file card opens on the server's own mcp.json block.
+ await screen.findByText("mcp.json");
+ expect(screen.getByText("2 files")).toBeTruthy();
// The overflow menu carries the connection check.
fireEvent.click(screen.getByRole("button", { name: "More actions" }));
diff --git a/jarvis/ui/web/frontend/src/views/McpsView.tsx b/jarvis/ui/web/frontend/src/views/McpsView.tsx
index 66572b707d..a8efc4b3b0 100644
--- a/jarvis/ui/web/frontend/src/views/McpsView.tsx
+++ b/jarvis/ui/web/frontend/src/views/McpsView.tsx
@@ -34,6 +34,7 @@ import {
TableRow,
type Column,
} from "@/components/extensions/primitives";
+import { FileCard, type CardFile } from "@/components/extensions/FileCard";
import { useEventStore } from "@/store/events";
import { robustCopy } from "@/lib/clipboard";
import { fill, useT } from "@/i18n";
@@ -426,6 +427,12 @@ export function McpsView() {
// Detail page
// ---------------------------------------------------------------------------
+async function fetchMcpFiles(name: string): Promise<{ files: CardFile[]; config_path: string }> {
+ const res = await fetch(`/api/mcps/${encodeURIComponent(name)}/files`);
+ if (!res.ok) throw new Error(`HTTP ${res.status}`);
+ return res.json();
+}
+
function McpDetail({
server,
pending,
@@ -442,6 +449,10 @@ function McpDetail({
onEditConfig: () => void;
}) {
const t = useT();
+ const filesQuery = useQuery({
+ queryKey: ["mcp-files", server.name],
+ queryFn: () => fetchMcpFiles(server.name),
+ });
const st = statusOf(server, pending, t);
const missing = (server.required_auth ?? []).filter(
(k) => server.credentials_status && server.credentials_status[k] === false,
@@ -530,7 +541,7 @@ function McpDetail({
{ label: t("mcps_view.col_transport"), value: server.transport ?? null },
{
label: t("mcps_view.command"),
- value: command ? <code className="font-mono text-xs">{command}</code> : null,
+ value: command ? <code className="font-mono text-[13px]">{command}</code> : null,
},
{
label: t("mcps_view.credentials"),
@@ -551,20 +562,27 @@ function McpDetail({
</div>
</Panel>
+ <FileCard
+ className="mt-4"
+ files={filesQuery.data?.files ?? []}
+ loading={filesQuery.isPending}
+ error={filesQuery.error ? (filesQuery.error as Error).message : null}
+ />
+
<Panel className="mt-4">
<div className="flex items-center gap-2 border-b border-border/70 px-5 py-2.5">
- <span className="text-xs font-medium">{t("mcps_view.tools_heading")}</span>
- <span className="text-xs text-muted-foreground">{server.tools.length}</span>
+ <span className="text-sm font-medium">{t("mcps_view.tools_heading")}</span>
+ <span className="text-sm text-muted-foreground">{server.tools.length}</span>
</div>
{server.tools.length === 0 ? (
<p className="px-5 py-4 text-xs text-muted-foreground">{t("mcps_view.no_tools")}</p>
) : (
<ul className="divide-y divide-border/70">
{server.tools.map((tool) => (
- <li key={tool.name} className="px-5 py-2.5">
- <p className="font-mono text-xs">{tool.name}</p>
+ <li key={tool.name} className="px-5 py-3">
+ <p className="font-mono text-[13px]">{tool.name}</p>
{tool.description && (
- <p className="mt-0.5 line-clamp-2 text-[11px] text-muted-foreground" title={tool.description}>
+ <p className="mt-0.5 line-clamp-2 text-[13px] text-muted-foreground" title={tool.description}>
{tool.description}
</p>
)}
diff --git a/jarvis/ui/web/frontend/src/views/PluginsView.test.tsx b/jarvis/ui/web/frontend/src/views/PluginsView.test.tsx
index 053cd92198..4c32758f91 100644
--- a/jarvis/ui/web/frontend/src/views/PluginsView.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/PluginsView.test.tsx
@@ -55,6 +55,13 @@ function installCatalogFetchMock() {
json: async () => CATALOG,
} as Response;
}
+ if (/^\/api\/marketplace\/plugins\/[^/]+\/files$/.test(url)) {
+ return {
+ ok: true,
+ status: 200,
+ json: async () => ({ files: [{ path: "plugin.json", text: "{}", size: 2 }] }),
+ } as Response;
+ }
throw new Error(`unexpected fetch ${url}`);
});
(globalThis as unknown as { fetch: typeof fetch }).fetch =
@@ -267,7 +274,12 @@ describe("plugin row click", () => {
const urls = (
globalThis.fetch as unknown as ReturnType<typeof vi.fn>
).mock.calls.map((c: unknown[]) => String(c[0]));
- expect(urls.every((u: string) => u === "/api/marketplace/plugins")).toBe(true);
+ // Only reads: the catalog and the plugin's own files — never a DELETE.
+ expect(
+ urls.every(
+ (u: string) => u === "/api/marketplace/plugins" || u === "/api/marketplace/plugins/github/files",
+ ),
+ ).toBe(true);
});
});
diff --git a/jarvis/ui/web/frontend/src/views/PluginsView.tsx b/jarvis/ui/web/frontend/src/views/PluginsView.tsx
index be069531b3..d91a77a7be 100644
--- a/jarvis/ui/web/frontend/src/views/PluginsView.tsx
+++ b/jarvis/ui/web/frontend/src/views/PluginsView.tsx
@@ -48,6 +48,7 @@ import {
TableRow,
type Column,
} from "@/components/extensions/primitives";
+import { FileCard, type CardFile } from "@/components/extensions/FileCard";
import { cn } from "@/lib/utils";
import { MarketplaceBadge } from "@/components/MarketplaceBadge";
import { openExternalUrl } from "@/lib/openExternal";
@@ -1231,8 +1232,20 @@ function PluginTableRow({
// Detail page
// ---------------------------------------------------------------------------
+async function fetchPluginFiles(pluginId: string): Promise<{ files: CardFile[] }> {
+ const res = await fetch(`/api/marketplace/plugins/${encodeURIComponent(pluginId)}/files`, {
+ cache: "no-store",
+ });
+ if (!res.ok) throw new Error(`HTTP ${res.status}`);
+ return res.json();
+}
+
function PluginDetail({ plugin, onConnect, onDisconnect }: { plugin: Plugin } & ConnectHandlers) {
const { busy, run } = useConnectLock(() => onConnect(plugin));
+ const filesQuery = useQuery({
+ queryKey: ["marketplace-plugin-files", plugin.id],
+ queryFn: () => fetchPluginFiles(plugin.id),
+ });
const connected = plugin.status === "connected";
const needsReconnect = plugin.status === "needs_reauth" || plugin.status === "error";
const family = oauthClientFamily(plugin);
@@ -1387,6 +1400,13 @@ function PluginDetail({ plugin, onConnect, onDisconnect }: { plugin: Plugin } &
/>
</div>
</Panel>
+
+ <FileCard
+ className="mt-4"
+ files={filesQuery.data?.files ?? []}
+ loading={filesQuery.isPending}
+ error={filesQuery.error ? (filesQuery.error as Error).message : null}
+ />
</div>
);
}
diff --git a/jarvis/ui/web/frontend/src/views/SkillsView.tsx b/jarvis/ui/web/frontend/src/views/SkillsView.tsx
index ea1d0e8a7c..1abb90f28d 100644
--- a/jarvis/ui/web/frontend/src/views/SkillsView.tsx
+++ b/jarvis/ui/web/frontend/src/views/SkillsView.tsx
@@ -1,6 +1,4 @@
import { useMemo, useState, useEffect, useCallback } from "react";
-import ReactMarkdown from "react-markdown";
-import remarkGfm from "remark-gfm";
import {
RefreshCw,
Lock,
@@ -62,6 +60,7 @@ import {
formatShortDate,
type Column,
} from "@/components/extensions/primitives";
+import { MarkdownBody, ModeButton } from "@/components/extensions/FileCard";
import { cn } from "@/lib/utils";
import { robustCopy } from "@/lib/clipboard";
import { fill, translate, useT, useUiLanguage } from "@/i18n";
@@ -1159,14 +1158,14 @@ function SkillDetailPage({
onClick={toggle}
aria-expanded={open}
aria-haspopup="menu"
- className="inline-flex h-7 max-w-[320px] items-center gap-1.5 rounded-md bg-sheen/[0.07] px-2.5 font-mono text-xs text-foreground hover:bg-sheen/[0.12]"
+ className="inline-flex h-8 max-w-[360px] items-center gap-2 rounded-md bg-sheen/[0.07] px-3 font-mono text-[13px] text-foreground hover:bg-sheen/[0.12]"
>
<span className="truncate">{openLabel}</span>
<ChevronDown className={cn("h-3.5 w-3.5 shrink-0 transition-transform", open && "rotate-180")} />
</button>
)}
/>
- <span className="text-xs text-muted-foreground">
+ <span className="text-sm text-muted-foreground">
{fileCount === 1 ? t("skills_view.file_one") : fill(t("skills_view.files"), { n: fileCount })}
</span>
<div className="ml-auto flex items-center gap-1">
@@ -1192,14 +1191,14 @@ function SkillDetailPage({
label={t("skills_view.view_preview")}
onClick={() => setMode("preview")}
>
- <Eye className="h-3.5 w-3.5" />
+ <Eye className="h-4 w-4" />
</ModeButton>
<ModeButton
active={mode === "source"}
label={t("skills_view.view_source")}
onClick={() => setMode("source")}
>
- <Code2 className="h-3.5 w-3.5" />
+ <Code2 className="h-4 w-4" />
</ModeButton>
</div>
</div>
@@ -1242,7 +1241,7 @@ function SkillDetailPage({
) : (
<textarea
className={cn(
- "block min-h-[420px] w-full resize-y bg-transparent px-6 py-5 font-mono text-xs leading-relaxed",
+ "block min-h-[420px] w-full resize-y bg-transparent px-6 py-5 font-mono text-[13px] leading-relaxed",
"focus:outline-none",
)}
aria-label="SKILL.md"
@@ -1285,35 +1284,6 @@ function SkillDetailPage({
);
}
-function ModeButton({
- active,
- label,
- onClick,
- children,
-}: {
- active: boolean;
- label: string;
- onClick: () => void;
- children: React.ReactNode;
-}) {
- return (
- <button
- type="button"
- role="tab"
- aria-selected={active}
- aria-label={label}
- title={label}
- onClick={onClick}
- className={cn(
- "grid h-6 w-7 place-items-center rounded transition-colors",
- active ? "bg-sheen/[0.12] text-foreground" : "text-muted-foreground hover:text-foreground",
- )}
- >
- {children}
- </button>
- );
-}
-
function TriggerList({ triggers }: { triggers: SkillTrigger[] }) {
return (
<ul className="space-y-0.5">
@@ -1334,26 +1304,6 @@ function TriggerList({ triggers }: { triggers: SkillTrigger[] }) {
);
}
-/** Rendered markdown — the body of SKILL.md or a bundled .md resource. */
-function MarkdownBody({ text }: { text: string }) {
- return (
- <article className="prose prose-neutral max-w-none text-sm dark:prose-invert prose-headings:font-display prose-headings:tracking-tight prose-h1:text-xl prose-h2:text-lg prose-h3:text-base prose-a:text-primary prose-code:text-foreground prose-pre:border prose-pre:border-border prose-pre:bg-card/80">
- <ReactMarkdown
- remarkPlugins={[remarkGfm]}
- components={{
- a: ({ href, children, ...props }) => (
- <a href={href} target="_blank" rel="noreferrer noopener" {...props}>
- {children}
- </a>
- ),
- }}
- >
- {text}
- </ReactMarkdown>
- </article>
- );
-}
-
function ResourceBody({
skillName,
kind,
@@ -1384,7 +1334,7 @@ function ResourceBody({
);
}
return (
- <pre className="max-h-[60vh] overflow-auto whitespace-pre-wrap break-words px-6 py-5 font-mono text-[11px] leading-relaxed">
+ <pre className="max-h-[60vh] overflow-auto whitespace-pre-wrap break-words px-6 py-5 font-mono text-[13px] leading-relaxed">
{data}
</pre>
);
diff --git a/jarvis/ui/web/marketplace_routes.py b/jarvis/ui/web/marketplace_routes.py
index daee39f75e..fd91e39294 100644
--- a/jarvis/ui/web/marketplace_routes.py
+++ b/jarvis/ui/web/marketplace_routes.py
@@ -1010,6 +1010,87 @@ def _plugin_manifest_files(entry: Any) -> list[dict[str, Any]]:
return files
+def _mask_env_literals(block: dict[str, Any]) -> dict[str, Any]:
+ """A copy of an MCP server block with literal ``env`` values hidden.
+
+ ``$NAME`` references are resolved from the credential store and safe to
+ show; anything else in ``env`` may be a pasted token and is not.
+ """
+ out = dict(block)
+ env = out.get("env")
+ if isinstance(env, dict):
+ out["env"] = {
+ k: (v if isinstance(v, str) and v.startswith("$") else "••••••")
+ for k, v in env.items()
+ }
+ return out
+
+
[email protected]("/plugins/{plugin_id}/files", openapi_extra={"x-jarvis-readonly": True})
+async def plugin_files(plugin_id: str, response: Response) -> dict[str, Any]:
+ """What a plugin is made of, as readable files — the detail page's file card.
+
+ A plugin is a catalog entry, not a folder on disk, so the "files" are the
+ pieces that decide what it may do, written out the way a plugin folder
+ would hold them: ``plugin.json`` (the spec without secrets — the schema
+ already excludes client secrets), ``mcp.json`` when it talks to an MCP
+ server (literal env values masked), and ``USAGE.md`` — the usage card the
+ brain reads when it calls the plugin. For a community plugin the
+ published manifests follow under ``source/``. Nothing is written.
+ """
+ response.headers["Cache-Control"] = "no-store"
+ spec = load_catalog().by_id(plugin_id)
+ if spec is None:
+ raise HTTPException(status_code=404, detail=f"Plugin '{plugin_id}' not found")
+
+ dump = spec.model_dump(mode="json", exclude_none=True)
+ mcp_block = dump.pop("mcp_server", None)
+ files = [_text_file("plugin.json", json.dumps(dump, indent=2, ensure_ascii=False))]
+ if isinstance(mcp_block, dict):
+ files.append(
+ _text_file(
+ "mcp.json",
+ json.dumps(
+ {"mcpServers": {spec.id: _mask_env_literals(mcp_block)}},
+ indent=2,
+ ensure_ascii=False,
+ ),
+ )
+ )
+
+ from jarvis.marketplace.usage_cards.loader import _resolve_card_path
+
+ card = _resolve_card_path(spec.id)
+ if card is not None:
+ try:
+ files.append(_text_file("USAGE.md", card.read_text(encoding="utf-8")))
+ except OSError as exc:
+ log.warning("usage card for %s unreadable: %s", spec.id, exc)
+
+ if spec.source == "community":
+ from jarvis.marketplace import community_source
+
+ try:
+ index, _ = await community_source.get_index()
+ except Exception as exc: # noqa: BLE001 — the card must still open
+ log.warning("community index unavailable for %s files: %s", spec.id, exc)
+ index = None
+ entry = (
+ next((e for e in index.plugins if e.name == spec.id), None)
+ if index is not None
+ else None
+ )
+ if entry is not None:
+ for f in _plugin_manifest_files(entry):
+ files.append({**f, "path": f"source/{f['path']}"})
+
+ return {
+ "id": spec.id,
+ "source": spec.source,
+ "files": files,
+ }
+
+
@router.get("/community/{item_id}/contents", openapi_extra={"x-jarvis-readonly": True})
async def community_contents(item_id: str, response: Response) -> dict[str, Any]:
"""What one published entry actually contains — skill, plugin or wallpaper.
diff --git a/jarvis/ui/web/mcp_routes.py b/jarvis/ui/web/mcp_routes.py
index 5f833286b5..6fa44e6f39 100644
--- a/jarvis/ui/web/mcp_routes.py
+++ b/jarvis/ui/web/mcp_routes.py
@@ -450,6 +450,68 @@ async def set_credentials(
}
+def _mask_env_literals(block: dict[str, Any]) -> dict[str, Any]:
+ """A copy of an mcp.json server block with literal ``env`` values hidden.
+
+ ``$NAME`` references resolve from the credential store and are safe to
+ show; anything else may be a pasted token and is not.
+ """
+ out = dict(block)
+ env = out.get("env")
+ if isinstance(env, dict):
+ out["env"] = {
+ k: (v if isinstance(v, str) and v.startswith("$") else "••••••")
+ for k, v in env.items()
+ }
+ return out
+
+
[email protected]("/{name}/files", openapi_extra={"x-jarvis-readonly": True})
+async def mcp_files(name: str, request: Request) -> dict[str, Any]:
+ """What defines one MCP server, as readable files — the detail page's file card.
+
+ ``mcp.json`` is the server's own block from the user's config (absent for a
+ built-in default that was never written there); ``definition.json`` is the
+ spec the registry actually runs — command, transport, URL, required
+ credentials, platform notes — so a built-in server is readable too.
+ Secrets never appear: env literals are masked and headers are omitted.
+ """
+ import json
+
+ registry = _get_registry(request)
+ spec = registry.get_spec(name) if registry is not None else None
+ spec = spec or next((s for s in BOOTSTRAP_SERVERS if s.name == name), None)
+ entry = mcp_state.get_server_entry(name)
+ if spec is None and entry is None:
+ raise HTTPException(404, f"MCP server '{name}' unknown.")
+
+ files: list[dict[str, Any]] = []
+ if entry is not None:
+ text = json.dumps(
+ {"mcpServers": {name: _mask_env_literals(entry)}}, indent=2, ensure_ascii=False
+ )
+ files.append({"path": "mcp.json", "size": len(text.encode("utf-8")), "text": text})
+ if spec is not None:
+ definition = {
+ "name": spec.name,
+ "display": spec.display,
+ "description": spec.description,
+ "transport": spec.transport,
+ "install_command": list(spec.install_command),
+ "url": spec.url,
+ "required_auth": list(spec.required_auth),
+ "platform_notes": spec.platform_notes,
+ "mandatory": spec.mandatory,
+ }
+ text = json.dumps(definition, indent=2, ensure_ascii=False)
+ files.append({"path": "definition.json", "size": len(text.encode("utf-8")), "text": text})
+ return {
+ "name": name,
+ "config_path": str(mcp_state._active_mcp_json_path()), # noqa: SLF001 — same helper the info route uses
+ "files": files,
+ }
+
+
@router.get("/config/info")
async def config_info() -> dict[str, Any]:
"""Path + existence + raw content of mcp.json (for the UI editor)."""
diff --git a/tests/unit/marketplace/test_plugin_files.py b/tests/unit/marketplace/test_plugin_files.py
new file mode 100644
index 0000000000..a842a96ed1
--- /dev/null
+++ b/tests/unit/marketplace/test_plugin_files.py
@@ -0,0 +1,103 @@
+"""The detail page's file card: what a plugin is made of, as readable files.
+
+A plugin is a catalog entry, not a folder on disk, so the route writes the
+pieces out the way a folder would hold them — ``plugin.json``, ``mcp.json``
+when there is a server, the usage card the brain reads — and never a secret.
+"""
+
+from __future__ import annotations
+
+import json
+from pathlib import Path
+from typing import Any
+
+import httpx
+import pytest
+from fastapi import FastAPI
+
+from jarvis.marketplace import catalog_data
+from jarvis.ui.web.marketplace_routes import router
+
+
+def _catalog(tmp_path: Path) -> Path:
+ seed = json.loads(catalog_data._PACKAGE_SEED_PATH.read_text(encoding="utf-8-sig"))
+ doc: dict[str, Any] = {
+ "version": seed["version"],
+ "schema_version": seed["schema_version"],
+ "plugins": [
+ {
+ "id": "todo-fox",
+ "display_name": "TodoFox",
+ "description": "Tasks and reminders from TodoFox",
+ "category": "Lists & Tasks",
+ "source": "local",
+ "logo_slug": "todoist",
+ "auth": {
+ "mode": "hosted_mcp_allowlist",
+ "mcp_url": "https://mcp.todofox.example/mcp",
+ },
+ "mcp_server": {
+ "command": "npx",
+ "args": ["-y", "todo-fox-mcp"],
+ "env": {"TODOFOX_TOKEN": "sk-live-very-secret", "TODOFOX_REF": "$TODOFOX"},
+ },
+ }
+ ],
+ }
+ path = tmp_path / "plugin_catalog.json"
+ path.write_text(json.dumps(doc), encoding="utf-8")
+ return path
+
+
+def catalog_env(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
+ monkeypatch.setattr(catalog_data, "_DEFAULT_CATALOG_PATH", _catalog(tmp_path))
+ catalog_data.clear_cache()
+ yield
+ catalog_data.clear_cache()
+
+
+def _client() -> httpx.AsyncClient:
+ app = FastAPI()
+ app.include_router(router)
+ return httpx.AsyncClient(transport=httpx.ASGITransport(app=app), base_url="http://test")
+
+
+async def test_plugin_files_list_manifest_and_masked_mcp_block(catalog_env: None) -> None:
+ async with _client() as client:
+ resp = await client.get("/api/marketplace/plugins/todo-fox/files")
+ assert resp.status_code == 200, resp.text
+ body = resp.json()
+ paths = [f["path"] for f in body["files"]]
+ assert paths[:2] == ["plugin.json", "mcp.json"]
+
+ manifest = json.loads(body["files"][0]["text"])
+ assert manifest["id"] == "todo-fox"
+ assert "mcp_server" not in manifest # it has its own file
+
+ mcp = json.loads(body["files"][1]["text"])
+ env = mcp["mcpServers"]["todo-fox"]["env"]
+ assert env["TODOFOX_REF"] == "$TODOFOX" # a credential-store reference is safe
+ assert "secret" not in env["TODOFOX_TOKEN"] # a literal is masked
+ assert "sk-live-very-secret" not in resp.text
+
+
+async def test_plugin_files_include_the_usage_card_when_one_ships(catalog_env: None) -> None:
+ # The seed catalog's GitHub plugin carries a usage card; the files route
+ # puts it next to the manifests so the owner can read what the brain reads.
+ catalog_data.clear_cache()
+ async with _client() as client:
+ resp = await client.get("/api/marketplace/plugins/github/files")
+ assert resp.status_code == 200, resp.text
+ paths = [f["path"] for f in resp.json()["files"]]
+ assert "plugin.json" in paths
+ assert "USAGE.md" in paths
+
+
+async def test_plugin_files_unknown_id_is_404(catalog_env: None) -> None:
+ async with _client() as client:
+ resp = await client.get("/api/marketplace/plugins/nope/files")
+ assert resp.status_code == 404
diff --git a/tests/unit/mcp/test_mcp_files_route.py b/tests/unit/mcp/test_mcp_files_route.py
new file mode 100644
index 0000000000..882760e855
--- /dev/null
+++ b/tests/unit/mcp/test_mcp_files_route.py
@@ -0,0 +1,104 @@
+"""The MCP detail page's file card: what defines one server, as readable files.
+
+``mcp.json`` is the user's own block for that server, ``definition.json`` the
+spec the registry runs. A built-in server that was never written to mcp.json
+still has a definition to read, and no secret ever appears in either file.
+"""
+
+from __future__ import annotations
+
+import json
+from pathlib import Path
+
+import httpx
+import pytest
+from fastapi import FastAPI
+
+from jarvis.mcp import state as mcp_state
+from jarvis.mcp.registry import MCPServerSpec
+from jarvis.ui.web.mcp_routes import router
+
+
+def mcp_json(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
+ path = tmp_path / "mcp.json"
+ monkeypatch.setenv("JARVIS_MCP_CONFIG", str(path))
+ path.write_text(
+ json.dumps(
+ {
+ "mcpServers": {
+ "notes-mcp": {
+ "command": "uvx",
+ "args": ["notes-mcp"],
+ "env": {"NOTES_TOKEN": "literal-secret-value", "NOTES_REF": "$NOTES"},
+ "enabled": True,
+ }
+ }
+ }
+ ),
+ encoding="utf-8",
+ )
+ return path
+
+
+def _client() -> httpx.AsyncClient:
+ app = FastAPI() # no registry on app.state — the route must still answer
+ app.include_router(router)
+ return httpx.AsyncClient(transport=httpx.ASGITransport(app=app), base_url="http://test")
+
+
+async def test_user_server_block_is_returned_with_env_literals_masked(mcp_json: Path) -> None:
+ async with _client() as client:
+ resp = await client.get("/api/mcps/notes-mcp/files")
+ assert resp.status_code == 200, resp.text
+ body = resp.json()
+ assert [f["path"] for f in body["files"]] == ["mcp.json"]
+ block = json.loads(body["files"][0]["text"])["mcpServers"]["notes-mcp"]
+ assert block["command"] == "uvx"
+ assert block["env"]["NOTES_REF"] == "$NOTES"
+ assert "literal-secret-value" not in resp.text
+ assert body["config_path"].endswith("mcp.json")
+
+
+class _FakeRegistry:
+ """Only what the route asks of a registry: the spec by name."""
+
+ def __init__(self, spec: MCPServerSpec) -> None:
+ self._spec = spec
+
+ def get_spec(self, name: str) -> MCPServerSpec | None:
+ return self._spec if name == self._spec.name else None
+
+
+async def test_registry_server_has_a_definition_even_without_an_mcp_json_entry(
+ mcp_json: Path,
+) -> None:
+ spec = MCPServerSpec(
+ name="files-mcp",
+ display="Files",
+ description="Read files.",
+ install_command=["uvx", "files-mcp"],
+ )
+ app = FastAPI()
+ app.state.mcp_registry = _FakeRegistry(spec)
+ app.include_router(router)
+ async with httpx.AsyncClient(
+ transport=httpx.ASGITransport(app=app), base_url="http://test"
+ ) as client:
+ resp = await client.get("/api/mcps/files-mcp/files")
+ assert resp.status_code == 200, resp.text
+ files = {f["path"]: f for f in resp.json()["files"]}
+ assert list(files) == ["definition.json"] # nothing of it in mcp.json yet
+ definition = json.loads(files["definition.json"]["text"])
+ assert definition["name"] == "files-mcp"
+ assert definition["install_command"] == ["uvx", "files-mcp"]
+
+
+async def test_unknown_server_is_404(mcp_json: Path) -> None:
+ assert mcp_state.get_server_entry("nope") is None
+ async with _client() as client:
+ resp = await client.get("/api/mcps/nope/files")
+ assert resp.status_code == 404