1
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?

Cloudflare を使い倒す Deploy to Cloudflare 編

1
Last updated at Posted at 2025-12-22

ネタ切れ、時間切れ、ボロボロになりかけの @toreis です。

最近 Cloudflare の Repository でよく見かけるこいつ。

image.png

こいつには "Deploy to Cloudflare button" というれっきとした名前があります (そのままやないかーい)。

ということで、こいつの正体について調べてみましょう。

Deploy to Cloudflare!

解説は Workers ドキュメントの中にありました。

Clone a Git repository: Cloudflare clones your source repository into the user's GitHub/GitLab account where they can continue development after deploying.

まずはデプロイ後も継続して開発できるように、 GitHub / GitLab レポジトリから Clone してくるところから始めます。

Configure a project: Your users can customize key details such as repository name, Worker name, and required resource names in a single setup page with customizations reflected in the newly created Git repository.

Deploy to Cloudflare ボタンを押すと、実際にデプロイする Worker の名前とか設定できます。

image.png

Build & deploy: Cloudflare builds the application using Workers Builds and deploys it to the Cloudflare network. Any required resources are automatically provisioned and bound to the Worker without additional setup.

実際には Workers Builds が動いていて、この先 GitHub, GitLab に push すると、CD が動いて勝手にデプロイし続けてくれます。

使い方

なにか特殊なことをしているわけではありません。

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=<your git repo URL>)

これで、Git Repo URL を入れたら完成です。リポジトリのサブディレクトリも使えるそうです。(未検証)

例えば Workers に Bindings があって、R2 Buckets とか使うプロダクトなんだよな…ってときにも、自動的に設定してくれます。現状、自動的に設定してくれるのは以下のサービスです。

Storage:

  • KV namespaces
  • D1 databases
  • R2 buckets
  • Hyperdrive
  • Vectorize databases
  • Secrets Store Secrets

Compute:

  • Durable Objects
  • Workers AI
  • Queues

まあ便利なこったで。

デプロイしてみる

ここでは、Cloudflare が公開している authless MCP サーバーのデモをちょっと変更したやつを使います。

Deploy to Cloudflare

上のボタンを押すと、デプロイの設定画面に飛びます。

image.png

好きなコマンドでデプロイしてください。Workers Builds なら bun とか pnpm とかあります。

で、デプロイすると、ビルドログがブワーッと出て

image.png

ログ中の下あたりに Deployed remote-mcp-server-authless0test triggers (0.75 sec) と、その下に URL があります。これがデプロイされた場所です。

これは MCP サーバーなので、そのままブラウザでアクセスしても何も出ません。

ということで、MCP 公式が出している Inspector を使って、チェックしてみます。

npx @modelcontextprotocol/inspector で Inspector を起動すると、こんな画面が出てきます。

image.png

ので、設定を以下の画面のようにいじります。

image.png

上から Transport Type を SSE、URL はさっきの URLで、後ろに /sse を付与します。
Connection Type は Direct にします。

そしたらボタンたちの一番下にある Connect ボタンを押します。

image.png

つながりました!

Tools の List Tools を押すと、実装されているツールが表示されます。
ここでは addcalculate が実装されています。

image.png

add を押して、ab に適当に数字を入れて Run Tool を実行してみますと

image.png

Tool Result: Success と、処理結果が表示されます。正しいですね。

これで、GitHub に Repository を公開して、「やってみてね」ができるようになりました。

終わりに

Deploy to Cloudflare ボタンが自分で作れるとは思っていませんでした。

Cloudflare のレポジトリを見ているとたまに見かけることができますので、デモを試してみるのもありかもしれませんね :boom: (爆発オチ)

1
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
1
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?