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.

3.8 KB
Raw Blame
export type McpClientId =
  | "chatgpt"
  | "codex"
  | "claude-code"
  | "cursor"
  | "gemini"
  | "antigravity"
  | "vscode"
  | "other";

export type McpEndpointSet = {
  origin: string;
  mcp: string;
  authorize: string;
  token: string;
  register: string;
  protectedResource: string;
  authorizationServer: string;
};

export type McpGuideStep = {
  title: string;
  body: string;
  copy?: { label: string; value: string; multiline?: boolean };
};

export type McpProbeCheckId = "server" | "https" | "mcp" | "challenge" | "resource" | "oauth" | "account" | "client-tools";
export type McpProbeCheckState = "passed" | "failed" | "unknown";
export type McpProbeCheck = {
  id: McpProbeCheckId;
  state: McpProbeCheckState;
  ok: boolean;
  detail: string;
  guidance?: string;
  httpStatus?: number;
};
export type McpProbeResult = {
  /** Readiness covers the observed server and discovery, not external client state. */
  ready: boolean;
  checks: McpProbeCheck[];
  observedOrigin: string;
  configuredOrigin: string;
  checkedAt: string;
};

export const MCP_CLIENTS: Array<{
  id: McpClientId;
  label: string;
  description: string;
  kind: "hosted" | "desktop" | "cli" | "editor" | "generic";
}> = [
  { id: "chatgpt", label: "ChatGPT", description: "Apps / Plugins with OAuth", kind: "hosted" },
  { id: "codex", label: "Codex", description: "CLI, desktop, and IDE", kind: "cli" },
  { id: "claude-code", label: "Claude Code", description: "Remote HTTP + browser OAuth", kind: "cli" },
  { id: "cursor", label: "Cursor", description: "Remote MCP in mcp.json", kind: "editor" },
  { id: "gemini", label: "Gemini CLI", description: "Remote HTTP server", kind: "cli" },
  { id: "antigravity", label: "Antigravity", description: "Google Antigravity MCP", kind: "cli" },
  { id: "vscode", label: "VS Code", description: "MCP: Add Server / mcp.json", kind: "editor" },
  { id: "other", label: "Other MCP", description: "Any Streamable HTTP client", kind: "generic" },
];

export const MCP_PROBE_LABELS: Record<McpProbeCheckId, string> = {
  server: "Server",
  https: "HTTPS to configured origin",
  account: "Selected AI app account",
  "client-tools": "AI app tool cache",
  mcp: "MCP endpoint",
  challenge: "OAuth challenge",
  resource: "Protected resource",
  oauth: "OAuth metadata",
};

export function mcpEndpoints(rawOrigin: string): McpEndpointSet {
  const origin = new URL(rawOrigin).origin;
  return {
    origin,
    mcp: `${origin}/mcp`,
    authorize: `${origin}/oauth/authorize`,
    token: `${origin}/oauth/token`,
    register: `${origin}/oauth/register`,
    protectedResource: `${origin}/.well-known/oauth-protected-resource`,
    authorizationServer: `${origin}/.well-known/oauth-authorization-server`,
  };
}

export function isRemoteMcpOrigin(rawOrigin: string): boolean {
  try {
    const url = new URL(rawOrigin);
    const host = url.hostname.toLowerCase();
    return url.protocol === "https:" && host !== "localhost" && host !== "::1" && host !== "[::1]" && !host.startsWith("127.");
  } catch {
    return false;
  }
}

export function cursorMcpConfig(rawOrigin: string): string {
  const { mcp } = mcpEndpoints(rawOrigin);
  return JSON.stringify({ mcpServers: { mso: { url: mcp } } }, null, 2);
}

export function vscodeMcpConfig(rawOrigin: string): string {
  const { mcp } = mcpEndpoints(rawOrigin);
  return JSON.stringify({ servers: { mso: { type: "http", url: mcp } } }, null, 2);
}

export function codexMcpConfig(rawOrigin: string): string {
  const { mcp } = mcpEndpoints(rawOrigin);
  return `[mcp_servers.mso]\nurl = "${mcp}"`;
}

export function antigravityMcpConfig(rawOrigin: string, token?: string): string {
  const { mcp } = mcpEndpoints(rawOrigin);
  return JSON.stringify({
    mso: {
      url: mcp,
      headers: {
        Authorization: `Bearer ${token || "<YOUR_PAT_TOKEN>"}`,
      },
    },
  }, null, 2);
}