ntnu-api
MCP server exposing NTNU course data (search, schedules, grades, semesters) as tools for LLM agents.
README
ntnu-api
TypeScript client for NTNU course data. Wraps the three public, no-auth data sources for course information at the Norwegian University of Science and Technology behind one typed interface. Fetch-based with zero runtime dependencies — works in Node ≥ 20, Cloudflare Workers, browsers, and any other fetch-capable runtime.
| Namespace | Data | Backing source |
|---|---|---|
client.courses |
catalog search, per-course schedules & weekly timetables | ntnu.no course-page JSON (Liferay) |
client.grades |
grade distributions per course/year/semester | HK-dir DBH statistics API |
client.semesters |
term ids (26h/26v), teaching weeks, exam periods |
NTNU's TP timetable system |
See docs/api-research.md for the full survey of NTNU data sources (including the dead and auth-gated ones) and the exact upstream request shapes.
Usage
npm install ntnu-api
import { NTNUClient } from "ntnu-api";
const client = new NTNUClient();
// Server-side course search (one 500-course page)
const page = await client.courses.search(2026, "objektorientert");
for (const hit of page.courses.slice(0, 3)) {
console.log(hit.courseCode, hit.courseName);
}
// Full catalog iteration (dedups the upstream's duplicate entries)
for await (const resultPage of client.courses.searchAll(2026)) {
// ...
}
// Dated teaching activities and the summarized weekly grid
const activities = await client.courses.schedules("TDT4100", 2026);
const grid = await client.courses.timetable("TDT4100", 2026);
// Grade distribution (accepts bare or DBH-versioned codes)
for (const row of await client.grades.distribution("TDT4100", { years: [2023] })) {
console.log(row.year, row.semesterName, row.grade, row.total);
}
// Terms as known by NTNU's timetable system
const current = await client.semesters.current();
All errors derive from NTNUAPIError (with NotFoundError,
RateLimitError, APITimeoutError, ... subclasses). Transient failures
(429, 502–504, connection errors) are retried with exponential backoff,
honoring Retry-After. Upstream payloads are parsed into plain typed
objects; helpers like bestName() (trilingual name fallback) and
weekNumbers() (ISO-week range expansion) are exported alongside them.
A word of caution: the ntnu.no endpoints are NTNU's own internal AJAX surface, not a documented API — treat results accordingly and be polite (the client ships a descriptive User-Agent by default).
MCP server
The ntnu-mcp sibling repo hosts a
remote MCP server built on this package (Cloudflare Worker), exposing the
client as eight LLM-shaped tools — connect Claude or ChatGPT to
https://ntnu-mcp.martinsundal.no/mcp. Upstream fixes and new data sources
land here; the MCP repo only shapes typed data for LLMs.
Stack
- TypeScript (strict), ESM-only, zero runtime dependencies
- vitest — tests over captured live fixtures
- Biome — linting + formatting
- mise — pins Node and exposes task shortcuts
- Dev Container — reproducible environment
Development
mise install # pinned Node
npm install
| Task | Command |
|---|---|
mise run test |
vitest run |
mise run lint |
biome check . |
mise run fmt |
biome check --write . |
mise run typecheck |
tsc --noEmit |
mise run build |
tsc -p tsconfig.build.json → dist/ |
mise run check |
lint + typecheck + test |
The default test run is fully mocked (injected fetch) against real
captured payloads in tests/fixtures/. To also verify against the live
endpoints (drift check):
NTNU_API_LIVE=1 npm test
Releases are tag-driven: npm version <patch|minor|major> && git push --follow-tags. The release workflow then
verifies the tag, runs the full check suite, publishes to npm (trusted
publishing with provenance — no token secrets), and creates the GitHub
Release with generated notes. The prepare script builds dist/, so
github:MartinSA04/ntnu-api installs also work between releases.
History
This library began as an async Python client (httpx + pydantic, with a CLI
and a stdio MCP server); it was ported 1:1 to TypeScript so one codebase
serves Node, Workers, and browsers, per
docs/ts-migration-spec.md. The final Python
state is preserved at the
python-final
tag.
Roadmap
- [x] MCP server exposing the client as tools → ntnu-mcp
- [ ] Expose the remaining catalog search facets (campus, level, faculty/institute)
- [ ] Course detail scraping (description, credits, prerequisites — HTML-only upstream)
- [ ] TP
emner.phpsemester catalog (English names, campus ids — see docs/api-research.md) - [ ] TP iCal export as a secondary timetable source once semesters publish
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。