CloudflareでセルフホストAIエージェント「Moltworker」を構築した全記録

Written by
John Doe
Published on
2026-01-31

目次

CloudflareでセルフホストAIエージェント「Moltworker」を構築した全記録

2026年に入って、AIアシスタントはもう珍しいものではなくなった。ただ、どのサービスも結局はクラウド頼みで、自分のデータがどこにあるのか、どう使われているのか、正直よくわからない。そんなモヤモヤを抱えていたときに見つけたのが、Cloudflareがオープンソースで公開している「Moltworker」だった。

MoltworkerはOpenClaw(昔はMoltbotと呼ばれていた)というパーソナルAIアシスタントを、Mac miniのような専用マシンなしで動かせるようにするプロジェクトだ。Cloudflareのエッジコンピューティング基盤を使うから、自前でサーバーを用意する必要がない。面白そうだと思って実際に構築してみたので、その過程を残しておく。

構築前に揃えておくもの

まず前提として、Moltworkerを動かすにはCloudflare Workersの有料プラン(月5ドル)が必要になる。Cloudflare Sandboxというコンテナ実行環境を使うためだ。あとはAnthropic APIキーも用意しておく。

GitHubからリポジトリをクローンして、依存関係をインストールするところから始めた。

git clone https://github.com/cloudflare/moltworker.git
cd moltworker
npm install

次にWranglerでCloudflareにログインする。ブラウザが開いて認証を求められるのだが、最初の試行ではタイムアウトしてしまった。もう一度やったら通ったので、ネットワークの調子が悪かっただけだろう。こういう一時的なトラブルは気にしても仕方がない。

認証情報はCloudflareのシークレット管理機能で保存する。まずリモートアクセス用のゲートウェイトークンを生成した。

export MOLTBOT_GATEWAY_TOKEN=$(openssl rand -hex 32)

このトークンはControl UIにアクセスするときに使う。後で必要になるから、どこかに控えておかないといけない。

Anthropic APIキーの設定にはwrangler secret putを使う。値は暗号化されてCloudflareに保存される仕組みだ。この時点ではWorkerがまだ存在しないので「新規作成するか」と聞かれるが、Yesで問題ない。

Dockerが入っていなかった

さて、いよいよデプロイだと意気込んだところで、いきなりつまずいた。「The Docker CLI could not be launched」というエラーが出たのだ。

考えてみれば当然で、Moltworkerはコンテナをビルドする必要があるから、ローカルにDockerがないと動かない。確認したら案の定、Docker Desktopが入っていなかった。Homebrewでインストールしようとしたが、sudo権限を要求されてターミナルでパスワードを打つ羽目になった。

brew install --cask docker

インストール後にDocker Desktopを起動して、デーモンが完全に立ち上がるまで待つ。docker infoで動作確認してから次に進んだ。

デプロイ、エラー、また調べる、の繰り返し

Dockerが準備できたので再びデプロイを実行。ところが、ここからが本当の試練だった。

最初に出たエラーは「Please enable R2 through the Cloudflare Dashboard」。R2はCloudflareのオブジェクトストレージで、Moltworkerのデータ保存に使われる。ダッシュボードに行ってR2を有効化した。無料枠があるから、普通に使う分には追加料金はかからない。

R2を有効にして再挑戦すると、今度は「You need a workers.dev subdomain」と言われた。Workers & Pagesのページを開けば自動的に作成されるらしい。ただ、Cloudflareのダッシュボードがリニューアルされていて、「Compute & AI」というセクションの中から「Workers & Pages」を探す必要があった。慣れていないと迷う。

サブドメインができたので再度デプロイ。ビルドは順調に進み、Dockerイメージの構築、Cloudflareレジストリへのプッシュと来たところで、最後の最後に「Unauthorized」。

調べてみると、Containers機能を使うにはWorkers有料プランが必須だった。ダッシュボードの「Containers」ページから月額5ドルのプランに加入して、ようやく先に進めた。

デプロイ成功、でもまだ終わらない

有料プランにアップグレードした後、デプロイはあっさり成功した。コンソールに新しいWorkerのURLが表示される。

https://moltbot-xxxxxxx.workers.dev

でも、これで終わりではなかった。セキュリティとデータ永続化のために、まだ設定が残っている。

Admin UIを保護するためにCloudflare Accessを設定する。Workers & Pagesでデプロイ済みのWorkerを選んで、Settings > Domains & Routesからworkers.devの行を探し、「Enable Cloudflare Access」を選択。Accessの設定にはチームドメインとApplication Audience(AUD)という二つの値が必要で、AUDはAccess設定画面から取得、チームドメインはZero Trustダッシュボードで確認できる。

npx wrangler secret put CF_ACCESS_AUD
npx wrangler secret put CF_ACCESS_TEAM_DOMAIN

