Bước 1 Step 1 ជំហាន 1
Tạo MCP server Create Your MCP Server បង្កើត MCP server
- Chúng ta đang xây What we're building អ្វីដែលយើងកំពុងសង់
- A Cloudflare Workers-based MCP server that AI assistants can connect to and use.
- Vì sao quan trọng Why this matters ហេតុអ្វីសំខាន់
- Cloudflare Workers provide global deployment with minimal latency, making your MCP tools available worldwide.
# Create new MCP server from template
npm create cloudflare@latest -- my-mcp-server --template=cloudflare/ai/demos/remote-mcp-authless
# Navigate to your project
cd my-mcp-server
# Install dependencies and start development server
npm install
npm run dev ⛅️ wrangler 4.64.0
───────────────────
Your Worker has access to the following bindings:
Binding Resource Mode
env.MCP_OBJECT (MyMCP) Durable Object local╭──────────────────────────────────────────────────────────────────────╮
│ [b] open a browser [d] open devtools [c] clear console [x] to exit │
╰──────────────────────────────────────────────────────────────────────╯
⎔ Starting local server…
[wrangler:info] Ready on http://localhost:8787 - npm not found: Install Node.js v20+ from nodejs.org
- Template not found: Update npm: npm install -g npm@latest
- Port 8787 busy: Stop other services or use npm run dev -- --port 8788
- Build errors: Delete node_modules and run npm install again
- Inspector won’t connect: Verify your MCP server is running on http://localhost:8787 and the endpoint is /mcp
- No tools visible: Check server logs for errors. The template should provide basic tools by default.
Bước 2: Test bằng MCP Inspector Step 2: Test with MCP Inspector ជំហាន 2: Test ដោយ MCP Inspector
- Chúng ta đang xây What we're building អ្វីដែលយើងកំពុងសង់
- A connection between the MCP Inspector and your server to verify functionality and test tools.
- Vì sao quan trọng Why this matters ហេតុអ្វីសំខាន់
- The inspector is the easiest way to verify your MCP server is working and explore available tools.
# In a new terminal window (keep your server running)
npx @modelcontextprotocol/inspector Quy trình kết nối Inspector: Inspector Connection Process: ដំណើរការភ្ជាប់ Inspector៖
- The inspector starts at http://localhost:6274/?MCP_PROXY_AUTH_TOKEN=[your_token]
- Open this URL in your browser (the inspector will do this automatically)
- Make sure “Streamable HTTP” is the Transport Type
- Enter http://localhost:8787/mcp as the URL
- Click “Connect” to establish the connection
- Make sure you’re on the “Tools” tab
- Click “List Tools”
- Click the “add” tool and run it with 2 numbers
You now have a functional MCP server that AI assistants can connect to and use!
You now have a functional MCP server that AI assistants can connect to and use!
You now have a functional MCP server that AI assistants can connect to and use!