Add inter-sandbox chat MCP server

This commit is contained in:
mmckeen-nv
2026-04-30 08:24:11 -07:00
parent 3ff1a664d7
commit acf4c05aeb
6 changed files with 243 additions and 6 deletions
+20 -5
View File
@@ -64,6 +64,16 @@ export const MCP_SERVER_CATALOG: McpCatalogEntry[] = [
env: {},
tags: ["state", "local"],
},
{
id: "inter-sandbox-chat",
name: "Inter-Sandbox Chat",
summary: "Give allowed sandboxes a shared roomed message board so agents can post updates and read messages from each other through the MCP broker.",
transport: "stdio",
command: "node",
args: [path.join(process.cwd(), "scripts/inter-sandbox-chat-mcp.mjs")],
env: {},
tags: ["chat", "collaboration", "sandbox"],
},
{
id: "git",
name: "Git",
@@ -118,6 +128,10 @@ function normalizeTransport(value: unknown): McpTransport {
return value === "http" ? "http" : "stdio"
}
function withoutUndefined<T extends Record<string, unknown>>(input: T): Partial<T> {
return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== undefined)) as Partial<T>
}
function normalizeInstall(input: Partial<McpServerInstall>, existing?: McpServerInstall | null): McpServerInstall {
const name = typeof input.name === "string" && input.name.trim() ? input.name.trim() : existing?.name || "MCP Server"
const id = slugify(typeof input.id === "string" && input.id.trim() ? input.id : existing?.id || name)
@@ -224,16 +238,17 @@ export async function listMcpServers() {
export async function installMcpServer(input: Partial<McpServerInstall>) {
const store = await readStore()
const fromCatalog = typeof input.id === "string"
? MCP_SERVER_CATALOG.find((entry) => entry.id === input.id)
const cleanInput = withoutUndefined(input as Record<string, unknown>) as Partial<McpServerInstall>
const fromCatalog = typeof cleanInput.id === "string"
? MCP_SERVER_CATALOG.find((entry) => entry.id === cleanInput.id)
: null
const next = normalizeInstall(
{
...fromCatalog,
...input,
source: input.source || (fromCatalog ? "catalog" : "custom"),
...cleanInput,
source: cleanInput.source || (fromCatalog ? "catalog" : "custom"),
},
typeof input.id === "string" ? store.servers[slugify(input.id)] : null,
typeof cleanInput.id === "string" ? store.servers[slugify(cleanInput.id)] : null,
)
store.servers[next.id] = next
await writeStore(store)
+35
View File
@@ -49,3 +49,38 @@ export async function writeSandboxFilePrivileged(
bytes: payload.byteLength,
}
}
export async function repairOpenClawWorkspacePermissions(sandboxName: string) {
const mutableDirs = [
"agents",
"extensions",
"workspace",
"skills",
"hooks",
"identity",
"devices",
"canvas",
"cron",
"memory",
"logs",
"credentials",
"sandbox",
"telegram",
]
const script = [
`for dir in ${mutableDirs.map(shellQuote).join(" ")}; do target="/sandbox/.openclaw-data/$dir"; link="/sandbox/.openclaw/$dir"; mkdir -p "$target"; if [ -d "$link" ] && [ ! -L "$link" ]; then cp -a "$link/." "$target/" 2>/dev/null || true; rm -rf "$link"; fi; ln -sfn "$target" "$link"; done`,
`chown -R sandbox:sandbox /sandbox/.openclaw-data 2>/dev/null || chown -R 998:998 /sandbox/.openclaw-data`,
`for dir in ${mutableDirs.map(shellQuote).join(" ")}; do chmod 0775 "/sandbox/.openclaw-data/$dir"; done`,
].join(" && ")
const result = await runDockerKubectl(
["exec", "-n", OPENSHELL_NAMESPACE, sandboxName, "--", "sh", "-lc", script],
)
if (result.code !== 0) throw new Error(result.stderr || "failed to repair OpenClaw mutable paths")
return {
sandboxName,
path: "/sandbox/.openclaw",
target: "/sandbox/.openclaw-data",
mutableDirs,
note: "Repaired OpenClaw mutable paths so AGENTS.md, session lock, and agent state writes resolve into writable .openclaw-data storage.",
}
}