N大堂CLI
注: 开发人员对使用此工具可能造成的任何损坏不承担任何责任。此软件是为教育目的而开发的,其操作不受保证。
用于访问N Lobby学校门户数据的双模CLI和模型上下文协议(MCP)服务器。从终端以交互方式使用它 nlobby,或将其作为MCP服务器连接到AI助手 nlobby serve.
特性
- 命令行接口命令模式:直接从终端访问N Lobby数据——新闻、日程、课程、个人资料等
- MCP模式:与Claude、Cursor和其他启用MCP的AI助手兼容的完整MCP服务器
- 基于浏览器的身份验证:通过自动Puppeteer浏览器窗口进行交互式登录
- 会话保持:CLI模式将Cookie保存到
~/.nlobby/session用于无缝后续使用 - 学校信息访问:检索公告、时间表和学习资源
- 必修课程管理:访问所需的课程信息和学术数据
- 多种日历类型:支持个人日历和学校日历
- 用户角色支持:学生、家长和教职员工的不同访问级别
安装
选项1:从npm安装(推荐)
npm install -g nlobby-cli选项2:开发安装
- 克隆存储库:
git clone https://github.com/minagishl/nlobby-cli.git
cd nlobby-cli- 安装依赖项:
pnpm install- 构建项目:
pnpm run build配置
创建一个 .env 如果需要覆盖默认值,请使用文件(可选):
NLOBBY_BASE_URL=https://nlobby.nnn.ed.jp
MCP_SERVER_NAME=nlobby-cli
MCP_SERVER_VERSION=1.0.0______________________________________________________________________
命令行用法
认证
# Interactive browser login (recommended)
nlobby login
# Set cookies manually
nlobby cookies set "__Secure-next-auth.session-token=ey...;"
# Check current authentication status
nlobby cookies check新闻
# List latest news (default: 10, newest first)
nlobby news
# Filter and sort
nlobby news --limit 20 --category お知らせ --sort oldest --unread
# Show full article
nlobby news show 980
# Download the first attachment to /tmp
nlobby news download 980 --index 1 --output-dir /tmp
# Mark as read
nlobby news read 980日程表和日历
# Today's schedule
nlobby schedule
# Specific date
nlobby schedule 2026-04-01
# This week's personal calendar
nlobby calendar
# School calendar for a date range
nlobby calendar --type school --from 2026-04-01 --to 2026-04-07课程
# All required courses
nlobby courses
# Filter by grade / semester
nlobby courses --grade 2 --semester 2025个人资料和健康状况
nlobby profile
nlobby healthMCP服务器
# Start MCP server (stdio transport)
nlobby serve
# or
nlobby mcp所有命令支持 --json 输出原始JSON而不是格式化文本。______________________________________________________________________
MCP使用
Setup with Cursor and Other MCP Clients
光标IDE设置

