🐧

opencodeと Serena MCPサーバを連携させる

に公開

※本記事では WSL 環境で opencode が実行できることを前提とします

1.はじめに

opencode と ローカル環境で立ち上げたMCPサーバを連携させる手順について紹介します。
今回は Serena を対象に opencode と連携させていきます。

2.WSL 環境へのSerena の導入

■ uv の導入

PowerShellを開き、WSL環境にログインする

wsl.exe -d Ubuntu

下記コマンドで uv をインストールします。

curl -LsSf https://astral.sh/uv/install.sh | sh

正常にインストールができているか下記コマンドで確認します。

$ uv --version
uv 0.8.17

■ ローカル環境(WSL)上で Serena を MCPサーバとして起動する

WSL環境上で Serena を MCPサーバとして起動できるか確認します。

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

下記のようなログが出力されているはずなので、
リンクを確認し ローカル環境で起動した Serena のダッシュボードを確認します。

INFO  2025-09-14 22:11:29,655 [MainThread] serena.agent:__init__:195 - Serena web dashboard started at http://127.0.0.1:24282/dashboard/index.html

ダッシュボード画面が表示されていれば Serena の動作確認は完了です。

3.opencode と Serena を連携する

作業ディレクトリ配下で opencode.jsonc を作成します。
opencode.jsonc で下記のようなMCP設定を記述します。
基本的には、ローカルでMCPサーバを立ち上げるためのコマンドをopencode.jsoncに記載するだけです。

※MCP設定項目については公式ドキュメント設定項目について記載した記事を確認ください。

opencode.jsonc
{
  "$schema": "https://opencode.ai/config.json",

  "mcp": {
    "serena": {
      "type": "local",
      "enabled": true,
      "command": [
        "uvx",
        "--from",
        "git+https://github.com/oraios/serena",
        "serena",
        "start-mcp-server",
        "--context",
        "ide-assistant",
        "--project",
        "{cwd}"
      ],
      "environment": {
        "PYTHONUNBUFFERED": "1"
      }
    }
  }
}

opencode を起動して Serena と連携されていることを確認する

作業ディレクトリ配下でWSL環境にログインし、opencode を起動します。

$ wsl.exe -d Ubuntu
$ opencode

試しに /init コマンドを実行します。

下記のようにSerena_で始まるコマンドを使用して、AGENTS.mdが作成されればOKです。

Serena_check_onboarding_performed

The onboarding was already performed, below is the list of available memories.
            Do not read them immediately, just remember that they exist and that you can read them later, if it is necessary
            for the current task.
            Some memories may be based on previous conversations, others may be general for the current project.
            You should be able to tell which one you need based on the name of the memory.

            ['code_style_conventions', 'project_overview', 'suggested_commands', 'task_completion_guidelines']

Discussion