コンテナは再起動するとデータが消える可能性があるから、R2ストレージとの連携も重要だ。R2ダッシュボードでAPI Tokenを新規作成し、権限を「Object Read & Write」、対象バケットを「moltbot-data」に限定した。生成されたAccess Key IDとSecret Access Key、それからCloudflareアカウントIDをシークレットとして登録する。

npx wrangler secret put R2_ACCESS_KEY_ID
npx wrangler secret put R2_SECRET_ACCESS_KEY
npx wrangler secret put CF_ACCOUNT_ID

初回アクセスでまたエラー

すべての設定を終えて、いざControl UIにアクセス。URLにゲートウェイトークンをクエリパラメータとして付ける。

https://moltbot-xxxxxxx.workers.dev/?token=<GATEWAY_TOKEN>

開いた瞬間、「Configuration Required」というエラーが出た。ANTHROPIC_API_KEYが認識されていないと言う。シークレットの一覧を見直したら、設定時に変数名と値を逆に入力していたことに気づいた。自分のミスだ。正しく設定し直して再デプロイ。

再度アクセスすると、今度は「Pairing required」と表示された。これはセキュリティ機能で、新しいデバイスからの接続には管理者の承認がいる。Admin UI(/_admin/パス)に行って、Pending Pairing Requestsから自分のデバイスを承認した。

承認してからControl UIに戻ってリロードしたら、ついにチャット画面が現れた。試しに「こんにちは」と送ったら、英語で自己紹介が返ってきた。日本語で返すように指示を出せば、それ以降は日本語で会話できるようになる。

振り返ってみて思うこと

今回の構築で感じたのは、Cloudflareのエコシステムの統合度の高さだ。Workers、R2、Access、Containersといった複数のサービスがシームレスにつながっている。ただ、その分だけ初期設定で有効にしなければならないサービスが多く、一つでも欠けるとデプロイが失敗する。エラーメッセージは親切なほうだと思うが、ダッシュボードの構成に慣れていないと該当の設定画面を見つけるのに手間取る。

シークレット管理も注意が必要だ。wrangler secret putはインタラクティブに値を入力する設計だが、スクリプト化するならパイプで値を渡すこともできる。ただし、変数名と値を取り違えないように気をつけないといけない。実際にやらかした。

あと、Dockerの存在を見落としがちだ。Cloudflare Sandboxはサーバーレスコンテナ環境だが、イメージのビルドはローカルで行われる。開発マシンにDockerが入っているか、事前に確認しておくとスムーズに進む。

月5ドルで手に入る自分専用AI

MoltworkerによるセルフホストAIの構築は、正直言って簡単ではなかった。でも一度セットアップしてしまえば、自分専用のAIアシスタントが常時動く環境が手に入る。データはCloudflareのインフラ上に保管されるし、R2との連携でコンテナが再起動してもセッション情報は維持される。

月額5ドルでエンタープライズグレードのインフラにパーソナルAIを置けるのは、なかなか魅力的だと思う。プライバシーが気になる人や、AIアシスタントを自分好みにいじりたい人には、検討してみる価値があるんじゃないだろうか。

Relation

関連記事

This is some text inside of a div block.

CloudflareでセルフホストAIエージェント「Moltworker」を構築した全記録

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

ポストに届いた「心理操作の教科書」を全ページ解剖してみた ——行動経済学で読み解く、セールスレターの見えない設計

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

NotebookLMとAntigravityで開発を自動化|マーケ担当でも実践できる連携術

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

AIを使ったSEO記事自動化テスト

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

テスト記事

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

Claude Code使い方完全ガイド 2025年最新版・入門から応用まで

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

GoogleのNotebookLMがついにGeminiと統合、AI研究ツールが新時代へ

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

Googleの新兵器「Titans」がAIの記憶力を劇的に変える? Transformerを超える長期記憶の謎に迫る

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

Google Antigravityの使い方を徹底解説|AIで誰でもアプリ開発できる時代へ

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

医療記事を自動で書くAIを作ったら、思わぬ壁にぶつかった話

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

月400万円の広告費が泡と消えたあの日、僕が「丸投げ」を辞めようと決意した話

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

Webflow Conf 2025で発表された新機能がヤバい件について、現場目線で語ってみる

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

【速報】Claude Code on the web登場!ブラウザとスマホで始める次世代AIコーディングが到来!

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

Claude Skillsでチームの生産性を上げる実践的な使い方と活用例

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

Gensparkで超ラクに環境設定!Claude CodeとGemini CLIを実際に体験してみた

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

AIを真に賢くする『コンテキストエンジニアリング』とは?

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

Webflow Conf 2025に参加して感じた、ウェブ制作の「これから」の話

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

Googleビジネスプロフィールの投稿は本当に検索順位を上げるのか?調査結果をわかりやすく解説

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

Ahrefsで解明!AIに引用される企業になるための5つの戦略 - マーケター10年の実践ノウハウ

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

