Agent SDK
A headless agent that can message its owner. sock_send is auto-approved because nobody is there to click, so the blast radius is the puppet: its owner and its conversations, at 60 sends a minute. Use one puppet per agent.
import { query } from "@anthropic-ai/claude-agent-sdk";
const token = process.env.SOCK_TOKEN;
if (!token) throw new Error("set SOCK_TOKEN to a sock_pt_ token");
// query() spawns Claude Code with this environment: only sock-mcp gets the token
delete process.env.SOCK_TOKEN;
for await (const msg of query({
prompt: process.argv[2] ?? "Send my owner a one line hello with sock_send.",
options: {
mcpServers: {
sock: {
type: "stdio",
command: "sock-mcp",
args: ["--outbound-only"],
env: { SOCK_TOKEN: token },
},
},
allowedTools: [
"mcp__sock__sock_whoami",
"mcp__sock__sock_list_conversations",
"mcp__sock__sock_send",
],
},
})) {
if (msg.type === "result") console.log(msg);
}
--outbound-only leaves out sock_fetch and sock_ack. Fetch returns messages from every sender in every conversation the puppet is in, and that text is untrusted.