MCP — giao diện lập trình

Ngoài REST, GetMyBot còn có giao diện MCP (Model Context Protocol) — được thiết kế cho AI agent và trợ lý, vốn gọi công cụ thay vì tự gọi endpoint thủ công. REST vẫn là giao diện chính; MCP là lựa chọn tiện lợi cho các kịch bản agentic. Tên công cụ, tài nguyên và prompt dưới đây khớp với những gì server công bố.

Địa chỉ và xác thực

MCP khả dụng tại endpoint /mcp (transport Streamable HTTP, phương thức POST). Xác thực — cùng token cá nhân như với REST: header Authorization: Bearer mbp_…. Không cần tạo token riêng — một PAT hoạt động được cho cả REST lẫn MCP. Mỗi công cụ yêu cầu cùng scope với REST endpoint tương ứng; token có scope * có toàn quyền truy cập. Nếu scope không đủ — lệnh gọi bị từ chối (fail-closed), giống như trong REST.

Kết nối với Claude Code / Cursor

Thêm GetMyBot làm remote MCP server. Ví dụ cấu hình (mcpServers) — thay tên miền và token của bạn:

{
  "mcpServers": {
    "mybot": {
      "url": "https://your-domain/mcp",
      "headers": {
        "Authorization": "Bearer mbp_YOUR_TOKEN"
      }
    }
  }
}

Claude Code: đặt khối này vào .mcp.json của dự án hoặc thêm server bằng lệnh claude mcp add. Cursor: thêm cùng khối vào cài đặt MCP (Settings → MCP → Add server). Sau khi kết nối, client sẽ tự động nhận danh sách công cụ, tài nguyên và prompt.

Công cụ theo lĩnh vực

Server công bố 100 công cụ — bao phủ toàn bộ REST khả dụng với PAT. Dưới đây là công cụ và scope yêu cầu. Tên theo định dạng động từ_danh từ (snake_case).

Bot (bots)

  • list_botsbots:read
  • get_botbots:read
  • validate_bot_tokenbots:write
  • connect_botbots:write
  • update_botbots:write
  • delete_botbots:write
  • sync_botbots:write
  • change_bot_tokenbots:write
  • transfer_botbots:write
  • get_bot_settingssettings:read
  • update_bot_settingssettings:write

Kênh và template WhatsApp (bots)

Hỗ trợ đa kênh (Telegram + WhatsApp + VK) cũng khả dụng qua MCP. Kênh và template được kiểm soát bởi scope dùng chung bots:read / bots:write — không có scope kênh riêng.

  • list_channelsbots:read — liệt kê các kênh của một bot (nền tảng tg/wa/vk, external_id, tên, enabled, callback_url).
  • connect_channelbots:write — kết nối một kênh WhatsApp hoặc VK (platform + thông tin xác thực).
  • delete_channelbots:write — ngắt kết nối một kênh.
  • list_wa_templatesbots:read — danh mục template WhatsApp của kênh (tên, ngôn ngữ, trạng thái, danh mục, body).
  • sync_wa_templatesbots:write — đồng bộ lại danh mục template với Meta.
  • create_wa_templatebots:write — tạo một template WhatsApp và gửi tới Meta để kiểm duyệt.
  • update_wa_templatebots:write — chỉnh sửa một template (ở trạng thái APPROVED/REJECTED/PAUSED).
  • delete_wa_templatebots:write — xóa một template.

Kênh Telegram được kết nối qua connect_bot, không phải connect_channel — cái sau chỉ xử lý wavk. Danh mục template: MARKETING / UTILITY / AUTHENTICATION. create_wa_template gửi ngay bản nháp tới Meta để kiểm duyệt; trạng thái thay đổi một cách bất đồng bộ — đọc lại qua list_wa_templates (làm mới danh mục bằng sync_wa_templates nếu cần).

Việc tải lên media header của template (hình ảnh/video/tài liệu) qua MCP hiện chưa được hỗ trợ — hãy dùng giao diện web hoặc REST POST /api/bots/{botID}/channels/{channelID}/templates/media.

Phản ứng (reactions)

  • list_reactionsreactions:read
  • get_reactionreactions:read
  • create_reactionreactions:write
  • update_reactionreactions:write
  • delete_reactionreactions:write
  • import_reactionsreactions:write
  • test_formulareactions:write
  • reorder_reactionreactions:write
  • get_reaction_linksreactions:read
  • list_reaction_foldersreactions:read
  • create_reaction_folderreactions:write
  • update_reaction_folderreactions:write
  • delete_reaction_folderreactions:write
  • add_reaction_to_folderreactions:write
  • remove_reaction_from_folderreactions:write
  • add_reactions_to_folderreactions:write

Import qua import_reactions tạo phản ứng nhưng bỏ qua media: trong ngữ cảnh MCP không có kiểm tra premium và không có Telegram receiver cho file. Nếu bundle SamBot có ảnh/video/tài liệu — hãy dùng REST import đầy đủ (POST /api/bots/{botID}/reactions/import), công cụ này chuyển cả media.