ChatGPTが変えた検索の未来:マーケターが知るべき流入減少の真実と対策

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

ホーキンズさんの著者『パワーかフォース』をセールスページに活かしてみた

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

WordPress MCPとClaude Desktopで業務効率が3.5倍に!自動投稿からファイル編集まで完全自動化した私の体験談

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

MCP Toolbox for Databases完全ガイド!AIエージェントとデータベースを安全に連携する革新的ツール

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

GoogleのApertureDBが変える未来!身近な例で理解する次世代データベースの革命

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

Googleの最新技術「MUVERA」!検索体験を根底から変える新時代アルゴリズム

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

AI時代のSEO戦略!検索エンジンの進化に対応し、治療院の集客を事例にGEOの重要性を語ります

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

AIが広告を変える!Google AI Max for Search Campaignと広告の未来

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

クエリファンアウトとは?GoogleのAI Modeが変える検索の未来と身近な例で理解する仕組み

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

生成AI時代の新潮流「LLMO対策」とは?ウェブサイトが生き残るための必須戦略

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

読まれ、評価されるコンテンツとは?検索意図から学ぶSEOライティングの極意

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

【実体験】Webflow AIで制作時間1/3に!コード不要で『売れる』サイトを作る新常識

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

効率的にウェブ制作を習得する方法〜脳科学に基づいた最適な学習法〜

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

Webflowでコーディングは必要?ノーコードでできることとできないことを徹底解説

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

消費者心理を味方につける、効果的な広告コピーライティングの秘訣

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

【GA4だけじゃ物足りない?】EBiS vs Usermaven アクセス解析ツール徹底比較!

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

マーケティングを変革する一手!WebflowとClayの連携で実現する効率化と自動化

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

Elementor Pro完全活用ガイド2025!カスタマイズから運用まで徹底解説

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

WebflowのCMSで記事の読了時間を自動計算して表示する方法

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

もう迷わない!Webflow SEO対策でサイト集客をアップさせる方法

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

【2024年最新】GSAPとは?Webflowとの統合で変わるアニメーション制作の未来 | 完全解説

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

WordPressの課題とWebflowの利点!移行のメリットを分析してみた結果・・・

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

Firecrawlでウェブサイト全体のデータを抽出!基本理解と活用法まで徹底解説

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

ビジネスを変える「物語」の力!メリットとデメリットを徹底解剖

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

【最新版】Webflowサイトをパワーアップする必見プラグインリスト

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

【2025年版】Elementorの使い方を初心者向けに解説!WordPressで本格サイト構築

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

集客に強いホームページの作り方!コツと方法を徹底解説

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

初心者でも月5万稼げる!副業としてウェブ制作を始める方法とは?

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

AIスキルを副業で活かす!初心者にも挑戦可能な11の方法を大公開

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

ノーコード技術で実現!これからの起業家が知るべきデジタルイノベーション

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

【料金から機能まで】WebflowとSTUDIOの比較分析!どちらを選ぶべきか?

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

SEO効果を高めるには、質の高いリンクを獲得することが重要!

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

Webflowコード出力機能でクリエイティブな自由を手に入れよう

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

Microsoft Copilot Studioとは?基本機能と活用法を徹底解説

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

コンセプトの作り方 - 顧客を魅了する設計の秘訣

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

ピアノ教室のホームページ制作はこれだけ読んでおけばOK!成功のための戦略と5つの事例紹介

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

OpenAIの新機能:GPTのカスタマイズ

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

プロンプトエンジニアリング初心者向けガイド

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

Webflowでウェブサイト構築!コーディング不要で誰でも簡単にサイトが作れる

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

Webflowを使ったUIデザインのメリット

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

Webflowの進化:デザイン、開発、コラボレーションの新たな可能性

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

AI時代の応用スキル:エクスペリエンス戦略とプロンプトデザイン

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

Webflowを活用したウェブサイトのパワーアップ:Fivetranのカスタマーストーリー

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

自分を表現するウェブサイトの作り方

This is some text inside of a div block.
7 min read
This is some text inside of a div block.

変化する市場に対応する:グローバルコンサルティング会社の視点

This is some text inside of a div block.
7 min read

現在【毎月先着5社様】限定無料相談受付ます

大変申し訳ありません。私たちのリソースには限りがあり、一社一社に質の高いサービスを提供するため、現在【毎月先着5社様】限定で、この特別な条件(全額返金保証+無料相談)でのご案内とさせていただいております。

さらに、今このページをご覧のあなただけに、無料相談へお申し込みいただいた方限定で、通常5万円相当の【競合サイト分析&改善提案レポート】を無料でプレゼントいたします。

枠がすぐに埋まる可能性がありますので、お早めにお申し込みください。

プライバシーポリシーに同意し、まずは無料相談をおこないます
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.