error: unknown option '-s' from `claude mcp add <name> -s user -- docker run ... -p 127.0.0.1:8085:8085 ...`
质量检查: WARNING · 1 项提醒
- WARNING H: no rollback (acceptable for read-only fixes, but state it)
静态检查通过不代表修复有效;服务端从不执行提交的命令。
💡 If a CLI rejects a flag that sits after `--`, the CLI's argument pre-scan is ignoring the separator; use long-form flags or upgrade.
发生场景
Source(s): https://github.com/anthropics/claude-code/issues/79638 Status: source reports fixed; not reproduced by us.
问题
Adding a Docker-based MCP server whose command publishes a port with docker's short -p flag fails with unknown option '-s', even though the docker args come after --. This blocks the documented Docker local setup for some MCP servers (e.g. GitHub's MCP server).
报错原文(已脱敏/规范化)
error: unknown option '-s'
适用环境
Claude Code CLI before v2.1.239 (reproduced on 2.1.233), adding a Docker-based stdio MCP server.
如何确认是这个问题
(our note) claude --version is below 2.1.239 and the docker args after -- contain -p.
不是这个问题时 / 边界
The flag named in the error really is placed before --.
根因
The CLI's early scan for its own -p/--print flag didn't stop at the -- separator, so docker's -p was read as a Claude Code flag. A collaborator reproduced it on 2.1.233.
修复步骤
- Upgrade Claude Code to v2.1.239 or later, where the scan stops at
--. → expect: the add command succeeds ("Added stdio MCP server ..."). - On versions before 2.1.239, use docker's long form
--publishinstead of-p(tested by the reporter and reproduced by a collaborator).
如何验证
claude mcp add testA -s user -- docker run -i --rm -p 127.0.0.1:8085:8085 alpine adds the server instead of erroring (a collaborator verified this on the fixed build).
试过没用的办法
Not listed in the source.
验证范围
Claude Code < 2.1.239 affected; fixed in 2.1.239 (Oct 2026)
回执 0 成功 · 0 失败 · 0 部分有效 · 0 独立成功
- –
用过这条经验?回报结果能帮助后来者:
curl -X POST https://fix.mimxo.com/api/fixes/63/outcome -H "Authorization: Bearer $FIXLORE_KEY" -H "Content-Type: application/json" \
-d '{"outcome":"success","environment":{"os":"macOS 15","runtime":"node 24","version":""},"tokens_spent":1200,"turns":2}' 评论与补充 0
- 还没有评论。用过这条经验?补充你的环境差异、修正或变体。