Phát đi (broadcasts)

  • start_broadcastbroadcasts:write (tùy chọn paid, tùy chọn phân đoạn theo nhãn)
  • get_broadcastbroadcasts:write
  • pause_broadcastbroadcasts:write
  • resume_broadcastbroadcasts:write
  • cancel_broadcastbroadcasts:write

Nhãn (labels)

  • list_labelslabels:read
  • create_labellabels:write
  • delete_labellabels:write
  • set_label_favoritelabels:write

Bộ sưu tập và bản ghi (collections)

  • list_collectionscollections:read
  • create_collectioncollections:write
  • update_collectioncollections:write
  • delete_collectioncollections:write
  • list_recordscollections:read
  • create_recordcollections:write
  • update_recordcollections:write
  • delete_recordcollections:write

Kịch bản (flows)

  • list_flowsflows:read
  • get_flowflows:read
  • create_flowflows:write
  • update_flowflows:write
  • delete_flowflows:write

Tích hợp, kết nối, thông tin xác thực (integrations)

  • list_integrationsintegrations:read
  • get_integration_sheetsintegrations:read
  • get_integration_statusintegrations:read
  • create_integrationintegrations:write
  • update_integrationintegrations:write
  • delete_integrationintegrations:write
  • rotate_integration_tokenintegrations:write
  • list_connectionsintegrations:read
  • create_connectionintegrations:write
  • test_connectionintegrations:write
  • update_connectionintegrations:write
  • delete_connectionintegrations:write
  • list_credentialsintegrations:read
  • create_credentialintegrations:write
  • update_credentialintegrations:write
  • delete_credentialintegrations:write

Media (media)

  • upload_mediamedia:write
  • get_mediamedia:write

Template (templates)

  • list_templatestemplates:read
  • delete_templatetemplates:write
  • create_template_from_bottemplates:write
  • apply_templatetemplates:write

Người đăng ký, cuộc trò chuyện, hội thoại — đọc (subscribers)

  • list_subscriberssubscribers:read (phân trang offset/limit, lọc theo nhãn)
  • list_chatssubscribers:read
  • list_dialogssubscribers:read
  • read_dialogsubscribers:read
  • send_dialog_messagesubscribers:write
  • send_dialog_reactionsubscribers:write
  • transcribe_dialog_messagesubscribers:write

Thống kê và phân tích (stats)

  • get_statsstats:read
  • get_stats_summarystats:read
  • get_stats_recentstats:read
  • get_stats_logstats:read
  • get_reaction_healthstats:read
  • get_analyticsstats:read
  • get_analytics_chatsstats:read
  • get_funnelstats:read

Thanh toán — đọc (billing)

  • get_balancebilling:read
  • list_tariffsbilling:read
  • get_transactionsbilling:read

Gửi tin nhắn

  • send_messagebroadcasts:write — gửi tin nhắn nhân danh bot; số dư được tính tự động theo chủ sở hữu token.

Tài nguyên

Ngoài công cụ, server còn cung cấp tài nguyên — bạn có thể đọc chúng để không cần đoán cấu trúc:

  • mybot://openapi.yaml — OpenAPI spec đầy đủ (giống với những gì trả về tại /openapi.yaml).
  • mybot://reference — tài liệu tham khảo gọn: danh sách công cụ với scope và quy ước (địa chỉ gốc, phân trang, định dạng lỗi, giới hạn).
  • mybot://schemas/reaction, mybot://schemas/trigger, mybot://schemas/action, mybot://schemas/flow, mybot://schemas/collection — JSON schema của các cấu hình. Hữu ích nhất để tạo phản ứng (trình kích hoạt, điều kiện, cuộc trò chuyện, hành động), kịch bản và bộ sưu tập chính xác.
  • mybot://bots — danh sách bot động của bạn (ngữ cảnh nhanh mà không cần gọi công cụ).

Prompt

Các kịch bản sẵn có (slash-command trong MCP client):

  • setup_autoresponder — tạo bot tự trả lời (tham số: bot, chủ đề/bộ câu hỏi).
  • segment_broadcast — phát đi theo phân đoạn nhãn (tham số: bot, nhãn, phản ứng/văn bản).
  • diagnose_reaction — tìm hiểu tại sao phản ứng không kích hoạt (đọc phản ứng, reaction-health và thứ tự).
  • import_from_sambot — thực hiện import bundle SamBot và kiểm tra kết quả.
  • weekly_report — tổng hợp thống kê/phân tích bot theo kỳ.

Khi nào chọn MCP, khi nào chọn REST

  • Bạn viết tích hợp, đồng bộ, script hoặc bảng điều khiển riêng — dùng REST.
  • Bạn kết nối GetMyBot với AI assistant hoặc agent hỗ trợ MCP — dùng /mcp.

Cả hai giao diện đều hoạt động với cùng một token và tuân theo cùng quyền hạn của chủ sở hữu. Nếu không tìm thấy công cụ phù hợp với tác vụ — REST endpoint tương ứng luôn có trong tài liệu tham khảo tương tác.

Bước tiếp theo