8
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

MCPをDockerで実行するとやばいぐらい簡単(クリスマスイブでも通常運転🎄🎄🎄)

Last updated at Posted at 2024-12-24

今日見つけたブログです。

The Model Context Protocol: Simplifying Building AI apps with Anthropic Claude Desktop and Docker

MCPはAnthropicがOSSで公開した生成AIツールの仕様(?)で、Claude.aiのデスクトップアプリから利用可能です。

リファレンス実装も公開されているのですが、MacやLinuxを前提としているのか、Windowsでは動かない部分がありました。

こちらの手順に従えば動きます

https://note.com/doerstokyo_kb/n/nd1c8f888038a

ここで冒頭のブログにつながるのですが、Dockerさえあれば、OSが違っても同じように動きます。(Windows以外やってないけど)

Dockerそのままでやってもいいのですが、前々から気になっていたFinchを使ってみました。

Finchとは?

FinchはAWSが開発しているオープンソースのコンテナ開発環境です。

github.com_runfinch_finch_blob_main_README.md.png

可愛いアイコンが素敵です。

基本的にはDockerと同じように使える感じです。

Finchのインストール

インストーラーをダウンロードしてウィザードに従うだけです。

image.png

image.png

image.png

image.png

image.png

Finchの初期設定

FinchにはGUIは用意されていないので、コマンドで実行します。
VMを準備します。

finch vm init
time="2024-12-24T20:43:54+09:00" level=info msg="attaching disk at path: C:\\Users\\******\\AppData\\Local\\.finch\\.disks\\6b456cb759bdbc3f.vhdx"
time="2024-12-24T20:43:56+09:00" level=info msg="Initializing and starting Finch virtual machine..."
time="2024-12-24T20:45:21+09:00" level=warning msg="Finch on Windows uses WSL, which mounts the C Drive in read-write mode by default. To run finch with more restricted access, follow https://runfinch.com/docs/managing-finch/windows/wsl-configuration/"
time="2024-12-24T20:45:21+09:00" level=info msg="Finch virtual machine started successfully"

Finch virtual machineが起動しました。WSLのディストリビューションとしてlima-finchが追加されます。

wsl --list
Ubuntu-20.04 (既定)
Ubuntu-22.04
lima-finch

PC再起動後などは、以下のコマンドでFinchのVMを起動する必要があります。

finch vm start

これで初期設定は完了です。コンテナを一つ起動してみましょう。

finch run --rm public.ecr.aws/finch/hello-finch

                            @@@@@@@@@@@@@@@@@@@
                        @@@@@@@@@@@@    @@@@@@@@@@@
                      @@@@@@@                  @@@@@@@
                    @@@@@@                        @@@@@@
                  @@@@@@                            @@@@@
                 @@@@@                      @@@#     @@@@@@@@@
                @@@@@                     @@   @@@       @@@@@@@@@@
                @@@@%                     @     @@            @@@@@@@@@@@
                @@@@                                               @@@@@@@@
                @@@@                                         @@@@@@@@@@@&
                @@@@@                                  &@@@@@@@@@@@
                 @@@@@                               @@@@@@@@
                  @@@@@                            @@@@@(
                   @@@@@@                        @@@@@@
                     @@@@@@@                  @@@@@@@
                        @@@@@@@@@@@@@@@@@@@@@@@@@@
                            @@@@@@@@@@@@@@@@@@


Hello from Finch!

Visit us @ github.com/runfinch

なんか出た!!

Docker Hubで公開されているMCPのコンテナイメージ

Docker HubにMCPネームスペースが登場しています。

2024/12/24時点で以下のイメージが登録されています。

  • mcp/aws-kb-retrieval-server
  • mcp/brave-search
  • mcp/everart
  • mcp/everything
  • mcp/fetch
  • mcp/filesystem
  • mcp/git
  • mcp/github
  • mcp/gitlab
  • mcp/gdrive
  • mcp/google-maps
  • mcp/memory
  • mcp/postgres
  • mcp/puppeteer
  • mcp/sentry
  • mcp/sequentialthinking
  • mcp/slack
  • mcp/sqlite
  • mcp/time

Model Context Protocol serversのGitHubリポジトリにあるReference Serversがすべて登録されています。

Claude.aiデスクトップアプリにMCPの設定を行う

  1. Claude.aiのデスクトップアプリを起動します

    image.png

  2. 「File」メニューの「Settings」を選択します

    image.png

  3. 「Edit Config」をクリックします

    image.png

  4. エクスプローラーが起動し、claude_desktop_config.jsonが選択された状態になると思いますので、claude_desktop_config.jsonを開きます

    claude_desktop_config.json(編集前)
    {
      "globalShortcut": "Alt+Ctrl+Space"
    }
    
  5. こちらを参考にBrave Searchの設定を追加します

    • commandが「finch」になってます
    • 「YOUR_API_KEY_HERE」は実際のAPIキーに変更します
      {
        "globalShortcut": "Alt+Ctrl+Space",
    +   "mcpServers": {
    +     "brave-search": {
    +       "command": "finch",
    +       "args": [
    +         "run",
    +         "-i",
    +         "--rm",
    +         "-e",
    +         "BRAVE_API_KEY",
    +         "mcp/brave-search"
    +       ],
    +       "env": {
    +         "BRAVE_API_KEY": "YOUR_API_KEY_HERE"
    +       }
    +     }
    +   }
      }
    
  6. 設定完了後、一度Claude.aiのデスクトップアプリを終了します
    (タスクバーに常駐しているアイコンから一旦終了します)

  7. 再度アプリを起動すると、カナヅチ(?)アイコンが表示されます

    image.png

    クリックすると、MCPツールとして追加した「brave_local_search」と「brave_web_search」が表示されます

    ※brave-searchのMCPサーバーにはツールが2つ含まれています

    image.png

Brave検索を使ってみよう

「Amazon Novaについて検索して、Anthropicのモデルとの違いを教えて」と入力してみます。
MCPツールを使用する際に同意を求めるダイアログが表示されます。

このあたり、セキュリティを意識してる感じがして好感が持てますね

image.png

検索して回答を生成してくれました。

image.png

検索に使ったクエリーも確認可能です。

image.png

おーすごい!!!


なんですが、意外と使いづらいですww

先程の質問ですが、わざと 「検索して」 と入れて実行してまして、この文言を除くとMCPツールは使わずに生成AIの知ってることだけで回答しようとします。

image.png

ザ・ハルシネーション

まだまだプロンプト力が求められますね。

  1. *****を検索して
  2. xxxxxを検索して
  3. 検索した結果からzzzzzについて教えて

みたいに指示する必要がありそうです。

8
2
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
8
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?