get_news
Retrieve school news and announcements from the N Lobby portal with options to filter by category, sort results, and limit items.
Instructions
Retrieve school news
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | No | Filter by category (optional) | |
| limit | No | Maximum number of news items to retrieve (optional, default: 10) | |
| sort | No | Sort order: 'newest' (default), 'oldest', 'title-asc', 'title-desc' |
Implementation Reference
- src/server.ts:458-524 (handler)Executes the get_news tool: fetches news via api.getNews(), filters by category if provided, sorts by specified order (default newest), limits results, returns JSON stringified list or error message with auth instructions.case "get_news": try { const { category, limit = 10, sort = "newest", } = args as { category?: string; limit?: number; sort?: "newest" | "oldest" | "title-asc" | "title-desc"; }; const news = await this.api.getNews(); let filteredNews = category ? news.filter((n) => n.category === category) : news; // Sort the news switch (sort) { case "oldest": filteredNews.sort( (a, b) => new Date(a.publishedAt || 0).getTime() - new Date(b.publishedAt || 0).getTime(), ); break; case "title-asc": filteredNews.sort((a, b) => (a.title || "").localeCompare(b.title || ""), ); break; case "title-desc": filteredNews.sort((a, b) => (b.title || "").localeCompare(a.title || ""), ); break; case "newest": default: filteredNews.sort( (a, b) => new Date(b.publishedAt || 0).getTime() - new Date(a.publishedAt || 0).getTime(), ); break; } if (limit > 0) { filteredNews = filteredNews.slice(0, limit); } return { content: [ { type: "text", text: JSON.stringify(filteredNews, 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:160-181 (schema)Input schema defining parameters for get_news tool: optional category filter, limit (default 10), sort order enum.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"], }, }, },
- src/server.ts:157-182 (registration)Tool registration entry in ListTools response, including name, description, and input schema for get_news.{ 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"], }, }, }, },