get_calendar_events
Retrieve calendar events from the N Lobby MCP Server, filtering by calendar type, date range, or predefined period. Supports personal and school calendars with flexible query options.
Instructions
Get calendar events with advanced options
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| calendar_type | No | Type of calendar to retrieve (personal or school) | personal |
| from_date | No | Start date in YYYY-MM-DD format (optional). If only from_date is provided, it will be treated as a single day. | |
| period | No | Predefined period (optional, overrides from/to dates). Use "today" for single day queries. | |
| to_date | No | End date in YYYY-MM-DD format (optional). Must be at least 1 day after from_date when both are provided. |
Implementation Reference
- src/server.ts:736-803 (handler)Handler function for the 'get_calendar_events' tool. Parses input parameters, determines calendar type and date range, calls the API to fetch schedule events, and returns formatted JSON response with error handling.case "get_calendar_events": try { const { calendar_type, from_date, to_date, period } = args as { calendar_type?: string; from_date?: string; to_date?: string; period?: string; }; // Determine calendar type const calendarType = calendar_type === "school" ? CalendarType.SCHOOL : CalendarType.PERSONAL; // Determine date range let dateRange; if (period) { switch (period) { case "today": { const today = new Date(); dateRange = this.api.createSingleDayRange(today); break; } case "week": dateRange = this.api.createWeekDateRange(); break; case "month": dateRange = this.api.createMonthDateRange(); break; default: throw new Error(`Invalid period: ${period}`); } } else if (from_date && to_date) { dateRange = this.api.createDateRange(from_date, to_date); } else if (from_date) { // Single day range dateRange = this.api.createSingleDayRange(from_date); } // If no date parameters, use default (current week) const schedule = await this.api.getSchedule( calendarType, dateRange, ); return { content: [ { type: "text", text: `[DATE] Calendar Events (${calendar_type || "personal"})${ dateRange ? ` from ${dateRange.from.toDateString()} to ${dateRange.to.toDateString()}` : " (current week)" }\n\n${JSON.stringify(schedule, null, 2)}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error: ${error instanceof Error ? error.message : "Unknown error"}\n\nTo authenticate:\n1. Login to N Lobby in your browser\n2. Open Developer Tools (F12)\n3. Go to Application/Storage tab\n4. Copy cookies and use the set_cookies tool\n5. Use health_check to verify connection`, }, ], }; }
- src/server.ts:261-292 (schema)Input schema and tool metadata (name, description) for the 'get_calendar_events' tool, defining parameters like calendar_type, from_date, to_date, and period.{ name: "get_calendar_events", description: "Get calendar events with advanced options", inputSchema: { type: "object", properties: { calendar_type: { type: "string", enum: ["personal", "school"], description: "Type of calendar to retrieve (personal or school)", default: "personal", }, from_date: { type: "string", description: "Start date in YYYY-MM-DD format (optional). If only from_date is provided, it will be treated as a single day.", }, to_date: { type: "string", description: "End date in YYYY-MM-DD format (optional). Must be at least 1 day after from_date when both are provided.", }, period: { type: "string", enum: ["today", "week", "month"], description: 'Predefined period (optional, overrides from/to dates). Use "today" for single day queries.', }, }, }, },
- src/types.ts:100-103 (schema)Type definition for CalendarType enum used in the get_calendar_events handler to distinguish between personal and school calendars.export enum CalendarType { PERSONAL = "personal", SCHOOL = "school", }
- src/server.ts:154-451 (registration)Registration of all tools including get_calendar_events in the MCP server's ListToolsRequestSchema handler.this.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ { name: "get_news", description: "Retrieve school news", inputSchema: { type: "object", properties: { category: { type: "string", description: "Filter by category (optional)", }, limit: { type: "number", description: "Maximum number of news items to retrieve (optional, default: 10)", minimum: 1, default: 10, }, sort: { type: "string", description: "Sort order: 'newest' (default), 'oldest', 'title-asc', 'title-desc'", enum: ["newest", "oldest", "title-asc", "title-desc"], }, }, }, }, { name: "get_news_detail", description: "Retrieve detailed information for a specific news article", inputSchema: { type: "object", properties: { newsId: { type: "string", description: "The ID of the news article to retrieve", }, markAsRead: { type: "boolean", description: "Mark the news article as read (optional, default: false)", default: false, }, }, required: ["newsId"], }, }, { name: "get_account_info", description: "Extract account information by parsing Next.js flight data from a rendered page", inputSchema: { type: "object", properties: {}, }, }, { name: "get_student_card_screenshot", description: "Capture a screenshot of the student ID card by following the secure portal redirect flow", inputSchema: { type: "object", properties: {}, }, }, { name: "get_required_courses", description: "Retrieve required courses information with detailed progress tracking", inputSchema: { type: "object", properties: { grade: { type: "number", description: "Filter by grade level (1, 2, or 3) (optional)", }, semester: { type: "string", description: 'Filter by term year (e.g., "2024", "2025") (optional)', }, category: { type: "string", description: 'Filter by curriculum category (e.g., "国語", "数学", "英語") (optional)', }, }, }, }, { name: "get_schedule", description: "Get school schedule for a specific date (backward compatibility)", inputSchema: { type: "object", properties: { date: { type: "string", description: "Date in YYYY-MM-DD format (optional, defaults to today)", }, }, }, }, { name: "get_calendar_events", description: "Get calendar events with advanced options", inputSchema: { type: "object", properties: { calendar_type: { type: "string", enum: ["personal", "school"], description: "Type of calendar to retrieve (personal or school)", default: "personal", }, from_date: { type: "string", description: "Start date in YYYY-MM-DD format (optional). If only from_date is provided, it will be treated as a single day.", }, to_date: { type: "string", description: "End date in YYYY-MM-DD format (optional). Must be at least 1 day after from_date when both are provided.", }, period: { type: "string", enum: ["today", "week", "month"], description: 'Predefined period (optional, overrides from/to dates). Use "today" for single day queries.', }, }, }, }, { name: "test_calendar_endpoints", description: "Test both personal and school calendar endpoints", inputSchema: { type: "object", properties: { from_date: { type: "string", description: "Start date in YYYY-MM-DD format (optional). If only from_date is provided, it will be treated as a single day.", }, to_date: { type: "string", description: "End date in YYYY-MM-DD format (optional). Must be at least 1 day after from_date when both are provided.", }, }, }, }, { 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"], }, }, { name: "check_cookies", description: "Check if authentication cookies are set", inputSchema: { type: "object", properties: {}, }, }, { name: "health_check", description: "Check if N Lobby API connection is working", inputSchema: { type: "object", properties: {}, }, }, { name: "debug_connection", description: "Debug N Lobby connection with detailed information", inputSchema: { type: "object", properties: { endpoint: { type: "string", description: "Endpoint to test (default: /news)", default: "/news", }, }, }, }, { name: "test_page_content", description: "Test page content retrieval and show sample content", inputSchema: { type: "object", properties: { endpoint: { type: "string", description: "Endpoint to test (default: /news)", default: "/news", }, length: { type: "number", description: "Number of characters to show (default: 1000)", default: 1000, }, }, }, }, { name: "test_trpc_endpoint", description: "Test specific tRPC endpoint with detailed response", inputSchema: { type: "object", properties: { method: { type: "string", description: "tRPC method to test (e.g., news.getUnreadNewsCount, user.updateLastAccess)", default: "user.updateLastAccess", }, params: { type: "string", description: "JSON string of parameters (optional)", }, }, }, }, { name: "verify_authentication", description: "Verify authentication status and cookie synchronization across all clients", inputSchema: { type: "object", properties: {}, }, }, { name: "interactive_login", description: "Open browser for manual login to N Lobby (no credentials required)", inputSchema: { type: "object", properties: {}, }, }, { name: "login_help", description: "Get help and troubleshooting tips for N Lobby login", inputSchema: { type: "object", properties: { email: { type: "string", description: "Your email address (optional, for personalized help)", }, }, }, }, { name: "mark_news_as_read", description: "Mark news articles as read", inputSchema: { type: "object", properties: { ids: { type: "array", items: { type: "string", }, description: "Array of news article IDs to mark as read", }, }, required: ["ids"], }, }, ], }; });