set_cookies
Set authentication cookies for secure access to N Lobby school portal data, enabling users to view announcements, schedules, and learning resources.
Instructions
Set authentication cookies for N Lobby access
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cookies | Yes | Cookie string from authenticated N Lobby session |
Implementation Reference
- src/server.ts:314-327 (registration)Registration of the 'set_cookies' tool including name, description, and input schema definition.name: "set_cookies", description: "Set authentication cookies for N Lobby access", inputSchema: { type: "object", properties: { cookies: { type: "string", description: "Cookie string from authenticated N Lobby session", }, }, required: ["cookies"], }, },
- src/server.ts:882-893 (handler)MCP server tool handler for 'set_cookies' that extracts the cookies argument and delegates to the API client's setCookies method, returning a success message.case "set_cookies": { const { cookies } = args as { cookies: string }; this.api.setCookies(cookies); return { content: [ { type: "text", text: "Authentication cookies have been set. You can now access real N Lobby data.", }, ], }; }
- src/nextauth.ts:35-42 (handler)Core setCookies implementation in NextAuthHandler that parses incoming cookie string using parseCookies and stores the extracted tokens (sessionToken, csrfToken, callbackUrl).setCookies(cookieString: string): void { this.cookies = this.parseCookies(cookieString); logger.debug("NextAuth cookies parsed:", { hasSessionToken: !!this.cookies.sessionToken, hasCsrfToken: !!this.cookies.csrfToken, hasCallbackUrl: !!this.cookies.callbackUrl, }); }
- src/nextauth.ts:3-7 (schema)TypeScript interface defining the structure of NextAuth cookies parsed and used by the setCookies functionality.export interface NextAuthCookies { sessionToken?: string; csrfToken?: string; callbackUrl?: string; }
- src/nextauth.ts:14-33 (helper)Helper method that parses raw semicolon-separated cookie string into structured NextAuthCookies object, extracting specific NextAuth.js cookie values.parseCookies(cookieString: string): NextAuthCookies { const cookies: NextAuthCookies = {}; const cookiePairs = cookieString.split(";"); for (const pair of cookiePairs) { const [name, value] = pair.trim().split("="); if (name && value) { // Handle NextAuth.js cookie names if (name === "__Secure-next-auth.session-token") { cookies.sessionToken = decodeURIComponent(value); } else if (name === "__Host-next-auth.csrf-token") { cookies.csrfToken = decodeURIComponent(value); } else if (name === "__Secure-next-auth.callback-url") { cookies.callbackUrl = decodeURIComponent(value); } } } return cookies; }