// MCP connector with the Node SDK beta namespace. STATUS: UNVERIFIED as a script (identical raw request LIVE_VERIFIED 2026-09-18, i1). // Run: node --env-file=.env --experimental-strip-types examples/anthropic/mcp/mcp_connector.ts [https://your-public-host/mcp] import Anthropic from "@anthropic-ai/sdk"; import { logRequest } from "../../shared/tool-loop/log.ts"; const client = new Anthropic(); const url = process.argv[2] ?? "https://mcp.deepwiki.com/mcp"; const resp: any = await client.beta.messages.create({ model: "claude-haiku-4-5-20251001", max_tokens: 200, betas: ["mcp-client-2025-11-20"], mcp_servers: [{ type: "url", url, name: "srv" }], tools: [{ type: "mcp_toolset", mcp_server_name: "srv" }] as any, messages: [{ role: "user", content: url.includes("deepwiki") ? "Call read_wiki_structure for anthropics/anthropic-sdk-python and reply with only the first 3 topic names." : "Use the echo tool to echo PING." }], }); logRequest("anthropic", "POST", "/v1/messages", 200, 0.003, "mcp_connector.ts"); console.log(resp.content.map((b: any) => ({ type: b.type, name: b.name, server_name: b.server_name, is_error: b.is_error, text: b.text?.slice(0, 200) })));