MCP Server (เชื่อมต่อ AI)
MCP server ช่วยให้คุณเชื่อมต่อ AI assistant (Claude Desktop, ChatGPT หรือ MCP client ตัวอื่น ๆ) เข้ากับบัญชี EasyDonate ของคุณได้โดยตรง เมื่อเชื่อมต่อแล้ว คุณสามารถถามด้วยภาษาพูดธรรมดาได้เลย เช่น "สัปดาห์นี้ได้เงินโดเนทเท่าไหร่" แล้ว assistant จะอ่านข้อมูลผ่าน public API ตัวเดียวกัน หรือควบคุมวิดเจ็ตจับเวลา ของคุณก็ได้
MCP server เป็น wrapper บาง ๆ ครอบ public API จึงใช้ API key และ scope ชุดเดียวกัน
สิ่งที่คุณต้องมี
- API key - สร้างได้ที่ หน้าจัดการโซนผู้พัฒนาAPI Keys แล้วเลือก scope ที่ต้องการให้ assistant ใช้งาน ดูรายละเอียด key และ scope ได้ที่ Authentication และ Scopes
- MCP client ตัวใดตัวหนึ่ง (ดูตัวอย่างด้านล่าง)
Endpoint คือ:
https://easydonate.app/mcpยืนยันตัวตนด้วย API key แบบ Bearer token เหมือนกับ REST API:
Authorization: Bearer ezdn_v1_xxxxxxxxxxxxxxxxTransport เป็นแบบ streamable HTTP หาก request ไม่มี key ที่ถูกต้องจะถูกปฏิเสธ
ด้วย 401 และหาก key ของคุณไม่มี scope ที่ tool นั้นต้องการ tool จะตอบกลับด้วย
error 403 ซึ่ง assistant จะแจ้งให้คุณทราบ
สิ่งที่ผู้ช่วยทำได้
Assistant จะค้นพบ tool ที่ใช้งานได้เองโดยอัตโนมัติ ส่วนสิ่งที่ทำได้จริงขึ้นอยู่กับ scope ที่ key ของคุณมี:
| You can ask about | Needs scope |
|---|---|
| Your profile, badges, agencies | read:profile |
| Donations, stats, breakdowns, trends, top donators | read:donations |
| Your plan, limits, sponsorships | read:subscription |
| Your creator stats and member trends | read:creator |
| Donation channel status | read:channels |
| Widget data (goal, leaderboard, last/top donate, timer, status) | read:widgets |
| Controlling the timer (play/pause/reset/adjust) | write:timer |
write:timer เป็น action เดียวที่เปลี่ยนแปลงข้อมูล ส่วนที่เหลือเป็นแบบอ่านอย่าง
เดียว (read-only)
เชื่อมต่อกับ Claude Desktop
เพิ่มโค้ดนี้ลงใน claude_desktop_config.json (Claude Desktop -> Settings ->
Developer -> Edit Config) โดยใช้ mcp-remote เป็นตัวเชื่อมไปยัง HTTP endpoint:
{
"mcpServers": {
"easydonate": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"https://easydonate.app/mcp",
"--header",
"Authorization: Bearer ezdn_v1_xxxxxxxxxxxxxxxx"
]
}
}
}รีสตาร์ท Claude Desktop แล้วคุณจะเห็น server ชื่อ easydonate พร้อม tool ต่าง ๆ
ให้ใช้ในแชท
เชื่อมต่อด้วย MCP Inspector (ทดสอบอย่างรวดเร็ว)
หากต้องการทดลองเรียกใช้ tool แบบอินเทอร์แอกทีฟ:
npx @modelcontextprotocol/inspectorใน Inspector ตั้งค่า Transport เป็น Streamable HTTP, URL เป็น
https://easydonate.app/mcp, เพิ่ม header Authorization: Bearer ezdn_v1_...
จากนั้นกด connect แล้วลองเรียก tool ใดก็ได้
เชื่อมต่อด้วย client กำหนดเอง (JSON-RPC ดิบ)
Endpoint นี้สื่อสารด้วย MCP ผ่าน JSON-RPC ใช้ MCP SDK ตัวไหนก็ได้ หากต้องการ
เช็คแบบง่าย ๆ ด้วยตัวเองให้ลองเรียกดูรายการ tool ด้วย curl:
curl -s https://easydonate.app/mcp \
-H "Authorization: Bearer ezdn_v1_xxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'เรียกใช้ tool ด้วยวิธีเดียวกัน โดยใช้ method: "tools/call":
curl -s https://easydonate.app/mcp \
-H "Authorization: Bearer ezdn_v1_xxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"control_timer","arguments":{"action":"play"}}}'ตัวอย่างพรอมต์
เมื่อเชื่อมต่อแล้ว คุณคุยกับ assistant แบบภาษาธรรมดาได้เลย:
โดเนทและสถิติ
- "How much did I earn from donations this week?"
- "Show my top 10 donators this month."
- "Break down my donations by channel."
- "What are my donation trends over the last 30 days?"
- "Find the donation from
<name>and tell me the amount."
บัญชีและแพลน
- "What's my current plan, and how many donations do I have left this month?"
- "When does my plan renew?"
- "Show my creator stats and how my members are trending."
ควบคุม timer (ต้องมี write:timer)
- "Start my timer."
- "Add 2 minutes to the timer."
- "Pause the timer."
- "Reset the timer."
Assistant จะแปลงคำสั่งเหล่านี้ไปเรียก tool ที่ถูกต้อง เช่น "add 2 minutes" จะ
กลายเป็นการเรียก control_timer ด้วย action: "adjust" และ ms: 120000
ส่วน "stop the timer" จะ map ไปที่ pause
ข้อควรรู้
- MCP server เปิดให้ใช้เฉพาะ tool อ่านข้อมูลสาธารณะ กับการควบคุม timer เท่านั้น ส่วนการจัดการบัญชี (สร้าง key, สร้าง OAuth app) ไม่สามารถทำผ่านช่องทางนี้ได้
- เก็บ API key เป็นความลับ - ใครก็ตามที่มี key นี้จะสามารถใช้สิทธิ์ตาม scope ได้ ทันที หาก key หลุดให้ revoke จากหน้าจัดการทันที
- แนะนำให้สร้าง key ที่มีเฉพาะ scope ที่ต้องใช้จริง ถ้าต้องการแค่ดูสถิติ ให้ไม่ติ๊ก
write:timerไว้ เพื่อไม่ให้ assistant แก้ไขวิดเจ็ตของคุณได้