上一篇,我们讲了在 Codex CLI 上使用 Streamable HTTP 方式来连接 Serena MCP,这一篇,我们再来讲讲在 Claude Code 上该如何配置
Serena 官方推荐的 Claude Code 使用方式是这样的:
1 | claude mcp add serena -- uvx --from git+https://github.com/oraios/serena serena start-mcp-server --context ide-assistant --project $(pwd) |
如果使用 Streamable HTTP
方式,那么我们就不能再使用--project $(pwd)
参数了
和 Codex CLI 类似,首先我们需要下载Serena并运行
1 | https://github.com/oraios/serena.git |
然后,我们使用 Claude Code 执行以下命令
1 | claude mcp add --transport http serena http://127.0.0.1:9122/mcp |
如果之前添加过 Serena,需要先删除再添加,删除命令如下
1 | claude mcp remove serena |
需要注意的是,由于我们没有指定参数--project $(pwd)
,因此在
Claude Code 上默认不会激活 Serena
建议在使用/init
生成的CLAUDE.md
文件中加入以下提示词,以自动激活
Serena
1 | IMPORTANT: If `serena.activate_project` has not been called in the context, then call it once first. The `workdir` is the path of the current project. |
完成配置后使用claude mcp list
就能看到成功连接了
开机自启动部分可以直接参照Codex CLI 使用 Streamable-HTTP 连接 Serena MCP中的部分来设置,这里就不再赘述啦
放个配置文件供参考
1 | [Unit] |