XiaoZhi MCP Bridge
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@XiaoZhi MCP BridgeWhat is the capital of France?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
XiaoZhi MCP Bridge (Cloudflare Workers + Durable Objects)
Bridge MCP custom untuk agent XiaoZhi AI (robot TK Islam Terpadu), di-deploy ke Cloudflare, tanpa perlu VM/server terpisah untuk menjaga koneksi tetap hidup.
Kenapa Ini "Worker + Durable Objects", Bukan "Pages" Murni
Permintaan awal adalah project Cloudflare Pages. Setelah dicek ke dokumentasi resmi Cloudflare, ada dua fakta yang mengubah pendekatannya:
Pola resmi XiaoZhi (
mcp_pipe.py) butuh koneksi WebSocket yang hidup terus-menerus kewss://api.xiaozhi.me/mcp/?token=..., dengan reconnect otomatis. Ini butuh compute yang stateful/persisten, bukan model request-response biasa.Cloudflare Pages tidak bisa mendefinisikan Durable Object di dalam project Pages itu sendiri — dokumentasi resminya eksplisit menyebut "You cannot create and deploy a Durable Object within a Pages project." Durable Object wajib didefinisikan di project Workers, baru di-bind ke Pages kalau mau dipakai dari sana.
Karena kebutuhan intinya murni tentang menjaga koneksi tetap hidup (bukan menyajikan halaman statis), project ini dibuat sebagai Cloudflare Worker langsung — masih pakai wrangler.toml, masih wrangler deploy, masih env variable/secret dari dashboard yang sama, cuma bukan dengan wrangler pages deploy. Secara praktis, workflow-nya identik dengan yang biasa kamu pakai untuk Cloudflare Pages.
Kabar baiknya: Durable Objects dengan SQLite storage backend (yang dipakai project ini) tersedia di Workers Free plan — tidak wajib upgrade ke Paid plan.
Related MCP server: Remote MCP Server (Authless)
Struktur Project
xiaozhi-mcp-bridge/
├── wrangler.toml # Konfigurasi Worker, Durable Object binding, cron trigger
├── package.json
├── tsconfig.json
├── src/
│ ├── index.ts # Entry point: fetch handler + cron scheduled handler
│ ├── mcp-bridge.ts # Durable Object: koneksi WebSocket + protokol JSON-RPC MCP
│ └── tools/
│ └── index.ts # Definisi & implementasi tools (cek_jawaban_angka, catat_ringkasan_sesi)
├── .github/workflows/
│ └── deploy.yml # Auto-deploy ke Cloudflare saat push ke main
├── .dev.vars.example # Contoh env var untuk development lokal
└── .gitignoreAsumsi Teknis yang Perlu Diverifikasi
Implementasi mcp-bridge.ts menerjemahkan protokol MCP (initialize, tools/list, tools/call) langsung dalam JavaScript, menggantikan peran mcp_pipe.py + subprocess Python.
Asumsi yang saya pakai: setiap pesan JSON-RPC dikirim sebagai satu frame WebSocket utuh (karena WebSocket sudah punya framing bawaan, beda dengan stdio yang butuh newline-delimited). Ini asumsi paling masuk akal berdasarkan cara kerja mcp_pipe.py yang murni membridging byte antara WebSocket dan stdio subprocess — tapi saya tidak punya akses ke source code mcp_pipe.py untuk memverifikasi ini byte-per-byte.
Wajib ditest setelah deploy — lihat bagian Verifikasi di bawah. Kalau ternyata tidak jalan karena masalah framing, opsi cadangannya adalah menjalankan mcp_pipe.py + tool Python asli di dalam Cloudflare Containers (fitur yang lebih baru, butuh Workers Paid plan) alih-alih reimplementasi ulang di JavaScript — beri tahu saya kalau perlu dibuatkan versi itu.
Setup
npm install
npm install -g wrangler # kalau belum ada
wrangler loginDevelopment Lokal
cp .dev.vars.example .dev.vars
# edit .dev.vars, isi MCP_ENDPOINT dengan token asli
npm run devDeploy
npm run deploySetelah deploy pertama kali, isi secret MCP_ENDPOINT (pilih salah satu):
# Opsi 1: CLI
wrangler secret put MCP_ENDPOINT
# lalu paste: wss://api.xiaozhi.me/mcp/?token=xxxxx
# Opsi 2: Dashboard
# Workers & Pages -> xiaozhi-mcp-bridge -> Settings -> Variables and Secrets
# -> Add -> Type: Secret -> Name: MCP_ENDPOINT -> Value: wss://api.xiaozhi.me/mcp/?token=xxxxxSetelah secret diisi, redeploy sekali lagi (npm run deploy) supaya cron trigger langsung mencoba koneksi.
Verifikasi
Cek status koneksi:
curl https://xiaozhi-mcp-bridge.<subdomain-kamu>.workers.dev/statusHarus muncul
"status": "connected"dalam 1-2 menit setelah deploy (menunggu cron trigger pertama).Cek log real-time:
npm run tailCari baris
"Terhubung ke XiaoZhi MCP endpoint."Cek status di panel XiaoZhi (Configure Role -> MCP Settings -> Custom Services -> Get MCP Endpoint) — status harus berubah dari Not Connected menjadi Connected.
Uji tool call: tanyakan sesuatu ke robot yang memicu tool (misalnya soal kuis angka), lalu cek log (
npm run tail) apakah baristools/callmuncul dan tidak error.Cek ringkasan sesi tersimpan:
curl https://xiaozhi-mcp-bridge.<subdomain-kamu>.workers.dev/sessions
Kalau langkah 1-3 berhasil tapi langkah 4 gagal atau error, kemungkinan besar asumsi framing di atas perlu direvisi — laporkan isi log-nya untuk didiagnosis lebih lanjut.
Menambah Tool Baru
Edit src/tools/index.ts:
Tambah entri ke
TOOL_DEFINITIONS(name, description yang jelas kapan dipakai, inputSchema)Tambah
casebaru diexecuteTool()
Tidak perlu ubah mcp-bridge.ts — dispatch tool sudah generik.
GitHub Actions (Opsional)
Kalau mau auto-deploy setiap push ke main, isi 2 secret di GitHub repo (Settings -> Secrets and variables -> Actions):
CLOUDFLARE_API_TOKEN— buat di dash.cloudflare.com/profile/api-tokens (scope: Edit Cloudflare Workers)CLOUDFLARE_ACCOUNT_ID— terlihat di sidebar kanan dashboard Cloudflare
MCP_ENDPOINT tetap di-set terpisah lewat wrangler secret put, tidak lewat GitHub Actions — supaya token tidak pernah lewat CI logs.
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.
Latest Blog Posts
- 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/farisi55/xiaozhi-mcp-bridge'
If you have feedback or need assistance with the MCP directory API, please join our Discord server