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): add fs_stat read capability and parity exemption

Abdurrahman Fakhrul8bed185d09d0
diff --git a/lib/mcp/parity.test.ts b/lib/mcp/parity.test.ts
index 081afe16..60d020c0 100644
--- a/lib/mcp/parity.test.ts
+++ b/lib/mcp/parity.test.ts
@@ -49,6 +49,7 @@ const MCP_ONLY: Record<string, string> = {
"project.mcp.call": "external MCP clients execute one exact dynamically-discovered project MCP tool under exec scope; Alfa can use its approved exec path and must not import project MCP catalogs",
"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",
"fs.export.file": "external MCP clients need an authenticated original-byte download bridge; in-shell Alfa already has direct host filesystem access",
+ "fs.stat": "external MCP clients need a true size/mtime without reading binary content",
"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",
diff --git a/lib/mcp/tools-read.ts b/lib/mcp/tools-read.ts
index dc5adfe7..9210e3e1 100644
--- a/lib/mcp/tools-read.ts
+++ b/lib/mcp/tools-read.ts
@@ -2,7 +2,7 @@ import { ownedArtifactSession } from "@/lib/agent/artifact-session";
import { saveSessionArtifact } from "@/lib/agent/artifacts";
import { artifactPaths } from "@/lib/agent/artifact-paths";
import path from "node:path";
-import { listDir, readFile, searchFs, usage, sha256Text, utf8Bytes } from "@/lib/host/fs-api";
+import { listDir, readFile, searchFs, usage, statReadableMeta, sha256Text, utf8Bytes } from "@/lib/host/fs-api";
import { stats, processes } from "@/lib/host/system-api";
import { captureMsoScreen } from "@/lib/host/screenshot-api";
import { createTempShare, tempShareUrl } from "@/lib/host/temp-share-api";
@@ -43,6 +43,17 @@ export const READ_TOOLS: McpTool[] = [
return { path: a.path, content, bytes: utf8Bytes(content), sha256: sha256Text(content) };
},
},
+ {
+ name: "fs_stat",
+ description:
+ "Get bounded metadata for a file or directory on the VPS (kind, true sizeBytes, mtimeMs, ctimeMs, mode). " +
+ "Use this for true file size or modification time without reading file contents or launching a shell. " +
+ "Reads are bounded to OS_FS_READ_ROOTS and credential paths (~/.ssh, ~/.mso, cloud tokens) are refused.",
+ scope: "read",
+ annotations: READ_ONLY,
+ inputSchema: S(PATH_P, ["path"]),
+ run: (a) => statReadableMeta(str(a, "path")),
+ },
{
name: "fs_search",
description:
@@ -121,7 +132,7 @@ export const READ_TOOLS: McpTool[] = [
"Semantic search across trusted SKILL.md files, the live MCP tool catalog and learned successful workflows. " +
"For MCP orientation, query mso-agent-bootstrap. Use this alone for capability research or unfamiliar single-step work. For a multi-step task call workflow_start directly — it already performs this search and avoids a duplicate startup call. " +
"The embedding runs locally with no API cost; untrusted skill instructions are excluded unless explicitly requested.",
- chatgptDescription: "Find mso-agent-bootstrap or research capabilities.",
+ chatgptDescription: "Find mso-agent-bootstrap",
scope: "read",
annotations: READ_ONLY,
inputSchema: S({
@@ -174,19 +185,13 @@ export const READ_TOOLS: McpTool[] = [
ttlMs: 15 * 60_000,
maxDownloads: 5,
});
- const previewUrl = tempShareUrl(share.id);
- const downloadUrl = tempShareUrl(share.id, true);
+ const previewUrl = tempShareUrl(share.id), downloadUrl = tempShareUrl(share.id, true);
+ const text = `MSO ${shot.shell} screenshot — ${shot.width}×${shot.height}\n` +
+ (artifactPath ? `Session artifact: ${artifactPath}\n` : "") +
+ `Temporary preview: ${previewUrl}\nDirect download: ${downloadUrl}\nExpires ${new Date(share.expiresAt).toISOString()} · ${share.downloadsLeft} authenticated downloads`;
return mcpDirect([
{ type: "image", data: shot.data, mimeType: shot.mimeType },
- {
- type: "text",
- text:
- `MSO ${shot.shell} screenshot — ${shot.width}×${shot.height}\n` +
- (artifactPath ? `Session artifact: ${artifactPath}\n` : "") +
- `Temporary preview: ${previewUrl}\n` +
- `Direct download: ${downloadUrl}\n` +
- `Expires ${new Date(share.expiresAt).toISOString()} · ${share.downloadsLeft} authenticated downloads`,
- },
+ { type: "text", text },
], false, {
result: { artifact, artifactPath, shell: shot.shell, width: shot.width, height: shot.height, mimeType: shot.mimeType, previewUrl, downloadUrl, expiresAt: share.expiresAt, downloadsLeft: share.downloadsLeft },
});