SerenaMCPサーバをClaudeCodeに適用しようとしてハマったので解決方法を記載します。
✅ 先に結論
- 原因:当記事執筆時点(2025/8/5)でSerenaMCPはTerraformに対応していない
- 解決方法:「~/.serena/project.yml」のlanguageとignored_pathsを修正する
やりたかった事
ClaudeCodeにSerenaMCPサーバの導入を行い、使用トークン量削減とClaudeCodeにプロジェクトのコンテキストを理解させて賢い応答を得たかった。
SerenaMCPサーバの詳細や導入手順はkaitoさんが記載してくれている以下が参考になると思います。
エラーの詳細
- 発生した環境
- Windows11
- VSCode
- GitBash
- ClaudeCode
-
エラー発生時の操作
- SerenaMCPサーバの適用
claude mcp add serena -- uvx --from git+https://github.com/oraios/serena serena-mcp-server --context ide-assistant --project $(pwd) - ClaudeCodeの起動とSerenaの初期化
claude
/mcp__serena__initial_instructions
⇒この初期化コマンド実行時にエラーが発生
- SerenaMCPサーバの適用
- 実際のエラーメッセージ
Error executing tool: Terraform executable not found, please ensure Terraform is installed.See https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli for instructions.
原因
タイトルやエラーメッセージにもある通りTerraformファイルの存在をSerenaが検出していた事が原因となっていました。
私の環境は個人開発しているプロダクトのルート配下にアプリケーションコードとインフラコードをまとめて管理している状態した。my-projectディレクトリでSerenaMCPサーバの初期化を行った際に、frontendやbackendのソースではなく最初にinfrastructure配下をSerenaMCPサーバが見に行ってしまったようです。
my-project/
├── frontend/ # Next.jsなどのフロントエンド
├── backend/ # APIや認証などのバックエンド
└── infrastructure/ # TerraformによるIaC管理
Terraformがインストールされているか確認してとエラーメッセージが出ていたのですが、tfenvを使ってTerraformは導入済みの状態だった為暫く悶々としました。。。
SerenaMCPのREADMEを見に行くと以下の通り当記事執筆時点(2025/8/5)でTerraformはサポート対象に含まれていないです。
Language servers provide support for a wide range of programming languages. With Serena, we provide
- direct, out-of-the-box support for:
- Python
- TypeScript/Javascript (currently has some instability issues, we are working on it)
- PHP
- Go (need to install go and gopls first)
- Rust
- C# (requires dotnet to be installed. We switched the underlying language server recently, please report any issues you encounter)
- Java (Note: startup is slow, initial startup especially so. There may be issues with java on macos and linux, we are working on it.)
- Elixir (Requires NextLS and Elixir install; Windows not supported - Next LS does not provide Windows binaries)
- Clojure
- C/C++ (You may experience issues with finding references, we are working on it)
- indirect support (may require some code changes/manual installation) for:
- Ruby (untested)
- Kotlin (untested)
- Dart (untested)
エラーにはなったもののSerena初期化時に作成されるproject.ymlは作成されていたので中身を確認すると以下の状態でした。
languageがサポート外のTerraformになってる![]()
### my-project/.serena/project.yml
# language of the project (csharp, python, rust, java, typescript, go, cpp, or ruby)
# * For C, use cpp
# * For JavaScript, use typescript
# Special requirements:
# * csharp: Requires the presence of a .sln file in the project folder.
language: terraform
# whether to use the project's gitignore file to ignore files
# Added on 2025-04-07
ignore_all_files_in_gitignore: true
# list of additional paths to ignore
# same syntax as gitignore, so you can use * and **
# Was previously called `ignored_dirs`, please update your config if you are using that.
# Added (renamed)on 2025-04-07
ignored_paths: []
以降省略
解決手順
languageが悪さをしていそうという事で、バックエンド作成で利用しており動作が安定している模様のpython指定に手動で変更。ignored_pathsにTerraform管理パスを追加しました。
一度ClaudeCodeのセッションを閉じ、改めて繋ぎなおしてSerenaMCPサーバの初期化を行ったところめでたく初期化することができました![]()
### my-project/.serena/project.yml(修正後)
# language of the project (csharp, python, rust, java, typescript, go, cpp, or ruby)
# * For C, use cpp
# * For JavaScript, use typescript
# Special requirements:
# * csharp: Requires the presence of a .sln file in the project folder.
language: python
# whether to use the project's gitignore file to ignore files
# Added on 2025-04-07
ignore_all_files_in_gitignore: true
# list of additional paths to ignore
# same syntax as gitignore, so you can use * and **
# Was previously called `ignored_dirs`, please update your config if you are using that.
# Added (renamed)on 2025-04-07
ignored_paths:
- "infrastructure/*"
以降省略
まとめ
サポート外だけど言語検出としてTerraformと認識しているということは、今後Terraformもサポートされるのかもしれないですね。同じ境遇の方がいらっしゃれば参考になると嬉しいです。
ちなみにproject.ymlのlanguageは複数指定できなさそうでした。言語変わるならそれ毎にMCPのプロジェクト指定をするのがよいのですかね。詳しい方いたら教えていただけると嬉しいです!