将以下内容添加到光标设置中(~/.cursor/config.json):
{
"mcpServers": {
"nlobby": {
"command": "npx",
"args": ["-y", "nlobby-cli", "serve"],
"env": {
"NLOBBY_BASE_URL": "https://nlobby.nnn.ed.jp"
}
}
}
}Claude桌面设置
添加到您的Claude桌面配置(~/Library/Application Support/Claude/claude_desktop_config.json 在macOS上):
{
"mcpServers": {
"nlobby": {
"command": "npx",
"args": ["-y", "nlobby-cli", "serve"],
"env": {
"NLOBBY_BASE_URL": "https://nlobby.nnn.ed.jp"
}
}
}
}其他MCP客户端
对于任何兼容MCP的客户端,请使用:
- 命令:
nlobby serve(如果全局安装)或node /path/to/dist/index.js serve - 协议标准: stdio
- 环境:配置部分中列出的可选环境变量
MCP资源
| URI | 描述 |
|---|---|
nlobby://news | 学校新闻和通知 |
nlobby://schedule | 每日课程安排和活动 |
nlobby://required-courses | 必修课程和学术信息 |
nlobby://user-profile | 当前用户信息 |
MCP工具
认证
| 工具 | 说明 |
|---|---|
interactive_login | 打开浏览器手动登录(推荐) |
login_help | 个性化登录帮助和故障排除 |
set_cookies | 手动设置身份验证Cookie |
check_cookies | 检查身份验证cookie状态 |
verify_authentication | 验证所有客户端的身份验证状态 |
新闻
| 工具 | 关键参数 | 说明 |
|---|---|---|
get_news | category? limit? sort? | 通过过滤检索学校新闻 |
get_news_detail | newsId markAsRead? | 特定文章的完整细节 |
mark_news_as_read | ids (数组) | 将文章标记为已读 |
get_unread_news_info | 未读计数和重要新闻标志 |
日程表和日历
| 工具 | 关键参数 | 说明 |
|---|---|---|
get_schedule | date? | 日期日程表(YYYY-MM-DD) |
get_calendar_events | calendar_type? from_date? to_date? period? | 日历活动(个人/学校) |
test_calendar_endpoints | from_date? to_date? | 测试两个日历端点 |
get_calendar_filters | 大厅日历筛选器定义 |
课程与考试
| 工具 | 关键参数 | 说明 |
|---|---|---|
get_required_courses | grade? semester? category? | 带有进度跟踪的必修课程 |
check_exam_day | date? | 检查日期是否为考试日 |
finish_exam_day_mode | 结束考试日模式 | |
get_exam_otp | 获取考试一次性密码 |
帐户和导航
| 工具 | 说明 |
|---|---|
get_account_info | 从Next.js页面提取帐户信息 |
get_student_card_screenshot | 拍摄学生证截图 |
update_last_access | 更新上次访问时间戳 |
get_navigation_menus | 主导航菜单列表 |
get_notifications | 通知消息 |
get_user_interests | 用户兴趣标签(带可选图标数据) |
get_interest_weights | 利息权重表定义 |
调试
| 工具 | 关键参数 | 说明 |
|---|---|---|
health_check | 测试N大堂API连接 | |
debug_connection | endpoint? | 详细的连接调试 |
test_page_content | endpoint? length? | 页面内容检索测试 |
test_trpc_endpoint | method params? | 测试特定的tRPC终点 |
______________________________________________________________________
身份验证流程
方法1:交互式浏览器登录(推荐)
CLI:
nlobby loginMCP工具: interactive_login
浏览器窗口会自动打开。完成N Lobby登录,Cookie将被提取并保存。
方法2:手动设置Cookie
- 在您的网络浏览器中登录N Lobby
- 打开DevTools→ 应用/存储→ Cookie
- 将所有Cookie复制为字符串
CLI:
nlobby cookies set "__Secure-next-auth.session-token=ey...;"MCP工具: set_cookies cookies="__Secure-next-auth.session-token=ey...;"
______________________________________________________________________
用户类型
服务器支持基于电子邮件域的三种用户类型:
| 类型 | 电子邮件域 |
|---|---|
| 学生 | @nnn.ed.jp |
| 员工 | @nnn.ac.jp |
| 父母 | 任何其他注册电子邮件 |
______________________________________________________________________
项目结构
src/
├── index.ts # Entry point — CLI vs MCP mode detection
├── config.ts # Configuration management
├── logger.ts # Logging utilities
├── trpc-client.ts # tRPC client for API calls
├── types.ts # TypeScript type definitions
├── api/
│ ├── index.ts # NLobbyApi facade + session persistence
│ ├── context.ts # ApiContext interface
│ ├── shared.ts # Shared utilities (fetchRenderedHtml, …)
│ ├── news.ts # News functions
│ ├── schedule.ts # Schedule / calendar functions
│ ├── courses.ts # Course / exam functions
│ ├── account.ts # Account info / student card functions
│ ├── navigation.ts # Navigation / notification / interest functions
│ └── health.ts # Health check / debug functions
├── auth/
│ ├── browser.ts # Puppeteer browser authentication
│ ├── nextauth.ts # NextAuth.js session handling
│ └── credentials.ts # Credential validation and guidance
├── cli/
│ ├── index.ts # Commander program wiring
│ ├── commands/ # login, news, schedule, courses, profile, health, serve
│ └── formatters/ # Human-readable output formatters
└── mcp/
└── server.ts # MCP server (28 tools, 4 resources)______________________________________________________________________
发展
脚本
pnpm run build # Build (esbuild bundle + tsc type declarations)
pnpm run dev # Watch mode
pnpm run start # Start MCP server
pnpm run lint # Lint
pnpm run format # Format安全说明
- CLI Cookie存储在
~/.nlobby/session(纯文本——相应保护) - MCP模式仅将所有身份验证令牌保存在内存中
- 浏览器自动化仅用于身份验证,不用于数据抓取
- 未记录敏感数据
______________________________________________________________________
许可证
该项目根据MIT许可证获得许可——请参阅 许可证 文件以获取详细信息。
