Probe MCP broker POST during access sync

This commit is contained in:
mmckeen-nv
2026-04-30 11:23:04 -07:00
parent c804e509bb
commit 6d25b2395e
2 changed files with 28 additions and 5 deletions
+23 -3
View File
@@ -140,9 +140,29 @@ export async function resolveSandboxNetworkRule(sandboxId: string, action: strin
}
async function probeBrokerEndpoint(sandboxName: string, brokerBaseUrl: string) {
const capabilitiesUrl = `${brokerBaseUrl.replace(/\/+$/, "")}/capabilities`
const script = `curl --noproxy '*' -sS --max-time 5 ${JSON.stringify(capabilitiesUrl)} >/dev/null || true`
await runOpenShell(["sandbox", "exec", "-n", sandboxName, "--", "sh", "-lc", script], 15000).catch(() => null)
const mcpUrl = `${brokerBaseUrl.replace(/\/+$/, "")}/mcp`
const payload = {
jsonrpc: "2.0",
id: 1,
method: "initialize",
params: {
protocolVersion: "2024-11-05",
capabilities: {},
clientInfo: { name: "openshell-control-mcp-policy-probe", version: "0" },
},
}
const script = [
"node",
"-e",
`
fetch(${JSON.stringify(mcpUrl)}, {
method: "POST",
headers: { "content-type": "application/json" },
body: ${JSON.stringify(JSON.stringify(payload))},
}).catch(() => {});
`,
]
await runOpenShell(["sandbox", "exec", "-n", sandboxName, "--", ...script], 15000).catch(() => null)
}
export async function syncBrokerNetworkAccess(sandboxId: string, brokerBaseUrl: string) {