0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

DevcontainerでSerenaMCPがTimeoutする問題の対処法

Posted at

TL;DR

  • SerenaMCPをDevcontainer内でClaude Codeと組み合わせて使用するとConnectionがTimeoutする事象が発生
  • 原因は ignore_all_files_in_gitignore: true の設定により、gitignoreファイルのパースに時間がかかること
  • 暫定対処として .serena/project.ymlignore_all_files_in_gitignorefalse に変更することで解決
  • 本事象はGitHub Issueとして報告済み(2025/8/16時点でOpen)

背景

Claude Codeの暴走へのリスクヘッジとして、何かしらの仮想環境内で使用している人も多いかと思いますが、私の場合はDevcontainerを使用しています。

最近話題のSerenaMCPをClaude CodeのMCPとして設定してみたところ、接続でつまづいたので情報共有します。

SerenaMCPの設定は、公式ドキュメントの通り、以下のコマンドで実行しました:

claude mcp add serena -- uvx --from git+https://github.com/oraios/serena serena start-mcp-server --context ide-assistant --project $(pwd)

発生した事象

claude mcp list で起動状況を確認したところ、以下の通りfailedになっていました:

$ claude mcp list
Checking MCP server health...
serena: uvx --from git+https://github.com/oraios/serena serena start-mcp-server --context ide-assistant --project /workspaces/<プロジェクトディレクトリ> - ✗ Failed to connect

claude mcp list --debug で詳細を確認すると以下のエラーが出力されていました:

[ERROR] MCP server "serena" Server stderr: INFO  2025-08-15 07:46:41,137 [MainThread] serena.project:__init__:31 - Parsing all gitignore files in /workspaces/<プロジェクトディレクトリ>
[DEBUG] MCP server "serena": Connection failed: Error: Connection to MCP server "serena" timed out after 30000ms
[DEBUG] MCP server "serena": Error message: Connection to MCP server "serena" timed out after 30000ms
[DEBUG] MCP server "serena": Error stack: Error: Connection to MCP server "serena" timed out after 30000ms

※ 最初の[ERROR]MCPの仕様で、実際には行内で書かれている通り、INFOレベルの出力です。

原因分析

タイムアウトが発生する前の最終行では、Parsing all gitignore files in /workspaces/<プロジェクトディレクトリ> となっており、gitignoreに記載されたファイルをパースするのに時間がかかっているように見えました。

このパース処理をコントロールできないか調べたところ、<プロジェクトディレクトリ>/.serena/project.yml に以下の設定がありました:

# whether to use the project's gitignore file to ignore files
# Added on 2025-04-07
ignore_all_files_in_gitignore: true

暫定対処法

上述の設定値を false に変更しました:

# whether to use the project's gitignore file to ignore files
# Added on 2025-04-07
ignore_all_files_in_gitignore: false

対処結果

設定変更後、claude mcp list --debug のログはスムーズに流れ、ステータス表示も Connected になりました:

$ claude mcp list
Checking MCP server health...
serena: uvx --from git+https://github.com/oraios/serena serena start-mcp-server --context ide-assistant --project /workspaces/<プロジェクトディレクトリ> - ✓ Connected

恒久対処について

この問題は仮想環境全般での事象としてGitHub Issue #470で報告されていますが、2025年8月16日時点ではまだOpenの状態です。

根本的な修正については、開発チームの対応を待つしかない状況ですね。

おわりに

Devcontainerなどの仮想環境でSerenaMCPを使用する際に同様の事象に遭遇した方の参考になれば幸いです。


参考リンク:

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?