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 Worker 만들기
먼저, 새로운 Cloudflare Worker 프로젝트를 초기화합니다.
지엑스피1
그런 다음 Cloudflare 계정을 인증하세요.
wrangler login2단계: 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