원클릭으로
serena-mcp
Serena MCP Tools — Semantic code analysis and editing with clangd for C++20 and Python
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Serena MCP Tools — Semantic code analysis and editing with clangd for C++20 and Python
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Use for any question about a codebase, its architecture, file relationships, or project content — especially when graphify-out/ exists, where the question should be treated as a graphify query first. Turns any input (code, docs, papers, images, videos) into a persistent knowledge graph with god nodes, community detection, and query/path/explain tools.
Drives a live Spectra instance via the embedded MCP automation server (default http://127.0.0.1:8765/mcp). Use for smoke tests, screenshots, UI commands, figure/series setup, and visual debugging after builds — whenever validating rendering without writing a harness.
Spectra Agent Skill Set
Plan, design, and implement Spectra C++/GLSL/Python changes. Use when breaking down a feature, making architecture decisions before coding, or writing/fixing source in src/, include/spectra/, shaders, tests, or python/.
Spectra git and release workflows: conventional commits, branches, PRs, version bumps, release tags, merge conflicts, changelog. Use for commit, branch, PR, release, version.txt, squash merge, cherry-pick, or git status/diff questions.
Fix or edit Spectra GitHub Actions (.github/workflows). Use for CI failures, new matrix jobs, golden/sanitizer jobs, release.yml, lavapipe/xvfb setup, or masking vs root-cause CI fixes.
| name | serena-mcp |
| description | Serena MCP Tools — Semantic code analysis and editing with clangd for C++20 and Python |
Serena provides LSP-backed semantic tools via MCP for the Spectra project. This skill covers proper usage, clangd-specific behavior, and the performance rules that keep
find_symbolfast. NOTE: The project switched from ccls to clangd on 2026-06-25. If you see old notes referencing::naming or ccls, they are obsolete.
cpp)The project uses clangd for C++ symbol analysis. Configured in .serena/project.yml:
languages:
- cpp
- python
~/.serena/language_servers/static/ClangdLanguageServer/clangd/clangd_19.1.2/bin/clangd), launched with --background-index.clangd-20; the build compiles with clang++-20. The 19-vs-20 skew is harmless (only IncludeCleaner log noise).kylin-clangd IDE extension using .vscode/settings.json) — independent of Serena.compile_commands.json is auto-symlinked at the project root by CMake on every configure (see CMakeLists.txt); clangd also reads build/ directly.serena project index (~7 min for ~618 files). This builds .serena/cache/cpp/document_symbols.pkl (~18 MB) and is REQUIRED for fast lookups.clangd returns symbols as a hierarchical documentSymbol tree; Serena joins the path with /, NOT ::.
/# CORRECT
find_symbol(name_path_pattern="spectra/Figure")
find_symbol(name_path_pattern="spectra/Figure/show")
find_symbol(name_path_pattern="spectra/Figure/set_size")
find_symbol(name_path_pattern="spectra/FigureManager")
# WRONG — ccls-style, will return empty results
find_symbol(name_path_pattern="spectra::Figure")
find_symbol(name_path_pattern="spectra::Figure::show")
When unsure of exact node names (nested namespaces such as spectra::adapters::ros2 may collapse into a single node), run get_symbols_overview on the file first.
.find_symbol(name_path_pattern="spectra.FigureManager")
find_symbol(name_path_pattern="spectra.FigureManager.create_figure")
[index]find_symbol(name_path_pattern="spectra/Figure/style[0]") # first overload
find_symbol(name_path_pattern="spectra/Figure/style[1]") # second overload
The #1 failure mode is find_symbol "getting stuck". It is almost never a real hang.
find_symbol without relative_path calls request_full_symbol_tree, which walks every project file via documentSymbol. Each ROS/heavy C++ file costs a ~0.7-1.5s clangd preamble, so with no cache a global search takes ~7 min and looks stuck. (clangd itself is fast — a direct workspace/symbol answers in ~0.05s; Serena just does not use that path.)relative_path for targeted lookups → a single documentSymbol, instant from cache.serena project index. Edited files re-index live on the next lookup (~1.5s each).find_symbol.get_symbols_overview — File structure (cheapest entry point)get_symbols_overview(relative_path="include/spectra/figure.hpp", depth=1)
clangd returns a hierarchical tree (Namespace → Class → Method/Field). Use this FIRST to understand a file and to discover exact /-joined name paths.
find_symbol — Symbol search# Exact match (ALWAYS provide relative_path)
find_symbol(name_path_pattern="spectra/Figure", relative_path="include/spectra/figure.hpp", include_body=False)
# Substring matching
find_symbol(name_path_pattern="Fig", substring_matching=True, max_matches=10)
# With full body
find_symbol(name_path_pattern="spectra/Figure/show", relative_path="include/spectra/figure.hpp", include_body=True)
clangd behavior:
depth=1 DOES return children for classes (hierarchical) — unlike ccls.include_body=True returns the FULL body.relative_path, the call walks all files (slow). Always provide it when you know the file.find_referencing_symbols — Find all referencesfind_referencing_symbols(
name_path="spectra/Figure",
relative_path="include/spectra/figure.hpp",
max_answer_chars=2000 # ALWAYS set this!
)
Critical: Always set max_answer_chars (recommend ≤2000). Core classes have 300+ references (~84KB); without the limit the MCP transport can crash.
find_declaration — Find declaration from usageRequires a regex with exactly one capture group.
# CORRECT — one capture group
find_declaration(regex="(show)\(\)", relative_path="include/spectra/figure.hpp")
# WRONG — no capture group
find_declaration(regex="show\(\)", relative_path="include/spectra/figure.hpp")
find_implementations — Find interface implementationsfind_implementations(name_path="spectra/IRenderer", relative_path="src/render/renderer.hpp", max_answer_chars=1000)
Works for interfaces; concrete (non-virtual) classes may return [].
get_diagnostics_for_file — File diagnosticsget_diagnostics_for_file(relative_path="include/spectra/figure.hpp") # C++ — works (clangd publishes diagnostics)
get_diagnostics_for_file(relative_path="python/spectra/figure.py") # Python — works
clangd publishes diagnostics via LSP, so this works for C++ as well as Python (a key improvement over ccls, which returned {}).
search_for_pattern — Regex search across codebasesearch_for_pattern(
substring_pattern="class Figure",
restrict_search_to_code_files=True,
context_lines_before=0,
context_lines_after=1
)
Use for non-symbol searches (comments, config patterns, etc.).
replace_symbol_body — Edit a symbol's body# First retrieve the current body
find_symbol(name_path_pattern="spectra/Figure/show", relative_path="include/spectra/figure.hpp", include_body=True)
# Then replace it
replace_symbol_body(
name_path="spectra/Figure/show",
relative_path="include/spectra/figure.hpp",
body="void show() const { /* new implementation */ }"
)
Only use after retrieving the current body with include_body=True.
insert_before_symbol / insert_after_symbol — Insert codeinsert_after_symbol(
name_path="spectra/Figure/show",
relative_path="include/spectra/figure.hpp",
body="void newMethod();"
)
insert_before_symbol(
name_path="spectra/Figure",
relative_path="include/spectra/figure.hpp",
body="#include <new_header>"
)
replace_content — File-based regex replacementreplace_content(
relative_path="src/core/figure.cpp",
needle="old_pattern.*?end_of_text",
repl="new_content",
mode="regex"
)
Use regex wildcards (.*?) to avoid quoting entire blocks.
rename_symbol — Rename across codebaserename_symbol(
name_path="spectra/Figure/oldMethod",
relative_path="include/spectra/figure.hpp",
new_name="newMethod"
)
Uses LSP refactoring — updates all references automatically.
safe_delete_symbol — Delete with reference checksafe_delete_symbol(
name_path_pattern="spectra/Figure/unusedMethod",
relative_path="include/spectra/figure.hpp"
)
Returns the list of references if the symbol is still used, preventing accidental deletion.
list_memories()
read_memory(memory_name="core")
write_memory(memory_name="new_topic", content="# Title\n\n...")
edit_memory(memory_name="core", needle="old text", repl="new text", mode="literal")
Available memories: conventions, core, memory_maintenance, serena_tools, suggested_commands, task_completion, tech_stack.
| Aspect | clangd (cpp, current) | ccls (cpp_ccls, removed) |
|---|---|---|
| Symbol naming | spectra/Figure (slash path) | spectra::Figure (:: scope) |
get_symbols_overview | Hierarchical (Namespace → Class → Method) | Flat list with :: names grouped by kind |
find_symbol depth=1 | Returns children (methods, fields) | Returned only the class |
find_symbol body | Full method body | Minimal (single line) |
get_diagnostics_for_file | Works for C++ and Python | Returned {} for C++ |
find_declaration | Reliable | Often "No symbol declaration found" |
compile_commands.json | Auto-symlinked at root by CMake; also reads build/ | Needed manual root symlink |
Global find_symbol (no relative_path) | Walks all files (~7 min uncached) → always pass relative_path | Same problem |
| Indexing | serena project index (~7 min, 618 files) → 18 MB cache | ~6.5 min |
1. get_symbols_overview(relative_path="include/spectra/figure.hpp", depth=1)
2. find_symbol(name_path_pattern="spectra/Figure/show", relative_path="include/spectra/figure.hpp", include_body=True)
3. read_file(... ) # for raw content if needed
1. find_symbol(name_path_pattern="spectra/Figure/show", relative_path="include/spectra/figure.hpp")
2. find_referencing_symbols(name_path="spectra/Figure/show", relative_path="include/spectra/figure.hpp", max_answer_chars=2000)
1. find_symbol(name_path_pattern="spectra/Figure/show", relative_path="include/spectra/figure.hpp", include_body=True)
2. replace_symbol_body(name_path="spectra/Figure/show", relative_path="include/spectra/figure.hpp", body="void show() const { /* new */ }")
1. get_symbols_overview(relative_path="include/spectra/figure.hpp", depth=1)
2. insert_after_symbol(name_path="spectra/Figure/has_animation", relative_path="include/spectra/figure.hpp", body="void newMethod();")
1. find_symbol(name_path_pattern="spectra/Figure/oldName", relative_path="include/spectra/figure.hpp")
2. rename_symbol(name_path="spectra/Figure/oldName", relative_path="include/spectra/figure.hpp", new_name="newName")
find_symbol is slow / "stuck"relative_path → it is walking every file. Pass relative_path.serena project index (terminal). Verify .serena/cache/cpp/document_symbols.pkl exists.find_symbol returns []/ not ::.get_symbols_overview to see the exact name path.substring_matching=True.find_referencing_symbols crashes MCP transportmax_answer_chars (≤2000). Narrow scope with relative_path.serena start-project-server --port 24283 + curl API (read-only tools only).# Start project server
serena start-project-server --port 24283 --log-level WARNING &
# Test heartbeat
curl -s http://127.0.0.1:24283/heartbeat
# Call any read-only tool (note the / naming)
curl -s -X POST http://127.0.0.1:24283/query_project \
-H "Content-Type: application/json" \
-d '{"project_name":"Spectra","tool_name":"find_symbol","tool_params_json":"{\"name_path_pattern\":\"spectra/Figure\",\"relative_path\":\"include/spectra/figure.hpp\"}"}'
Note: Project server only allows read-only tools. Write tools require an MCP connection.
serena tools list # List all active tools
serena tools description find_symbol # Get tool description
serena memories list # List memories
serena project health-check # Health check
serena project index # Index project (run after major changes)