关于 setup-serena-mcp
用于引导 Serena MCP 服务配置的 Agent 技能,面向在 Claude Code 等客户端中接入 Serena 并初始化项目的用户。它根据配置范围和客户端类型逐步检查依赖、设置项目并验证连接。
主要功能
- 01区分项目共享、本地和全局配置
- 02检查 Serena 工具是否可用
- 03指导客户端与项目配置
- 04指导项目索引和初始化
- 05更新 CLAUDE.md 配置说明
适用场景
- 01为项目或团队接入 Serena
- 02在个人全局环境配置 Serena
- 03初始化项目索引并验证连接
MCP 相关
该技能指导用户配置 Serena MCP 服务,并检查 MCP 工具是否可用。
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ neolabhq/ context-engineering-kit --skill setup-serena-mcp安装后在 Claude Code 中输入/setup-serena-mcp确认已加载。
详细介绍
用户输入:
$ARGUMENTS
Serena MCP 服务设置指南
1. 确定设置上下文
询问用户想要将配置存储在哪里:
选项:
-
项目级别(通过 git 共享) - 配置纳入版本控制并与团队共享
- CLAUDE.md 更新至:
./CLAUDE.md
- CLAUDE.md 更新至:
-
项目级别(个人偏好) - 配置保留在本地,不纳入 git 跟踪
- CLAUDE.md 更新至:
./CLAUDE.local.md - 确认这些文件已列在
.gitignore中;如果没有,则添加
- CLAUDE.md 更新至:
-
用户级别(全局) - 配置适用于此用户的所有项目
- CLAUDE.md 更新至:
~/.claude/CLAUDE.md
- CLAUDE.md 更新至:
保存用户的选择,并在后续步骤中使用相应路径。
2. 检查 Serena MCP 服务是否已设置
尝试使用 Serena 的某个工具(例如 find_symbol 或 get_symbols_overview),检查你是否可以访问 Serena MCP 服务。
如果无法访问,则继续设置。
3. 加载 Serena 文档
阅读以下文档,了解 Serena 的功能和设置流程:
- 加载 https://raw.githubusercontent.com/oraios/serena/refs/heads/main/README.md,了解 Serena 是什么以及它的功能
- 加载 https://oraios.github.io/serena/02-usage/020_running.html,了解如何运行 Serena
- 加载 https://oraios.github.io/serena/02-usage/030_clients.html,了解如何配置 MCP 客户端
- 加载 https://oraios.github.io/serena/02-usage/040_workflow.html,了解如何为项目设置 Serena
4. 引导用户完成设置流程
根据加载的文档:
- 检查先决条件:确认已安装
uv(运行 Serena 所必需) - 确定客户端类型:确定用户使用的是哪种 MCP 客户端(Claude Code、Claude Desktop、Cursor、VSCode 等)
- 提供设置说明:如果尚未配置,则引导用户完成适用于其客户端的配置
- 设置项目:如果尚未设置,则引导用户完成项目设置流程
- 开始为项目建立索引:如果刚完成设置,则引导用户完成项目索引流程
- 如果刚设置 MCP,请让用户重启 Claude Code 以加载新的 MCP 服务,并明确告知用户:“退出 Claude Code 控制台,然后运行 'claude --continue',再输入 "continue" 以继续设置流程”
- 测试连接:确认设置后可以访问 Serena 工具
- 如果还不能访问,则运行 initial_instructions
- 检查是否已完成引导;如果没有,则运行引导流程。
- 然后尝试读取任意文件
添加 MCP 服务后、测试连接前,向用户发送以下消息,内容必须完全一致:
You must restart Claude Code to load the new MCP server:
1. Exit Claude Code console (type exit or press Ctrl+C)
2. Run claude --continue
3. Type "continue" to resume setup
After restart, I will:
- Verify Serena tools are accessible
- Run initial_instructions if needed
- Perform onboarding for this project (if not already done)
5. 更新 CLAUDE.md 文件
使用第 1 步确定的路径。Serena 成功设置后,使用以下内容更新相应的 CLAUDE.md 文件,内容必须完全一致:
### Use Serena MCP for Semantic Code Analysis instead of regular code search and editing
Serena MCP is available for advanced code retrieval and editing capabilities.
**When to use Serena:**
- Symbol-based code navigation (find definitions, references, implementations)
- Precise code manipulation in structured codebases
- Prefer symbol-based operations over file-based grep/sed when available
**Key tools:**
- `find_symbol` - Find symbol by name across the codebase
- `find_referencing_symbols` - Find all symbols that reference a given symbol
- `get_symbols_overview` - Get overview of top-level symbols in a file
- `read_file` - Read file content within the project directory
**Usage notes:**
- Memory files can be manually reviewed/edited in `.serena/memories/`
如果在用户级别(全局)设置了服务,则添加以下部分:
**Project setup (per project):**
1. Run `serena project create --index` in your project directory
2. Serena auto-detects language; creates `.serena/project.yml`
3. First use triggers onboarding and creates memory files in `.serena/memories/`
6. 项目初始化(如有需要)
如果这是一个新项目,或者 Serena 尚未初始化:
- 引导用户运行项目初始化命令
- 说明基于项目的工作流和索引
- 根据需要配置项目专属设置
评论
支持 Markdown