From 5b19648a62a3cf1348a5dd92d95464e9a2faefd5 Mon Sep 17 00:00:00 2001 From: Aikhan Jumashukurov <117706338+aikhanj@users.noreply.github.com> Date: Thu, 26 Nov 2026 01:02:47 -0500 Subject: [PATCH 1/3] Add current course coverage, official CS schedules, and public Prince search --- app/COURSE_CONNECTOR.md | 44 ++++++++++++- app/scripts/smoke-current-course-data.ts | 24 +++++++ app/src/server/course-consent.ts | 2 +- app/src/server/course-mcp.ts | 43 ++++++++++--- app/src/server/course-public-data.ts | 81 ++++++++++++++++++++++++ app/src/server/pi.ts | 1 + app/tests/course-mcp.test.ts | 35 +++++++++- app/tests/course-public-data.test.ts | 50 +++++++++++++++ 8 files changed, 267 insertions(+), 13 deletions(-) create mode 100644 app/scripts/smoke-current-course-data.ts create mode 100644 app/src/server/course-public-data.ts create mode 100644 app/tests/course-public-data.test.ts diff --git a/app/COURSE_CONNECTOR.md b/app/COURSE_CONNECTOR.md index 0f8eeaf..b1b63be 100644 --- a/app/COURSE_CONNECTOR.md +++ b/app/COURSE_CONNECTOR.md @@ -43,7 +43,9 @@ Overlapping upstream tool catalogs cannot change a tool's designated source. | PrincetonCourses | Course evaluations, review summaries, instructor information | None | | TigerPath | Degree requirement trees, aggregate planning statistics, own four-year plan | Add or remove a course in a semester | -There are 24 allowlisted read tools and 5 optional write tools. Whole-schedule +The baseline engine provides 24 allowlisted read tools and 5 optional write tools. +With the published-data engine extension and three local public/coverage tools, +the connector offers up to 30 read tools. Whole-schedule deletion, seat alerts, TigerHub registration, Canvas, calendar access, and PI workspaces are excluded. A saved plan is not a transcript or actual enrollment. @@ -122,3 +124,43 @@ require the assistant to report that gap instead of substituting an older term. Production CAS-to-Claude authorization, real personal-plan ownership enforcement, and saved-plan changes still require an authorized staging check. No production deployment or real plan mutation is part of these local checks. + +## Published data and coverage + +The connector now includes three local read tools independently of engine catalog +availability. `get_course_data_status(term)` checks the imported catalog, the live +published-term source and the CS department fallback. It does not read a student's +plans. `get_cs_course_schedule(term)` reads the official department page for that +exact semester, and rejects a page that silently selects a different term. +`search_prince_articles(query, page)` searches the Daily Princetonian public site, +returning bounded excerpts with source identity, article dates and canonical URLs. +This is not Clio and does not access its database, newsletters, retrieval service, +credentials or chats. Publication date, fetch time and unknown ingestion history +are separate fields. Public fetches send neither NetID nor session credentials. + +A companion engine change exposes `list_published_terms`, +`search_published_courses` and `get_published_course` on the junction MCP scope. +These read Princeton's authenticated OIT course API directly and do not require a +completed database import. Deploy that change and configure the engine's existing +`CONSUMER_KEY`/`CONSUMER_SECRET` (preferred) or `API_ACCESS_TOKEN`. PI does not receive +those credentials. Without that deployment/configuration, only the CS fallback +and public Prince search are independently available. Imported search results and +saved-plan validation may still be stale. Do not claim the database was refreshed. + +Successful public reads are cached for at most five minutes per process/isolate, +with fetch timestamps and bounded cache sizes. Errors are not empty catalogs. +A working source is not proof it covers every department or the requested term. +The CS page provides course-level meetings, not every precept or lab; missing or +ambiguous times stay unknown. Prince reporting cannot establish degree policy or +current section availability. Ratings remain historical and a saved plan is not +a transcript. No automatic import, production mutation or registration is added. + +Local live checks on November 26, 2026 retrieved Spring 2027 COS 217 with +`MW 10:40 - 11:30` and dated Prince search results. The existing production engine +still returned only seven terms through Fall 2026 and no Spring 2027 COS results. +The authenticated engine reads have fixture tests, but require a deployed smoke +check with valid OIT credentials before university-wide coverage can be claimed. + +Reproduce the read-only live public-source check from `app` with +`npx tsx scripts/smoke-current-course-data.ts 1274`. It uses the real MCP transport +with a local test identity, without production sessions or saved-plan writes. diff --git a/app/scripts/smoke-current-course-data.ts b/app/scripts/smoke-current-course-data.ts new file mode 100644 index 0000000..4d33736 --- /dev/null +++ b/app/scripts/smoke-current-course-data.ts @@ -0,0 +1,24 @@ +/** Read-only live source check through the actual connector MCP transport. + * Run from app: npx tsx scripts/smoke-current-course-data.ts 1274 + * Does not use production identities, credentials, plans or the production MCP. + */ +import assert from "node:assert/strict"; +import { Client, StreamableHTTPClientTransport } from "@modelcontextprotocol/client"; +import { COURSE_READ, handleCourseMcp } from "../src/server/course-mcp.ts"; +const term = Number(process.argv[2]); +assert.ok(Number.isInteger(term) && term >= 1000 && term <= 1999 && [2, 4].includes(term % 10), "Pass an explicit Fall/Spring term, e.g. 1274"); +const client = new Client({ name: "pi-live-public-smoke", version: "1" }); +const upstream = { list: async () => [], call: async () => { throw new Error("No engine in this public-source smoke test"); } }; +try { + await client.connect(new StreamableHTTPClientTransport(new URL("https://local.test/mcp"), { + fetch: (url, init) => handleCourseMcp(new Request(url, init), { netid: "teststudent", scope: [COURSE_READ] }, upstream), + })); + for (const [name, args] of [["get_cs_course_schedule", { term }], ["search_prince_articles", { query: "course offerings" }]] as const) { + const result = await client.callTool({ name, arguments: args }); + assert.notEqual(result.isError, true, JSON.stringify(result)); + const text = result.content?.find(c => c.type === "text"); + assert.ok(text?.type === "text"); + const data = JSON.parse(text.text); + console.log(JSON.stringify({ tool: name, status: "PASS", source: data.source, sourceUrl: data.sourceUrl, fetchedAt: data.fetchedAt, coverage: data.coverage, resultCount: data.courses?.length ?? data.articles?.length, sample: data.courses?.find((c: any) => c.code === "COS217") ?? data.articles?.[0] })); + } +} finally { await client.close(); } diff --git a/app/src/server/course-consent.ts b/app/src/server/course-consent.ts index f39157a..6fdb5e7 100644 --- a/app/src/server/course-consent.ts +++ b/app/src/server/course-consent.ts @@ -29,7 +29,7 @@ export function consentPage(details: ConsentDescription, handle: string, netid: ${details.clientDomain ? `Client domain verified as ${escapeHtml(details.clientDomain)}.` : "The application name is supplied by the client. Check the destination before connecting."}${details.redirectIsLoopback ? " This destination is a local app. Another local process could be listening there." : ""}