Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

feat(mcp): render live workflow progress in ChatGPT

Abdurrahman Fakhrul98ea9d278f32
diff --git a/docs/integrations/CHATGPT-UI.md b/docs/integrations/CHATGPT-UI.md
new file mode 100644
index 00000000..53ad0291
--- /dev/null
+++ b/docs/integrations/CHATGPT-UI.md
@@ -0,0 +1,81 @@
+# ChatGPT MCP App UI
+
+MSO can render a first-party progress card inside ChatGPT instead of returning only tool-call text. The implementation follows the MCP Apps / OpenAI Apps SDK contract while keeping the existing JSON/text result as a backward-compatible fallback for MCP clients that do not render UI resources.
+
+## What ChatGPT needs
+
+A connector cannot create an inline card merely by returning HTML in a normal tool result. The MCP server must expose and connect four contracts:
+
+1. **UI resource** — `resources/list` and `resources/read` expose a `ui://…` resource with MIME type `text/html;profile=mcp-app`.
+2. **Tool → UI binding** — the tool descriptor points at that resource through `_meta.ui.resourceUri`. MSO also emits the compatibility alias `_meta["openai/outputTemplate"]`.
+3. **Structured result** — the tool declares `outputSchema` and returns matching `structuredContent`; `content` remains as the portable text fallback.
+4. **Widget bridge** — the sandboxed component reads `window.openai.toolOutput`, may call explicitly app-visible tools through `window.openai.callTool`, and can open the full MSO dashboard through `window.openai.openExternal`.
+
+Official references:
+
+- <https://developers.openai.com/plugins/build/chatgpt-ui>
+- <https://developers.openai.com/plugins/reference>
+
+## MSO implementation
+
+| Contract | MSO source |
+| --- | --- |
+| Progress UI resource | `lib/mcp/ui-resources.ts` |
+| Resource capability / RPC | `lib/mcp/dispatch.ts` |
+| Tool descriptor + structured schemas | `lib/mcp/tools-learning.ts` |
+| Shared tool schema type | `lib/mcp/tool-kit.ts` |
+| Toolset signature | `lib/mcp/toolset.ts` |
+| Tests | `lib/mcp/ui-resources.test.ts` |
+
+`workflow_start` is the model-visible entry point. Its result renders `ui://mso/workflow-progress-v1.html` when the host supports MCP Apps.
+
+The component then uses `workflow_status` to refresh the visible card. `workflow_status` is marked `ui.visibility: ["app"]` so it is a component bridge, not another model/operator action. Polling is deliberately excluded from MSO activity/workflow-step persistence; otherwise a four-second UI refresh would teach workflow memory a fake sequence made mostly of `workflow_status` calls.
+
+## Data boundary
+
+The progress component receives only:
+
+- workflow id;
+- intent and resolved project label;
+- started time / elapsed time;
+- step count;
+- recent tool name, outcome, timestamp, and duration.
+
+It does **not** receive tool arguments, shell commands, file contents, bearer tokens, API keys, credentials, or raw audit details. The existing workflow-memory redaction remains the authority for persisted workflow evidence.
+
+The component is self-contained: no external JavaScript, CSS, images, or direct API fetches are required. `Open in MSO` uses the host navigation bridge to `https://mso.rahmanef.com` instead of sharing an authenticated browser session with the iframe.
+
+## Dedicated UI origin
+
+For the current custom connector, MSO intentionally leaves `_meta.ui.domain` unset so ChatGPT uses its default sandbox origin. The main dashboard origin is not reused as the widget origin.
+
+Before submitting a UI-enabled MSO integration to the ChatGPT app directory, provision a dedicated HTTPS origin unique to the MSO widget and add that reviewed origin to `_meta.ui.domain` (plus the `openai/widgetDomain` compatibility alias if still required by the target client). Treat that as a release/submission configuration change rather than an arbitrary runtime environment knob.
+
+The dashboard navigation target is separate: `openai/widgetCSP.redirect_domains` allowlists `https://mso.rahmanef.com` solely for the **Open in MSO** action.
+
+## Expected ChatGPT flow
+
+```text
+ChatGPT
+ └─ tools/call workflow_start
+ ├─ content -> text fallback
+ ├─ structuredContent -> initial workflow state
+ └─ _meta.ui.resourceUri -> ui://mso/workflow-progress-v1.html
+ └─ ChatGPT renders sandboxed card
+ └─ callTool(workflow_status)
+ └─ structuredContent -> card refresh
+```
+
+For a client without MCP App support, nothing breaks: it keeps reading `content[0].text` exactly as before.
+
+## Deployment / refresh
+
+After merging this change:
+
+1. run the normal MSO verification pipeline (`bun run verify`);
+2. deploy through the normal MSO release path;
+3. reconnect or refresh the ChatGPT MSO connector so ChatGPT re-reads `initialize`, `tools/list`, and the resource capability;
+4. start a multi-step request that routes through `workflow_start`;
+5. verify that the card renders, recent steps advance without `workflow_status` appearing in the learned workflow, and **Open in MSO** opens the production dashboard.
+
+If ChatGPT still shows only JSON/text after deployment, inspect `tools/list` first. `workflow_start` must expose both `outputSchema` and `_meta.ui.resourceUri`, and `resources/read` for that URI must return `text/html;profile=mcp-app`. A stale connector schema is the next likely cause; refresh/reconnect it before changing the server implementation.
diff --git a/lib/mcp/dispatch.ts b/lib/mcp/dispatch.ts
index 4c020ee8..831a7f9d 100644
--- a/lib/mcp/dispatch.ts
+++ b/lib/mcp/dispatch.ts
@@ -5,12 +5,13 @@ import { allows, type Scope } from "./scope";
import { isMcpDirectResult } from "./tool-kit";
import { MCP_SERVER_VERSION, toolsetInfo } from "./toolset";
import { TOOLS, TOOLS_BY_NAME } from "./tools";
+import { listUiResources, readUiResource } from "./ui-resources";
export interface RpcRequest {
jsonrpc?: string;
id?: string | number | null;
method?: string;
- params?: { name?: string; arguments?: Record<string, unknown>; protocolVersion?: string };
+ params?: { name?: string; arguments?: Record<string, unknown>; protocolVersion?: string; uri?: string };
}
const PROTOCOL = "2024-11-05";
@@ -31,6 +32,7 @@ const toolList = (scope: Scope) => visibleTools(scope).map((tool) => ({
name: tool.name,
description: tool.description,
inputSchema: tool.inputSchema,
+ ...(tool.outputSchema ? { outputSchema: tool.outputSchema } : {}),
...(tool.annotations ? { annotations: tool.annotations } : {}),
...(tool.meta ? { _meta: tool.meta } : {}),
}));
@@ -60,6 +62,19 @@ function workflowFromResult(result: unknown): ActiveWorkflow | null {
: null;
}
+function structuredResult(toolName: string, result: unknown) {
+ const tool = TOOLS_BY_NAME.get(toolName);
+ const content = [{ type: "text" as const, text: typeof result === "string" ? result : JSON.stringify(result) }];
+ const structured = tool?.toStructuredContent
+ ? tool.toStructuredContent(result)
+ : result !== null && typeof result === "object" && !Array.isArray(result)
+ ? result as Record<string, unknown>
+ : undefined;
+ return tool?.outputSchema && structured
+ ? { structuredContent: structured, content }
+ : { content };
+}
+
export async function dispatch(req: RpcRequest, scope: Scope, actor?: string): Promise<Record<string, unknown>> {
const id = req.id ?? null;
switch (req.method) {
@@ -67,7 +82,7 @@ export async function dispatch(req: RpcRequest, scope: Scope, actor?: string): P
const toolset = toolsetInfo(visibleTools(scope), scope);
return ok(id, {
protocolVersion: req.params?.protocolVersion ?? PROTOCOL,
- capabilities: { tools: { listChanged: false } },
+ capabilities: { tools: { listChanged: false }, resources: { listChanged: false } },
serverInfo: { name: "mso", version: MCP_SERVER_VERSION },
instructions: instructions(scope),
_meta: { toolset },
@@ -80,11 +95,23 @@ export async function dispatch(req: RpcRequest, scope: Scope, actor?: string): P
const tools = visibleTools(scope);
return ok(id, { tools: toolList(scope), _meta: { toolset: toolsetInfo(tools, scope) } });
}
+ case "resources/list":
+ return ok(id, { resources: listUiResources() });
+ case "resources/read": {
+ const uri = String(req.params?.uri ?? "");
+ if (!uri) return fail(id, -32602, "resources/read needs { uri }");
+ const resource = readUiResource(uri);
+ if (!resource) return fail(id, -32602, `unknown resource: ${uri}`);
+ return ok(id, {
+ contents: [{ uri: resource.uri, mimeType: resource.mimeType, text: resource.text, _meta: resource._meta }],
+ });
+ }
case "tools/call": {
const name = String(req.params?.name ?? "");
const args = req.params?.arguments ?? {};
const tool = TOOLS_BY_NAME.get(name);
if (!tool) return fail(id, -32602, `unknown tool: ${name}`);
+ const workflowProbe = name === "workflow_status";
const requestedWorkflowId = typeof args.workflow_id === "string" && args.workflow_id ? args.workflow_id : undefined;
const lifecycle = name === "workflow_finish" || name === "workflow_cancel";
const activeWorkflow = requestedWorkflowId
@@ -95,8 +122,10 @@ export async function dispatch(req: RpcRequest, scope: Scope, actor?: string): P
void audit({ action: "mcp.denied", actor, target: name, ok: false, detail: `scope ${scope} < ${tool.scope}` });
const deniedId = newActivityId();
const target = activityTarget(args);
- void recordMcpActivity({ id: deniedId, actor, tool: name, state: "denied", scope, ...initialFlow, target, detail: `scope ${scope} < ${tool.scope}` });
- await recordWorkflowStep(actor, activeWorkflow?.id, { id: deniedId, tool: name, state: "denied", target, args, ts: new Date().toISOString() });
+ if (!workflowProbe) {
+ void recordMcpActivity({ id: deniedId, actor, tool: name, state: "denied", scope, ...initialFlow, target, detail: `scope ${scope} < ${tool.scope}` });
+ await recordWorkflowStep(actor, activeWorkflow?.id, { id: deniedId, tool: name, state: "denied", target, args, ts: new Date().toISOString() });
+ }
return ok(id, {
content: [{ type: "text", text: `error: this token holds scope "${scope}"; ${name} needs "${tool.scope}". Mint a new token in mso Settings → MCP.` }],
isError: true,
@@ -105,7 +134,7 @@ export async function dispatch(req: RpcRequest, scope: Scope, actor?: string): P
for (const key of tool.inputSchema.required ?? []) {
if (args[key] == null) return fail(id, -32602, `${name} needs { ${(tool.inputSchema.required ?? []).join(", ")} }`);
}
- if (requestedWorkflowId && !lifecycle && name !== "workflow_start" && name !== "skills_search" && !activeWorkflow) {
+ if (requestedWorkflowId && !lifecycle && !workflowProbe && name !== "workflow_start" && name !== "skills_search" && !activeWorkflow) {
const mismatchId = newActivityId();
const target = activityTarget(args);
const message = "workflow_id was not found for this MCP client";
@@ -121,8 +150,10 @@ export async function dispatch(req: RpcRequest, scope: Scope, actor?: string): P
void audit({ action: "mcp.denied", actor, target: name, ok: false, detail: "rate limited" });
const limitedId = newActivityId();
const target = activityTarget(args);
- void recordMcpActivity({ id: limitedId, actor, tool: name, state: "rate_limited", scope, ...initialFlow, target, detail: "rate limited" });
- await recordWorkflowStep(actor, activeWorkflow?.id, { id: limitedId, tool: name, state: "rate_limited", target, args, ts: new Date().toISOString() });
+ if (!workflowProbe) {
+ void recordMcpActivity({ id: limitedId, actor, tool: name, state: "rate_limited", scope, ...initialFlow, target, detail: "rate limited" });
+ await recordWorkflowStep(actor, activeWorkflow?.id, { id: limitedId, tool: name, state: "rate_limited", target, args, ts: new Date().toISOString() });
+ }
return ok(id, {
content: [{ type: "text", text: `error: ${name} is rate limited (${tool.limit.max} per ${Math.round(tool.limit.windowMs / 1000)}s). Wait and retry.` }],
isError: true,
@@ -135,7 +166,7 @@ export async function dispatch(req: RpcRequest, scope: Scope, actor?: string): P
const activityId = newActivityId();
const startedAt = Date.now();
const target = activityTarget(args);
- void recordMcpActivity({ id: activityId, actor, tool: name, state: "started", scope, ...initialFlow, target });
+ if (!workflowProbe) void recordMcpActivity({ id: activityId, actor, tool: name, state: "started", scope, ...initialFlow, target });
try {
const result = await tool.run(args, { actor, scope, workflowId: activeWorkflow?.id });
if (trail) {
@@ -144,16 +175,20 @@ export async function dispatch(req: RpcRequest, scope: Scope, actor?: string): P
}
const durationMs = Date.now() - startedAt;
const completedWorkflow = workflowFromResult(result) ?? activeWorkflow;
- void recordMcpActivity({ id: activityId, actor, tool: name, state: "completed", scope, ...flowFields(completedWorkflow), target, durationMs });
- await recordWorkflowStep(actor, completedWorkflow?.id, { id: activityId, tool: name, state: "completed", target, args, durationMs, ts: new Date().toISOString() });
+ if (!workflowProbe) {
+ void recordMcpActivity({ id: activityId, actor, tool: name, state: "completed", scope, ...flowFields(completedWorkflow), target, durationMs });
+ await recordWorkflowStep(actor, completedWorkflow?.id, { id: activityId, tool: name, state: "completed", target, args, durationMs, ts: new Date().toISOString() });
+ }
if (isMcpDirectResult(result)) return ok(id, { content: result.content, ...(result.isError ? { isError: true } : {}) });
- return ok(id, { content: [{ type: "text", text: typeof result === "string" ? result : JSON.stringify(result) }] });
+ return ok(id, structuredResult(name, result));
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
if (trail) void audit({ action: trail.action, actor, target: auditTarget, ok: false, detail: message.slice(0, 200), meta: { via: "mcp", scope } });
const durationMs = Date.now() - startedAt;
- void recordMcpActivity({ id: activityId, actor, tool: name, state: "failed", scope, ...initialFlow, target, durationMs, detail: message.slice(0, 220) });
- await recordWorkflowStep(actor, activeWorkflow?.id, { id: activityId, tool: name, state: "failed", target, args, durationMs, ts: new Date().toISOString() });
+ if (!workflowProbe) {
+ void recordMcpActivity({ id: activityId, actor, tool: name, state: "failed", scope, ...initialFlow, target, durationMs, detail: message.slice(0, 220) });
+ await recordWorkflowStep(actor, activeWorkflow?.id, { id: activityId, tool: name, state: "failed", target, args, durationMs, ts: new Date().toISOString() });
+ }
return ok(id, { content: [{ type: "text", text: "error: " + message.slice(0, 500) }], isError: true });
}
}
diff --git a/lib/mcp/parity.test.ts b/lib/mcp/parity.test.ts
index fd66ef08..4a8f3646 100644
--- a/lib/mcp/parity.test.ts
+++ b/lib/mcp/parity.test.ts
@@ -39,6 +39,7 @@ const MCP_ONLY: Record<string, string> = {
"project.function.call": "external MCP clients need one no-shell bridge into project-declared functions; Alfa already has per-call-approved exec.run and must not receive a dynamic per-project tool catalog",
"fs.upload.file": "external ChatGPT connectors need openai/fileParams to move conversation-generated files onto the VPS; in-shell Alfa already has direct host filesystem access",
"workflow.start": "the external connector needs an actor-scoped task boundary; Alfa already owns an in-app conversation/run boundary",
+ "workflow.status": "app-only MCP Apps bridge used by the ChatGPT progress component; Alfa already owns its in-shell run state and must not poll the external workflow store",
"workflow.cancel": "same actor-scoped boundary; external runs need explicit recovery from an interrupted task",
"workflow.finish": "same actor-scoped learning loop; Alfa recipes can use the session route later without weakening MCP scope semantics",
"exec.job.start": "external MCP requests have a hard request-time budget and need a bounded resumable shell job; in-shell Alfa can keep using its interactive Terminal/approved exec.run surfaces",
@@ -111,6 +112,9 @@ describe("MCP rate limits mirror the routes", () => {
// MCP clients and is expensive enough to deserve a much smaller bucket.
"screen.capture": 10,
"workflow.memory": 30,
+ // workflow_status is app-only polling. Keep its own bucket so UI refreshes
+ // neither consume lifecycle capacity nor bypass the server-wide token limit.
+ "workflow.status": 30,
"exec.job.start": 12,
"exec.job.status": 120,
"exec.job.cancel": 30,
diff --git a/lib/mcp/tool-kit.ts b/lib/mcp/tool-kit.ts
index c4141a66..7fd0f71f 100644
--- a/lib/mcp/tool-kit.ts
+++ b/lib/mcp/tool-kit.ts
@@ -8,7 +8,6 @@ import type { Scope } from "./scope";
// catastrophic-command filter in exec.ts. That is the whole reason this file is
// thin: a tool that reimplemented an operation would reimplement its guard too.
-
export type McpContent =
| { type: "text"; text: string }
| { type: "image"; data: string; mimeType: string };
@@ -38,8 +37,14 @@ export interface McpTool {
description: string;
scope: Scope;
inputSchema: { type: "object"; properties: Record<string, unknown>; required?: string[] };
+ /** MCP Apps structured output contract. */
+ outputSchema?: Record<string, unknown>;
+ /** Optional projection for the structured result. Use this to keep the portable
+ * text fallback backward compatible while exposing a smaller, explicitly safe
+ * object to a widget. */
+ toStructuredContent?: (result: unknown) => Record<string, unknown> | undefined;
annotations?: Record<string, boolean>;
- /** OpenAI Apps SDK metadata, including top-level file parameter binding. */
+ /** MCP Apps / OpenAI metadata: UI resource binding, visibility and file params. */
meta?: Record<string, unknown>;
run: (a: Record<string, unknown>, context: McpRunContext) => Promise<unknown>;
/** Which audit action this writes, and which argument names the target. Reads
diff --git a/lib/mcp/tools-learning.ts b/lib/mcp/tools-learning.ts
index 72650e72..8e489d3c 100644
--- a/lib/mcp/tools-learning.ts
+++ b/lib/mcp/tools-learning.ts
@@ -1,24 +1,120 @@
import { inspectProject, resolveProjectHint } from "@/lib/host";
-import { cancelWorkflow, finishWorkflow, markRecipeUsed, startWorkflow } from "@/lib/skills/memory";
+import { activeWorkflowForActor, cancelWorkflow, finishWorkflow, markRecipeUsed, startWorkflow } from "@/lib/skills/memory";
import { searchSkillMemory } from "@/lib/skills/search";
import { allows } from "./scope";
import { type McpTool, str, opt, S } from "./tool-kit";
import { toolsetInfo } from "./toolset";
+import { WORKFLOW_PROGRESS_URI } from "./ui-resources";
const visibleTools = async (scope: "read" | "write" | "exec"): Promise<McpTool[]> => {
const { TOOLS } = await import("./tools");
return TOOLS.filter((tool) => allows(scope, tool.scope));
};
+const WORKFLOW_PROGRESS_OUTPUT = {
+ type: "object",
+ properties: {
+ active: { type: "boolean" },
+ workflowId: { type: "string" },
+ intent: { type: "string" },
+ project: { type: "string" },
+ startedAt: { type: "string" },
+ elapsedMs: { type: "number" },
+ stepCount: { type: "number" },
+ steps: {
+ type: "array",
+ items: {
+ type: "object",
+ properties: {
+ tool: { type: "string" },
+ state: { type: "string", enum: ["completed", "failed", "denied", "rate_limited"] },
+ durationMs: { type: "number" },
+ ts: { type: "string" },
+ },
+ required: ["tool", "state", "ts"],
+ additionalProperties: false,
+ },
+ },
+ },
+ required: ["active", "workflowId", "stepCount", "steps"],
+ additionalProperties: false,
+} as const;
+
+type WorkflowProgressStep = {
+ tool: string;
+ state: "completed" | "failed" | "denied" | "rate_limited";
+ durationMs?: number;
+ ts: string;
+};
+
+function projectLabel(value: unknown): string | undefined {
+ if (typeof value !== "string" || !value.trim()) return undefined;
+ const normalized = value.trim().replace(/\\/g, "/").replace(/\/+$/, "");
+ const label = normalized.split("/").filter(Boolean).at(-1) ?? normalized;
+ return label.slice(0, 120) || undefined;
+}
+
+function workflowSteps(value: unknown): WorkflowProgressStep[] {
+ if (!Array.isArray(value)) return [];
+ const out: WorkflowProgressStep[] = [];
+ for (const candidate of value.slice(-8)) {
+ if (!candidate || typeof candidate !== "object") continue;
+ const step = candidate as Record<string, unknown>;
+ const state = step.state;
+ if (typeof step.tool !== "string" || typeof step.ts !== "string") continue;
+ if (state !== "completed" && state !== "failed" && state !== "denied" && state !== "rate_limited") continue;
+ out.push({
+ tool: step.tool.slice(0, 100),
+ state,
+ ...(typeof step.durationMs === "number" && Number.isFinite(step.durationMs)
+ ? { durationMs: Math.max(0, step.durationMs) }
+ : {}),
+ ts: step.ts,
+ });
+ }
+ return out;
+}
+
+function workflowProgress(value: unknown, active: boolean): Record<string, unknown> | undefined {
+ if (!value || typeof value !== "object") return undefined;
+ const workflow = value as Record<string, unknown>;
+ if (typeof workflow.id !== "string" || !workflow.id) return undefined;
+ const allSteps = Array.isArray(workflow.steps) ? workflow.steps : [];
+ const startedAt = typeof workflow.startedAt === "string" ? workflow.startedAt : undefined;
+ const started = startedAt ? Date.parse(startedAt) : Number.NaN;
+ const label = projectLabel(workflow.project);
+ return {
+ active,
+ workflowId: workflow.id,
+ ...(typeof workflow.intent === "string" && workflow.intent ? { intent: workflow.intent.slice(0, 1000) } : {}),
+ ...(label ? { project: label } : {}),
+ ...(startedAt ? { startedAt } : {}),
+ ...(Number.isFinite(started) ? { elapsedMs: Math.max(0, Date.now() - started) } : {}),
+ stepCount: allSteps.length,
+ steps: workflowSteps(allSteps),
+ };
+}
+
export const LEARNING_TOOLS: McpTool[] = [
{
name: "workflow_start",
description:
"The ONE startup call for a multi-step task. It starts the workflow, searches trusted skills and prior recipes, " +
"resolves project aliases, reports the current toolset/version, and inspects repository context when available. " +
- "Do not call skills_search first for the same task; this already includes it. Multiple conversations may start isolated workflows on the same token; correlate every later step with the returned workflow_id.",
+ "Do not call skills_search first for the same task; this already includes it. Multiple conversations may start isolated workflows on one token; correlate every later step with the returned workflow_id.",
scope: "write",
annotations: { idempotentHint: false },
+ outputSchema: WORKFLOW_PROGRESS_OUTPUT,
+ toStructuredContent: (result) => {
+ if (!result || typeof result !== "object") return undefined;
+ return workflowProgress((result as { workflow?: unknown }).workflow, true);
+ },
+ meta: {
+ ui: { resourceUri: WORKFLOW_PROGRESS_URI, visibility: ["model", "app"] },
+ "openai/outputTemplate": WORKFLOW_PROGRESS_URI,
+ "openai/toolInvocation/invoking": "Starting MSO workflow…",
+ "openai/toolInvocation/invoked": "MSO workflow ready",
+ },
limit: { key: "workflow.memory", max: 30, windowMs: 60_000 },
audit: { action: "workflow.start" as const, targetArg: "project" },
inputSchema: S({
@@ -34,8 +130,8 @@ export const LEARNING_TOOLS: McpTool[] = [
const project = projectHint ? await resolveProjectHint(projectHint).catch(() => null) : null;
const tools = await visibleTools(context.scope);
// Complete every fallible read-only preflight before allocating the run id.
- // A failed skill scan or repo inspection must not
- // leave a run the client never received an id for and therefore cannot close.
+ // A failed skill scan or repo inspection must not leave a run the client never
+ // received an id for and therefore cannot close.
const search = await searchSkillMemory(intent, {
topK: 8,
recipeAccess: { actor, scope: context.scope },
@@ -92,6 +188,30 @@ export const LEARNING_TOOLS: McpTool[] = [
};
},
},
+ {
+ name: "workflow_status",
+ description:
+ "Return a redacted live status snapshot for one workflow. This tool exists for the MSO ChatGPT progress widget: it exposes only workflow identity, timing and high-level tool outcomes, never tool arguments, command strings, file contents or credentials.",
+ scope: "read",
+ annotations: { readOnlyHint: true, idempotentHint: true },
+ outputSchema: WORKFLOW_PROGRESS_OUTPUT,
+ meta: {
+ ui: { visibility: ["app"] },
+ "openai/widgetAccessible": true,
+ },
+ limit: { key: "workflow.status", max: 30, windowMs: 60_000 },
+ inputSchema: S({
+ workflow_id: { type: "string", description: "Exact id returned by workflow_start." },
+ }),
+ run: async (a, context) => {
+ const workflowId = str(a, "workflow_id");
+ const workflow = await activeWorkflowForActor(context.actor, workflowId);
+ if (!workflow) {
+ return { active: false, workflowId, stepCount: 0, steps: [] };
+ }
+ return workflowProgress(workflow, true)!;
+ },
+ },
{
name: "workflow_cancel",
description:
diff --git a/lib/mcp/toolset.ts b/lib/mcp/toolset.ts
index c8f94474..2c470d5f 100644
--- a/lib/mcp/toolset.ts
+++ b/lib/mcp/toolset.ts
@@ -4,7 +4,7 @@ import type { McpTool } from "./tool-kit";
export const MCP_SERVER_VERSION = "1.6.0";
export const MCP_TOOLSET_VERSION = "2026.08.31.1";
-export const MCP_TOOLSET_CHANGED_AT = "2026-08-31T16:36:00Z";
+export const MCP_TOOLSET_CHANGED_AT = "2026-09-01T07:55:00Z";
export type McpToolsetInfo = {
serverVersion: string;
@@ -24,6 +24,7 @@ export function toolsetInfo(tools: readonly McpTool[], scope?: Scope): McpToolse
description: tool.description,
scope: tool.scope,
inputSchema: tool.inputSchema,
+ outputSchema: tool.outputSchema,
annotations: tool.annotations,
meta: tool.meta,
limit: tool.limit,
diff --git a/lib/mcp/ui-resources.test.ts b/lib/mcp/ui-resources.test.ts
new file mode 100644
index 00000000..7016fc52
--- /dev/null
+++ b/lib/mcp/ui-resources.test.ts
@@ -0,0 +1,113 @@
+import { describe, expect, it, vi } from "vitest";
+
+vi.mock("server-only", () => ({}));
+
+const { dispatch } = await import("./dispatch");
+const { MCP_APP_MIME_TYPE, WORKFLOW_PROGRESS_URI } = await import("./ui-resources");
+const { activeWorkflowForActor } = await import("@/lib/skills/memory");
+
+const call = (name: string, args: Record<string, unknown> = {}) =>
+ ({ jsonrpc: "2.0", id: 1, method: "tools/call", params: { name, arguments: args } });
+
+describe("MCP Apps workflow progress UI", () => {
+ it("advertises resources and binds workflow_start to the progress resource", async () => {
+ const initialized = await dispatch({ id: 1, method: "initialize" }, "write", "mcp:ui-init");
+ expect(initialized.result).toMatchObject({
+ capabilities: { tools: { listChanged: false }, resources: { listChanged: false } },
+ });
+
+ const listed = await dispatch({ id: 2, method: "tools/list" }, "write", "mcp:ui-list");
+ const tools = (listed.result as {
+ tools: Array<{ name: string; outputSchema?: unknown; _meta?: Record<string, unknown> }>;
+ }).tools;
+ const start = tools.find((tool) => tool.name === "workflow_start");
+ expect(start?.outputSchema).toBeDefined();
+ expect(start?._meta).toMatchObject({
+ ui: { resourceUri: WORKFLOW_PROGRESS_URI, visibility: ["model", "app"] },
+ "openai/outputTemplate": WORKFLOW_PROGRESS_URI,
+ });
+
+ const status = tools.find((tool) => tool.name === "workflow_status");
+ expect(status?.outputSchema).toBeDefined();
+ expect(status?._meta).toMatchObject({
+ ui: { visibility: ["app"] },
+ "openai/widgetAccessible": true,
+ });
+ });
+
+ it("serves one self-contained mcp-app resource", async () => {
+ const listed = await dispatch({ id: 1, method: "resources/list" }, "read", "mcp:ui-resource");
+ expect(listed.result).toMatchObject({
+ resources: [expect.objectContaining({ uri: WORKFLOW_PROGRESS_URI, mimeType: MCP_APP_MIME_TYPE })],
+ });
+
+ const read = await dispatch({ id: 2, method: "resources/read", params: { uri: WORKFLOW_PROGRESS_URI } }, "read", "mcp:ui-resource");
+ const content = (read.result as {
+ contents: Array<{ uri: string; mimeType: string; text: string; _meta: Record<string, unknown> }>;
+ }).contents[0];
+ expect(content.uri).toBe(WORKFLOW_PROGRESS_URI);
+ expect(content.mimeType).toBe(MCP_APP_MIME_TYPE);
+ expect(content.text).toContain("workflow_status");
+ expect(content.text).toContain("Open in MSO");
+ expect(content.text).not.toContain("fetch(");
+ expect(content._meta).toMatchObject({
+ ui: { prefersBorder: true },
+ "openai/widgetPrefersBorder": true,
+ });
+ });
+
+ it("returns only redacted structured workflow state and keeps polling out of workflow memory", async () => {
+ const actor = `mcp:ui-status-${Date.now()}`;
+ const projectHint = "/private/operator/projects/mso";
+ const started = await dispatch(call("workflow_start", {
+ intent: "verify the ChatGPT progress widget",
+ project: projectHint,
+ constraints: "never expose secret-token=example in the widget",
+ }), "write", actor);
+ const startResult = started.result as {
+ structuredContent?: {
+ active: boolean;
+ workflowId?: string;
+ project?: string;
+ stepCount: number;
+ steps: Array<{ tool: string }>;
+ [key: string]: unknown;
+ };
+ content: Array<{ text: string }>;
+ };
+ const workflowId = startResult.structuredContent?.workflowId;
+ expect(workflowId).toBeTruthy();
+ expect(startResult.structuredContent).toMatchObject({ active: true, workflowId, project: "mso" });
+ expect(startResult.structuredContent).not.toHaveProperty("bootstrap");
+ expect(startResult.structuredContent).not.toHaveProperty("search");
+ expect(JSON.stringify(startResult.structuredContent)).not.toContain(projectHint);
+ expect(JSON.stringify(startResult.structuredContent)).not.toContain("secret-token");
+
+ // The portable text fallback intentionally keeps the pre-existing result shape
+ // for MCP clients that do not render Apps UI.
+ expect(JSON.parse(startResult.content[0].text).workflow.id).toBe(workflowId);
+
+ const before = await activeWorkflowForActor(actor, workflowId!);
+ expect(before).not.toBeNull();
+
+ const statusCall = await dispatch(call("workflow_status", { workflow_id: workflowId }), "write", actor);
+ const status = statusCall.result as {
+ structuredContent?: { active: boolean; workflowId: string; project?: string; stepCount: number; steps: Array<{ tool: string }> };
+ };
+ expect(status.structuredContent).toMatchObject({ active: true, workflowId, project: "mso" });
+ expect(status.structuredContent?.steps.some((step) => step.tool === "workflow_status")).toBe(false);
+ expect(JSON.stringify(status.structuredContent)).not.toContain(projectHint);
+
+ const after = await activeWorkflowForActor(actor, workflowId!);
+ expect(after?.steps).toHaveLength(before!.steps.length);
+
+ await dispatch(call("workflow_cancel", { workflow_id: workflowId, reason: "test cleanup" }), "write", actor);
+ const closed = await dispatch(call("workflow_status", { workflow_id: workflowId }), "write", actor);
+ expect((closed.result as { structuredContent?: { active: boolean } }).structuredContent?.active).toBe(false);
+ });
+
+ it("rejects unknown UI resource URIs", async () => {
+ const result = await dispatch({ id: 1, method: "resources/read", params: { uri: "ui://mso/not-real.html" } }, "read");
+ expect(result.error).toMatchObject({ code: -32602 });
+ });
+});
diff --git a/lib/mcp/ui-resources.ts b/lib/mcp/ui-resources.ts
new file mode 100644
index 00000000..79bea1cc
--- /dev/null
+++ b/lib/mcp/ui-resources.ts
@@ -0,0 +1,249 @@
+export const WORKFLOW_PROGRESS_URI = "ui://mso/workflow-progress-v1.html";
+export const MCP_APP_MIME_TYPE = "text/html;profile=mcp-app";
+const MSO_ORIGIN = "https://mso.rahmanef.com";
+
+const workflowProgressHtml = String.raw`<main class="mso-workflow" aria-live="polite">
+ <style>
+ :root { color-scheme: light dark; font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
+ * { box-sizing: border-box; }
+ body { margin: 0; background: transparent; color: CanvasText; }
+ .mso-workflow { min-width: 0; padding: 14px; }
+ .card { border: 1px solid color-mix(in srgb, CanvasText 16%, transparent); border-radius: 18px; background: color-mix(in srgb, Canvas 94%, transparent); overflow: hidden; }
+ .head { display: flex; gap: 12px; align-items: flex-start; padding: 14px 14px 10px; }
+ .mark { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; border-radius: 10px; background: color-mix(in srgb, #7c3aed 18%, Canvas); font-weight: 800; }
+ .title { min-width: 0; flex: 1; }
+ h2 { margin: 0; font-size: 15px; line-height: 1.3; }
+ .intent { margin: 4px 0 0; color: color-mix(in srgb, CanvasText 67%, transparent); font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
+ .status { flex: 0 0 auto; border-radius: 999px; padding: 4px 8px; font-size: 10px; font-weight: 750; letter-spacing: .07em; border: 1px solid color-mix(in srgb, CanvasText 16%, transparent); }
+ .status.active { background: color-mix(in srgb, #22c55e 12%, Canvas); }
+ .status.closed { background: color-mix(in srgb, CanvasText 7%, Canvas); }
+ .meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: color-mix(in srgb, CanvasText 10%, transparent); border-block: 1px solid color-mix(in srgb, CanvasText 10%, transparent); }
+ .metric { min-width: 0; background: Canvas; padding: 9px 11px; }
+ .metric span { display: block; color: color-mix(in srgb, CanvasText 55%, transparent); font-size: 9px; text-transform: uppercase; letter-spacing: .09em; }
+ .metric strong { display: block; margin-top: 2px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+ .steps { padding: 10px 14px 8px; }
+ .steps-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
+ .steps-head strong { font-size: 11px; }
+ .steps-head span { color: color-mix(in srgb, CanvasText 52%, transparent); font-size: 10px; }
+ ol { list-style: none; margin: 0; padding: 0; }
+ li { display: grid; grid-template-columns: 9px minmax(0, 1fr) auto; align-items: center; gap: 8px; min-height: 29px; border-top: 1px solid color-mix(in srgb, CanvasText 8%, transparent); font-size: 11px; }
+ li:first-child { border-top: 0; }
+ .dot { width: 7px; height: 7px; border-radius: 50%; background: color-mix(in srgb, CanvasText 35%, transparent); }
+ .dot.completed { background: #22c55e; }
+ .dot.failed, .dot.denied, .dot.rate_limited { background: #ef4444; }
+ .tool { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
+ .duration { color: color-mix(in srgb, CanvasText 50%, transparent); font-variant-numeric: tabular-nums; }
+ .empty { padding: 8px 0 10px; color: color-mix(in srgb, CanvasText 52%, transparent); font-size: 11px; }
+ .foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px 10px 14px; }
+ .connection { color: color-mix(in srgb, CanvasText 52%, transparent); font-size: 10px; }
+ .actions { display: flex; gap: 6px; }
+ button { appearance: none; border: 1px solid color-mix(in srgb, CanvasText 16%, transparent); background: color-mix(in srgb, CanvasText 6%, Canvas); color: CanvasText; border-radius: 10px; padding: 7px 10px; min-height: 32px; font: inherit; font-size: 11px; font-weight: 650; cursor: pointer; }
+ button.primary { background: color-mix(in srgb, #7c3aed 17%, Canvas); }
+ button:focus-visible { outline: 2px solid Highlight; outline-offset: 2px; }
+ @media (max-width: 440px) { .mso-workflow { padding: 8px; } .head { padding: 11px 11px 8px; } .meta { grid-template-columns: 1fr 1fr; } .metric.project { grid-column: 1 / -1; } .foot { align-items: flex-end; } }
+ </style>
+ <section class="card" aria-label="MSO workflow progress">
+ <div class="head">
+ <div class="mark" aria-hidden="true">M</div>
+ <div class="title"><h2>MSO workflow</h2><p class="intent" id="intent">Preparing workflow…</p></div>
+ <span class="status active" id="state">ACTIVE</span>
+ </div>
+ <div class="meta">
+ <div class="metric project"><span>Project</span><strong id="project">—</strong></div>
+ <div class="metric"><span>Elapsed</span><strong id="elapsed">0s</strong></div>
+ <div class="metric"><span>Steps</span><strong id="count">0</strong></div>
+ </div>
+ <div class="steps">
+ <div class="steps-head"><strong>Recent progress</strong><span id="updated">waiting</span></div>
+ <ol id="step-list"></ol><div class="empty" id="empty">Workflow initialized. Tool progress will appear here.</div>
+ </div>
+ <div class="foot">
+ <span class="connection" id="connection">Live status</span>
+ <div class="actions"><button type="button" id="refresh">Refresh</button><button class="primary" type="button" id="open">Open in MSO ↗</button></div>
+ </div>
+ </section>
+ <script>
+ (() => {
+ const MSO_URL = "https://mso.rahmanef.com";
+ const stateEl = document.getElementById("state");
+ const intentEl = document.getElementById("intent");
+ const projectEl = document.getElementById("project");
+ const elapsedEl = document.getElementById("elapsed");
+ const countEl = document.getElementById("count");
+ const listEl = document.getElementById("step-list");
+ const emptyEl = document.getElementById("empty");
+ const updatedEl = document.getElementById("updated");
+ const connectionEl = document.getElementById("connection");
+ const refreshButton = document.getElementById("refresh");
+ const openButton = document.getElementById("open");
+ let workflowId = "";
+ let startedAt = "";
+ let active = true;
+ let timer = 0;
+ const pending = new Map();
+ let nextRequestId = 1;
+
+ function safeText(value, fallback = "—") {
+ return typeof value === "string" && value.trim() ? value.trim() : fallback;
+ }
+ function formatDuration(ms) {
+ const total = Math.max(0, Math.floor(Number(ms) || 0));
+ if (total < 1000) return total + "ms";
+ const seconds = Math.floor(total / 1000);
+ if (seconds < 60) return seconds + "s";
+ const minutes = Math.floor(seconds / 60);
+ return minutes + "m " + (seconds % 60) + "s";
+ }
+ function elapsedMs() {
+ const parsed = Date.parse(startedAt);
+ return Number.isFinite(parsed) ? Math.max(0, Date.now() - parsed) : 0;
+ }
+ function render(data) {
+ if (!data || typeof data !== "object") return;
+ const workflow = data.workflow && typeof data.workflow === "object" ? data.workflow : data;
+ workflowId = safeText(workflow.workflowId || workflow.id || data.workflowId, workflowId);
+ startedAt = safeText(workflow.startedAt || data.startedAt, startedAt);
+ if (typeof data.active === "boolean") active = data.active;
+ intentEl.textContent = safeText(workflow.intent || data.intent, "Workflow initialized");
+ const bootstrapProject = data.bootstrap && data.bootstrap.project && typeof data.bootstrap.project === "object" ? (data.bootstrap.project.path || data.bootstrap.project.hint) : "";
+ projectEl.textContent = safeText(workflow.project || data.project || bootstrapProject, "Not specified");
+ const steps = Array.isArray(data.steps) ? data.steps : (Array.isArray(workflow.steps) ? workflow.steps : []);
+ countEl.textContent = String(Number.isFinite(data.stepCount) ? data.stepCount : steps.length);
+ stateEl.textContent = active ? "ACTIVE" : "CLOSED";
+ stateEl.className = "status " + (active ? "active" : "closed");
+ listEl.textContent = "";
+ const recent = steps.slice(-7).reverse();
+ emptyEl.hidden = recent.length > 0;
+ for (const step of recent) {
+ const li = document.createElement("li");
+ const dot = document.createElement("span");
+ dot.className = "dot " + safeText(step.state, "completed");
+ const tool = document.createElement("span");
+ tool.className = "tool";
+ tool.textContent = safeText(step.tool, "tool");
+ const duration = document.createElement("span");
+ duration.className = "duration";
+ duration.textContent = step.durationMs == null ? safeText(step.state, "") : formatDuration(step.durationMs);
+ li.append(dot, tool, duration);
+ listEl.append(li);
+ }
+ updatedEl.textContent = "updated now";
+ elapsedEl.textContent = formatDuration(Number(data.elapsedMs) || elapsedMs());
+ if (!active) stopPolling();
+ }
+ function postMessageCall(name, args) {
+ const id = nextRequestId++;
+ window.parent.postMessage({ jsonrpc: "2.0", id, method: "tools/call", params: { name, arguments: args } }, "*");
+ return new Promise((resolve, reject) => {
+ pending.set(id, { resolve, reject });
+ window.setTimeout(() => {
+ const request = pending.get(id);
+ if (!request) return;
+ pending.delete(id);
+ reject(new Error("status timeout"));
+ }, 8000);
+ });
+ }
+ async function callStatus() {
+ if (!workflowId || !active || document.visibilityState === "hidden") return;
+ refreshButton.disabled = true;
+ try {
+ const result = window.openai && typeof window.openai.callTool === "function"
+ ? await window.openai.callTool("workflow_status", { workflow_id: workflowId })
+ : await postMessageCall("workflow_status", { workflow_id: workflowId });
+ const payload = result && result.structuredContent ? result.structuredContent : result;
+ render(payload);
+ connectionEl.textContent = active ? "Live status" : "Workflow closed";
+ } catch (_) {
+ connectionEl.textContent = "Status refresh unavailable";
+ } finally {
+ refreshButton.disabled = false;
+ }
+ }
+ function startPolling() {
+ stopPolling();
+ if (!active) return;
+ timer = window.setInterval(callStatus, 4000);
+ }
+ function stopPolling() {
+ if (timer) window.clearInterval(timer);
+ timer = 0;
+ }
+ function readHostOutput() {
+ const output = window.openai && window.openai.toolOutput;
+ if (output) render(output);
+ }
+ window.addEventListener("message", (event) => {
+ if (event.source !== window.parent) return;
+ const message = event.data;
+ if (!message || message.jsonrpc !== "2.0") return;
+ if (message.id !== undefined && pending.has(message.id)) {
+ const request = pending.get(message.id);
+ pending.delete(message.id);
+ if (message.error) request.reject(message.error); else request.resolve(message.result);
+ return;
+ }
+ if (message.method === "ui/notifications/tool-result" && message.params && message.params.structuredContent) {
+ render(message.params.structuredContent);
+ }
+ }, { passive: true });
+ window.addEventListener("openai:set_globals", readHostOutput, { passive: true });
+ refreshButton.addEventListener("click", callStatus);
+ openButton.addEventListener("click", async () => {
+ if (window.openai && typeof window.openai.openExternal === "function") {
+ await window.openai.openExternal({ href: MSO_URL, redirectUrl: false });
+ } else {
+ window.open(MSO_URL, "_blank", "noopener,noreferrer");
+ }
+ });
+ const clock = window.setInterval(() => { elapsedEl.textContent = formatDuration(elapsedMs()); }, 1000);
+ window.addEventListener("pagehide", () => { stopPolling(); window.clearInterval(clock); }, { once: true });
+ readHostOutput();
+ startPolling();
+ })();
+ </script>
+</main>`;
+
+export type McpUiResource = {
+ uri: string;
+ name: string;
+ description: string;
+ mimeType: string;
+ text: string;
+ _meta: Record<string, unknown>;
+};
+
+function workflowResourceMeta(): Record<string, unknown> {
+ return {
+ ui: {
+ prefersBorder: true,
+ csp: { connectDomains: [], resourceDomains: [] },
+ },
+ "openai/widgetDescription": "Authoritative MSO workflow progress card. It shows only high-level workflow state and recent tool outcomes; do not repeat the card contents verbatim.",
+ "openai/widgetPrefersBorder": true,
+ "openai/widgetCSP": {
+ connect_domains: [],
+ resource_domains: [],
+ redirect_domains: [MSO_ORIGIN],
+ },
+ };
+}
+
+const RESOURCES: readonly McpUiResource[] = [
+ {
+ uri: WORKFLOW_PROGRESS_URI,
+ name: "MSO workflow progress",
+ description: "Compact live progress for an authenticated MSO workflow.",
+ mimeType: MCP_APP_MIME_TYPE,
+ text: workflowProgressHtml,
+ _meta: workflowResourceMeta(),
+ },
+];
+
+export function listUiResources() {
+ return RESOURCES.map(({ uri, name, description, mimeType }) => ({ uri, name, description, mimeType }));
+}
+
+export function readUiResource(uri: string): McpUiResource | undefined {
+ return RESOURCES.find((resource) => resource.uri === uri);
+}
diff --git a/scripts/check-docs.mjs b/scripts/check-docs.mjs
index 7ee2c459..bec00801 100755
--- a/scripts/check-docs.mjs
+++ b/scripts/check-docs.mjs
@@ -28,15 +28,27 @@ for (const file of toolFiles) {
const matches = text.matchAll(/name:\s*"([^"]+)"[\s\S]*?scope:\s*"(read|write|exec)"/g);
for (const [, name, scope] of matches) tools.set(name, scope);
}
+
+// App-only MCP bridge tools are intentionally absent from the model/operator action
+// catalogs. They must be documented in the MCP App UI guide instead. Keep this list
+// tiny and explicit: adding a hidden bridge should be a conscious review decision.
+const appOnlyTools = new Set(["workflow_status"]);
+const documentedTools = new Map([...tools].filter(([name]) => !appOnlyTools.has(name)));
+const appUiDoc = read("docs/integrations/CHATGPT-UI.md");
+for (const name of appOnlyTools) {
+ if (!tools.has(name)) fail.push(`app-only MCP tool ${name} is no longer in the source catalog`);
+ if (!appUiDoc.includes(`\`${name}\``)) fail.push(`docs/integrations/CHATGPT-UI.md: app-only MCP tool ${name} is not documented`);
+}
+
const counts = { read: 0, write: 0, exec: 0 };
-for (const scope of tools.values()) counts[scope] += 1;
-const marker = `server=${server} version=${version} tools=${tools.size} read=${counts.read} write=${counts.write} exec=${counts.exec}`;
+for (const scope of documentedTools.values()) counts[scope] += 1;
+const marker = `server=${server} version=${version} tools=${documentedTools.size} read=${counts.read} write=${counts.write} exec=${counts.exec}`;
for (const file of ["docs/MCP.md", "docs/CHATGPT-PLUGIN.md", "docs/CONNECTORS-GATEWAY-INTEGRATION.md"]) {
const text = read(file);
if (!text.includes(`<!-- mcp-toolset: ${marker} -->`)) {
fail.push(`${file}: MCP marker stale; expected ${marker}`);
}
- for (const name of tools.keys()) {
+ for (const name of documentedTools.keys()) {
if (!text.includes(`\`${name}\``)) fail.push(`${file}: MCP tool ${name} is not documented`);
}
}
@@ -110,4 +122,4 @@ if (fail.length) {
for (const item of fail) console.error(`- ${item}`);
process.exit(1);
}
-console.log(`docs: current — ${markdown.length} markdown files, ${tools.size} MCP tools, ${sliceCount} slices, ${featureCount} AppShell feature dirs`);
+console.log(`docs: current — ${markdown.length} markdown files, ${documentedTools.size} model MCP tools + ${appOnlyTools.size} app-only bridge, ${sliceCount} slices, ${featureCount} AppShell feature dirs`);
diff --git a/scripts/mso-cli-agent.sh b/scripts/mso-cli-agent.sh
index d2d2bbec..1ba7583d 100755
--- a/scripts/mso-cli-agent.sh
+++ b/scripts/mso-cli-agent.sh
@@ -49,6 +49,8 @@ run_provider() {
list)
provider_metadata | jq -r '.providers[] | "\(if .configured then "✓" else "·" end) \(.id)\t\(if .configured then "configured" else "missing: " + (.missing|join(", ")) end)\t\(.description)"' ;;
show)
+ # U_provider is the shared usage string defined by bin/mso before this slice is sourced.
+ # shellcheck disable=SC2154
[ -n "$id" ] || die "usage: mso $U_provider"
provider_metadata | jq --arg id "$id" '.providers[] | select(.id==$id)' ;;
projects|dokploy-projects)
@@ -60,10 +62,12 @@ run_provider() {
if [ -n "$id" ]; then body=$(jq -nc --arg id "$id" '{id:$id}'); else body='{}'; fi
jpost "/api/v1/infra/providers/doctor" "$body" | jq -r '.results[] | "\(if .ok == true then "✓" elif .ok == false then "✗" else "·" end) \(.id) — \(.detail)"' ;;
rm|remove)
+ # shellcheck disable=SC2154
[ -n "$id" ] || die "usage: mso $U_provider"
jdel "/api/v1/infra/providers?id=$(enc "$id")" >/dev/null
echo "removed infrastructure provider: $id" ;;
set)
+ # shellcheck disable=SC2154
[ -n "$id" ] || die "usage: mso $U_provider"
tty_ok || die "provider setup needs a terminal because API tokens are entered with hidden input"
data=$(provider_metadata)
@@ -100,7 +104,9 @@ process.stdout.write(JSON.stringify({ id, values }));
unset body
echo " ✓ $id configured"
jpost "/api/v1/infra/providers/doctor" "$(jq -nc --arg id "$id" '{id:$id}')" | jq -r '.results[] | " \(if .ok == true then "✓" elif .ok == false then "✗" else "·" end) \(.detail)"' ;;
- *) die "usage: mso $U_provider" ;;
+ *)
+ # shellcheck disable=SC2154
+ die "usage: mso $U_provider" ;;
esac
}