Skip to main content
Glama

AFFiNE MCP Server

by DAWNCR0W
auth.ts1.2 kB
import { fetch } from "undici"; function extractCookiePairs(setCookies: string[]): string { const pairs: string[] = []; for (const sc of setCookies) { const first = sc.split(";")[0]; if (first) pairs.push(first.trim()); } return pairs.join("; "); } export async function loginWithPassword(baseUrl: string, email: string, password: string): Promise<{ cookieHeader: string }> { const url = `${baseUrl.replace(/\/$/, "")}/api/auth/sign-in`; const res = await fetch(url, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ email, password }) }); if (!res.ok) { const text = await res.text().catch(() => ""); throw new Error(`Sign-in failed: ${res.status} ${text}`); } const anyHeaders = res.headers as any; let setCookies: string[] = []; if (typeof anyHeaders.getSetCookie === "function") { setCookies = anyHeaders.getSetCookie(); } else { const sc = res.headers.get("set-cookie"); if (sc) setCookies = [sc]; } if (!setCookies.length) { throw new Error("Sign-in succeeded but no Set-Cookie received"); } const cookieHeader = extractCookiePairs(setCookies); return { cookieHeader }; }

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/DAWNCR0W/affine-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server