thieponline-guests-mcp
MCP server để AI agent quản lý khách mời trên thieponline.app — liệt kê, thêm, sửa, xóa khách và xuất CSV. Backend Supabase; server tự refresh access token.
Tool
| Tool | Mô tả |
|---|---|
list_guests(search="") | Liệt kê khách; search lọc theo tên. |
get_guest(guest_id) | Chi tiết 1 khách theo id. |
add_guest(name, invite_message="", salutation="") | Thêm khách; name bắt buộc, slug tự sinh. |
update_guest(guest_id, ...) | Sửa khách; chỉ truyền field muốn đổi. |
delete_guest(guest_id) | Xóa khách (không hoàn tác). |
export_guests_to_csv() | Xuất CSV (STT, Tên khách, Lời nhắn). |
RSVP lưu ở bảng riêng, chỉ khách tự điền qua trang công khai — server này không ghi RSVP.
Cài đặt (MCP client)
Thêm vào cấu hình MCP (mcp.json / claude_desktop_config.json / .kiro/settings/mcp.json):
{
"mcpServers": {
"thieponline-guests": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/ngoctp27/thieponline-app-mcp",
"thieponline-guests-mcp"
],
"env": {
"THIEPONLINE_INVITATION_ID": "<id-thiệp-của-bạn>",
"THIEPONLINE_REFRESH_TOKEN": "<refresh-token-của-bạn>"
}
}
}
}
Cần uv (uvx) cài sẵn. uvx tự tải package + dependency khi chạy.
Lấy 2 giá trị cấu hình
Làm đúng thứ tự để token không chết ngay: nếu token báo hết hạn, hãy đăng xuất (logout) rồi đăng nhập (login) lại thieponline.app để Supabase cấp session hoàn toàn mới, lấy refresh_token, rồi đóng hết tab thieponline.app trước khi dán vào MCP.
Đăng nhập thieponline.app, mở trang /guests, mở DevTools (F12).
THIEPONLINE_INVITATION_ID
DevTools → Application → Local Storage → https://thieponline.app → key lastActiveInvitationId → copy value.
THIEPONLINE_REFRESH_TOKEN
Trong Cookies, ghép 2 cookie sb-dudcjocrigjgnprdkijw-auth-token.0 + .1, bỏ tiền tố base64-, decode base64 ra JSON, lấy field refresh_token:
python3 - <<'PY'
import base64, json
p0 = "base64-...phần .0 (bỏ 'base64-')..."
p1 = "...phần .1..."
raw = p0.replace("base64-", "") + p1
print(json.loads(base64.urlsafe_b64decode(raw + "=" * (-len(raw) % 4)))["refresh_token"])
PY
Cách nhanh — Chrome Console (JS)
Mở thieponline.app/guests (đã đăng nhập) → F12 → tab Console → dán đoạn JS dưới, Enter. Nó in sẵn khối env để copy vào mcp.json:
(() => {
const ref = "dudcjocrigjgnprdkijw";
const base = `sb-${ref}-auth-token`;
const readCookie = n => document.cookie.split("; ").find(c => c.startsWith(n + "="))?.split("=").slice(1).join("=");
const b64urlToJson = s => {
s = s.replace(/^base64-/, "").replace(/-/g, "+").replace(/_/g, "/");
while (s.length % 4) s += "=";
const bin = atob(s);
const bytes = Uint8Array.from(bin, c => c.charCodeAt(0));
return JSON.parse(new TextDecoder("utf-8").decode(bytes));
};
let raw;
const p0 = readCookie(base + ".0");
if (p0) raw = decodeURIComponent(p0) + decodeURIComponent(readCookie(base + ".1") || "");
else { raw = readCookie(base) || localStorage.getItem(base); if (raw) raw = decodeURIComponent(raw); }
if (!raw) { console.error("Khong tim thay session. Da dang nhap chua?"); return; }
const session = b64urlToJson(raw);
const invitation = readCookie("lastActiveInvitationId") || localStorage.getItem("lastActiveInvitationId");
console.log(JSON.stringify({
THIEPONLINE_INVITATION_ID: invitation,
THIEPONLINE_REFRESH_TOKEN: session.refresh_token,
}, null, 2));
})();
Nếu Console chặn dán: gõ allow pasting rồi Enter, dán lại.
Token xoay vòng: Supabase refresh token dùng 1 lần rồi đổi. Đóng hết tab thieponline.app trước khi copy token cho MCP. Server lưu token xoay vòng vào~/.thieponline-guests-mcp/token.jsonnên tự duy trì sau lần seed đầu.
Nếu token đã hết hạn / báo lỗi xác thực: đăng xuất (logout) → đăng nhập (login) lại → lấyrefresh_tokenmới bằng đoạn JS ở trên → đóng hết tab thieponline.app → dán token mới vàomcp.json→ xoá cache cũrm ~/.thieponline-guests-mcp/token.json→ restart MCP client.
Bảo mật
refresh_tokenlà bí mật cá nhân — giữ trongenvcủa MCP client, không commit.- Repo không chứa token của ai. Anon key nhúng sẵn là khóa publishable công khai, không phải secret.
- Token chỉ truy cập dữ liệu của chính tài khoản đăng nhập (RLS).