import { query, tool, createSdkMcpServer } from "@anthropic-ai/claude-agent-sdk"
import { Sandbox } from "@superserve/sdk"
import { z } from "zod"
const sandbox = await Sandbox.create({ name: "agent-runtime" })
const bash = tool(
"bash",
"Run a shell command in the sandbox.",
{ command: z.string() },
async ({ command }) => {
const result = await sandbox.commands.run(command, { timeoutMs: 60_000 })
return {
content: [
{ type: "text", text: `${result.stdout}\n${result.stderr}` },
],
}
},
)
const superserve = createSdkMcpServer({
name: "superserve",
version: "1.0.0",
tools: [bash],
})
for await (const message of query({
prompt: "List the files in /tmp and tell me how many there are.",
options: {
mcpServers: { superserve },
allowedTools: ["mcp__superserve__bash"],
},
})) {
if (message.type === "result" && message.subtype === "success") {
console.log(message.result)
}
}
await sandbox.kill()