Model Context Protocol Model Context Protocol Model Context Protocol · Lab 4/7 Lab 4/7 Lab 4/7 · 25 phút · 25 min · 25 នាទី

04

Deploy lên Cloudflare Workers Deploy to Cloudflare Workers Deploy ទៅ Cloudflare Workers

Deploy MCP server lên Workers để dùng toàn cầu, rồi test trên AI Playground. Deploy your MCP server to Cloudflare Workers for global availability and test it with AI Playground. Deploy MCP server ទៅ Workers ដើម្បីប្រើទូទាំងពិភពលោក បន្ទាប់មក test លើ AI Playground។

Nội dung bước (lệnh, code) giữ nguyên tiếng Anh từ nguồn chính thức. Step body (commands, code) stays in English from the official source. ខ្លឹមសារជំហាន (ពាក្យបញ្ជា និង code) រក្សាភាសាអង់គ្លេសពីប្រភពផ្លូវការ។ labs.cloudflare.dev ↗

Cần trước Prerequisites តម្រូវការជាមុន

  • Đã xong bước 3 Completed Step 3 បានបញ្ចប់ជំហាន 3
  • Tài khoản Cloudflare Cloudflare account គណនី Cloudflare
  • Đã cài Wrangler CLI Wrangler CLI installed បានដំឡើង Wrangler CLI

Bạn sẽ làm được Learning objectives គោលបំណងសិក្សា

  • Deploy MCP server lên Cloudflare Workers Deploy MCP servers to Cloudflare Workers Deploy MCP server ទៅ Cloudflare Workers
  • Cấu hình môi trường production Configure production environment settings កំណត់បរិស្ថាន production
  • Test server đã deploy trên AI Playground Test deployed servers with AI Playground Test server ដែលបាន deploy លើ AI Playground
  • Monitor và debug bản deploy production Monitor and debug production deployments Monitor និង debug ការដាក់ឱ្យប្រើ production

Bước 1: Deploy MCP server Step 1: Deploy Your MCP Server ជំហាន 1: Deploy MCP server

Chúng ta đang xây What we're building អ្វីដែលយើងកំពុងសង់
A globally deployed MCP server running on the edge network for low-latency access worldwide.
Vì sao quan trọng Why this matters ហេតុអ្វីសំខាន់
Production deployment makes your MCP server accessible to AI assistants and provides real-world testing capabilities.
bash
# Login to Cloudflare (if not already done)
$ npx wrangler login

# Deploy to Workers
$ npm run deploy

Once deployed (usually 30-60 seconds), copy the deployment URL from the output. Your MCP endpoint will be at https://my-mcp-server.[your-account].workers.dev/mcp.

Once deployed (usually 30-60 seconds), copy the deployment URL from the output. Your MCP endpoint will be at https://my-mcp-server.[your-account].workers.dev/mcp.

Once deployed (usually 30-60 seconds), copy the deployment URL from the output. Your MCP endpoint will be at https://my-mcp-server.[your-account].workers.dev/mcp.

Bước 2: Test trên AI Playground Step 2: Test with AI Playground ជំហាន 2: Test លើ AI Playground

Now for the fun part - connecting your deployed MCP server to an actual AI assistant.

Now for the fun part - connecting your deployed MCP server to an actual AI assistant.

Now for the fun part - connecting your deployed MCP server to an actual AI assistant.

🎮 Test trên AI Playground: 🎮 AI Playground Testing: 🎮 Test លើ AI Playground៖

  1. Visit the AI Playground
  2. Create a new chat session
  3. Click the “Tools” button in the interface
  4. Add your MCP server URL: https://your-worker.workers.dev/mcp (make sure to include /mcp)
  5. Click “Connect” and verify tools are loaded
  6. Test your tools by asking the AI to use them
  7. Example: “Generate a random number between 1 and 100”

How cool is that? An LLM was able to call the tool you built, deployed globally on our edge network!

How cool is that? An LLM was able to call the tool you built, deployed globally on our edge network!

How cool is that? An LLM was able to call the tool you built, deployed globally on our edge network!