Claude Agent SDK v0.3.326弃用命令行传参
v0.3.326
推荐理由
开发者若依赖此SDK且使用较老版本的Claude Code,必须关注此弃用通知,否则未来版本将失效。建议检查当前配置并准备迁移至initialize模式。
What's changed
变更内容
- Added mcpServersDelivery: 'initialize': sends mcpServers in the initialize request instead of on Claude Code's command line; needs the bundled Claude Code or newer
- Added getSessionInfo() to the /core entry
- Added message_uuid to cancel_async_message responses, naming the dropped message
- Added a warning on stderr and as a system/informational message when a tool list has an entry that doesn't look like a complete rule
- Added a system/informational warning, tagged managed_mcp_arrived, when an administrator's managed-mcp.json arrives during a session and your own MCP servers stop loading
- Fixed a tool call in a running turn reconnecting to an MCP server just removed with setMcpServers(), or reporting that it needs authentication; the call is now refused
- Fixed resumeSessionAt failing on an empty reply, and a resumed session losing recent turns after a crash when the previous turn ended with one
- Fixed a tool result from an SDK MCP server being lost, or delivered to another call, when a long call overlapped a reconnect of the SDK MCP servers
- Fixed a hook request that arrives while the SDK is still starting up being refused instead of answered
- Improved how secrets are masked in the description passed to canUseTool; input itself is unchanged
- Improved the first turn after SpareProcess.claim(): it no longer waits up to 500 ms for the stdio MCP servers the claim starts, where tool search loads their tools on demand
- Changed the JSON-RPC id of requests to an SDK MCP server from a number to a string
- Changed rewindFiles() on macOS, Linux and WSL to leave some files untouched when the sandbox is on, and report them as skipped
- Changed the register_repo_root control request to refuse some folders it used to accept
- Deprecated sending mcpServers on Claude Code's command line (today's default, 'argv'): a future release defaults to 'initialize'; apps running an older Claude Code must update it or set 'argv'
- Updated to parity with Claude Code v2.1.326
- 新增 mcpServersDelivery: 'initialize':在初始化请求中发送 mcpServers,而非通过 Claude Code 的命令行;需要捆绑版或更新版本的 Claude Code
- 向 /core 入口添加了 getSessionInfo()
- 在 cancel_async_message 响应中添加了 message_uuid,用于标识被丢弃的消息
- 当工具列表包含看起来不完整的规则条目时,向 stderr 输出警告,并作为系统/信息性消息发出
- 当管理员的 managed-mcp.json 在会话期间到达且你自己的 MCP 服务器停止加载时,发出标记为 managed_mcp_arrived 的系统/信息性警告
- 修复了在运行中的回合内调用工具时,若该工具已使用 setMcpServers() 移除或报告需要身份验证,则重新连接到 MCP 服务器的行为;现在此类调用将被拒绝
- 修复了 resumeSessionAt 在收到空回复时失败的问题,以及恢复的会话在崩溃后丢失最近回合(当上一回合以某种方式结束时)的问题
- 修复了当 SDK MCP 服务器的长时间调用与重连重叠时,SDK MCP 服务器的工具结果丢失或被传递给其他调用的问题
- 修复了在 SDK 仍处于启动阶段时到达的钩子请求被拒绝而非应答的问题
- 改进了传递给 canUseTool 的描述中对密钥的掩码处理;输入本身保持不变
- 改进了 SpareProcess.claim() 后的第一个回合:不再等待最多 500 毫秒以获取 claim 启动的 stdio MCP 服务器,这些服务器的工具按需加载
- 将发往 SDK MCP 服务器的请求的 JSON-RPC id 从数字改为字符串
- 在 macOS、Linux 和 WSL 上更改 rewindFiles() 的行为:当沙箱启用时,保留某些文件不变,并将其报告为已跳过
- 更改 register_repo_root 控制请求,使其拒绝一些以前接受的文件夹
- 弃用在 Claude Code 命令行上传递 mcpServers(当前默认值为 'argv');未来版本将默认使用 'initialize';运行旧版 Claude Code 的应用必须更新它或设置 'argv'
- 更新至与 Claude Code v2.1.326 保持一致
Update
更新
代码 · 7 行
npm install @anthropic-ai/[email protected]
# or
yarn add @anthropic-ai/[email protected]
# or
pnpm add @anthropic-ai/[email protected]
# or
bun add @anthropic-ai/[email protected]更进一步:量化金融体系
看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力