12
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Gemini CLI で Serena を使う方法

Last updated at Posted at 2025-08-01

Gemini CLISerena をMCPサーバーとして登録するために、我々はどうすればよいのか。
Claude Codeの向けのやり方は公式のreadmeにあるけど、Gemini CLIのは見つからなかったので、とりあえずメモ。

1. uv のインストール

Macなので、とりあえずbrewで。

brew install uv

Linuxならpipxとか。

sudo apt update
sudo apt install pipx
pipx ensurepath
pipx install uv

2. Gemini CLI の設定

こんな感じで、 ~/.gemini/settings.json に、mcpサーバーを登録。

{
  "selectedAuthType": "gemini-api-key",
  "theme": "Default",
  "checkpointing": true,
  "mcpServers": {
    "serena": {
      "command": "uvx",
      "args": [
        "--from", "git+https://github.com/oraios/serena",
        "serena-mcp-server",
        "--context", "ide-assistant",
        "--enable-web-dashboard", "false",
        "--project", "${PWD}"
      ]
    }
  }
}

3 使ってみる

Gemini CLI で /mcp と打つと、serena が mcp サーバに登録されてるのが見えるはず。

$ gemini

> /mcp

  🟢 serena - Ready (23 tools)
    - list_dir
    - find_file
    - replace_regex
    - search_for_pattern
    - restart_language_server
    - get_symbols_overview
    - find_symbol
    - find_referencing_symbols
    - replace_symbol_body
    - insert_after_symbol
    - insert_before_symbol
    - write_memory
    - read_memory
    - list_memories
    - delete_memory
    - activate_project
    - remove_project
    - switch_modes
    - check_onboarding_performed
    - onboarding
    - think_about_collected_information
    - think_about_task_adherence
    - think_about_whether_you_are_done

とりあえず、プロジェクトのディレクトリで gemini を立ち上げてから、

このディレクトリでserenaをactivateしてから、onboardingして

とか指示してみるとよいかと。
ただし、Geminiの機嫌が悪いと serena って何ぞ?ってなることもあります。

そこで、ツール名を指定して指示を送る場合、
@(serena).(ツール名) [引数]
という形式でMCPのツールを直接叩けるので、(カッコを省略して)

@serena.activate_project

というプロンプトを投げると確実です。
(claude code なら /mcp__serena__activate_project)

また、onboarding時にプロジェクト全体のファイル構造やシンボルを分析・インデックス化しメタデータを.serenaというディレクトリに作ってくれるのですが、これは現状自動的には更新されないみたいです。

ある程度、ファイル構造やコードに変化がでてきたら、

@serena.onboarding

を実行して、その都度、メタデータを作り直すのがよいみたい。

12
4
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
12
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?