MCP Server with Cloudflare Workers
Cloudflare Workersを使用したMCPサーバー
導入
モデルコンテキストプロトコル(MCP)は、AIエージェントとアシスタントがサービスとやり取りできるようにするオープンスタンダードです。MCPサーバーを設定することで、AIアシスタントがAPIに直接アクセスできるようになります。
Cloudflare Workers は、 workers-mcpパッケージと組み合わせることで、MCP サーバーを構築するための強力でスケーラブルなソリューションを提供します。
Related MCP server: Remote MCP Server
前提条件
始める前に、次のものを用意してください。
Node.jsがインストールされている
Wrangler CLI がインストールされている (
npm install -g wrangler)
はじめる
ステップ1: 新しいCloudflareワーカーを作成する
まず、新しい Cloudflare Worker プロジェクトを初期化します。
npx create-cloudflare@latest my-mcp-worker
cd my-mcp-worker次に、Cloudflare アカウントを認証します。
wrangler loginステップ2: Wranglerを構成する
正しいアカウント詳細でwrangler.tomlファイルを更新します。
name = "my-mcp-worker"
main = "src/index.ts"
compatibility_date = "2025-03-03"
account_id = "your-account-id"MCPツールのインストール
MCP サポートを有効にするには、 workers-mcpパッケージをインストールします。
npm install workers-mcpMCP を構成するには、セットアップ コマンドを実行します。
npx workers-mcp setupこれにより、次のようになります。
必要な依存関係を追加する
テスト用にローカルプロキシを設定する
MCPコンプライアンスのためにWorkerを構成する
MCP サーバーコードの作成
src/index.tsを更新して MCP サーバーを定義します。
import { WorkerEntrypoint } from 'cloudflare:workers';
import { ProxyToSelf } from 'workers-mcp';
export default class MyWorker extends WorkerEntrypoint<Env> {
/**
* A friendly greeting from your MCP server.
* @param name {string} The name of the user.
* @return {string} A personalized greeting.
*/
sayHello(name: string) {
return `Hello from an MCP Worker, ${name}!`;
}
/**
* @ignore
*/
async fetch(request: Request): Promise<Response> {
return new ProxyToSelf(this).fetch(request);
}
}主要コンポーネント:
WorkerEntrypoint : 受信リクエストとメソッドの公開を管理します。
ProxyToSelf : MCP プロトコルの準拠を保証します。
sayHello メソッド: AI アシスタントが呼び出すことができる MCP 関数の例。
API呼び出しの追加
外部APIを統合することで、MCPサーバーを拡張できます。以下は天気データを取得する例です。
export default class WeatherWorker extends WorkerEntrypoint<Env> {
/**
* Fetch weather data for a given location.
* @param location {string} The city or ZIP code.
* @return {object} Weather details.
*/
async getWeather(location: string) {
const response = await fetch(`https://api.weather.example/v1/${location}`);
const data = await response.json();
return {
temperature: data.temp,
conditions: data.conditions,
forecast: data.forecast
};
}
async fetch(request: Request): Promise<Response> {
return new ProxyToSelf(this).fetch(request);
}
}MCPサーバーの展開
Worker をセットアップしたら、Cloudflare にデプロイします。
npx wrangler deploy展開後、Worker が稼働し、AI アシスタントが MCP ツールを検出して使用できるようになります。
MCP サーバーを更新するには、次のコマンドで再デプロイします。
npm run deployMCPサーバーのテスト
MCP セットアップをローカルでテストするには:
npx workers-mcp proxyこのコマンドは、MCP クライアント (Claude Desktop など) が接続できるようにローカル プロキシを起動します。
安全
MCP サーバーを保護するには、Wrangler Secrets を使用します。
npx wrangler secret put MCP_SECRETこれにより、不正アクセスを防ぐための共有秘密認証メカニズムが追加されます。
結論
おめでとうございます!Cloudflare Workersを使用してMCPサーバーを構築し、デプロイしました。これで、さらに多くの機能を追加して拡張し、AIアシスタント用の新しいツールを公開できるようになりました。
詳細については、 Cloudflare MCP ドキュメントを参照してください。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Cloudflare Workers MCP server: ai-model-router
The Telnyx MCP server is an official implementation of the Model Context Protocol that enables AI clients (like Claude Desktop, Cursor, and OpenAI Agents) to interact with Telnyx's telephony, messaging, and AI assistant APIs. It provides comprehensive capabilities including making and managing phone calls, sending SMS/MMS messages, purchasing and configuring phone numbers, creating AI assistants with custom instructions, managing cloud storage buckets, scraping and embedding website content, and handling integration secrets. The server exists as both a local implementation and a remotely hosted version, allowing developers to integrate real-world communication infrastructure directly into AI applications.
Related MCP Servers
AlicenseNot gradedqualityFmaintenanceA server that implements the Model Context Protocol (MCP) on Cloudflare Workers, allowing AI models to access custom tools without authentication.151MIT- FlicenseNot gradedqualityDmaintenanceA deployable Model Context Protocol server for Cloudflare Workers that enables AI models to use custom tools without authentication requirements.
- FlicenseNot gradedqualityCmaintenanceA serverless implementation of Model Context Protocol on Cloudflare Workers that enables connecting AI assistants like Claude to custom tools without authentication.
- FlicenseNot gradedqualityCmaintenanceA deployable Model Context Protocol server on Cloudflare Workers that enables AI tools integration without authentication requirements.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/sivakumarl/my-mcp-worker'
If you have feedback or need assistance with the MCP directory API, please join our Discord server