Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 55 additions & 1 deletion app/COURSE_CONNECTOR.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ 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 three local public/coverage tools, the connector offers up to 27 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.

Expand Down Expand Up @@ -122,3 +123,56 @@ 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 maintained catalog term
list, probes that exact term with `search_courses`, and checks 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.

The existing TigerJunction importer owns catalog ingestion and freshness. PI uses
its existing `list_terms`, `search_courses`, `get_course_details` and
`get_course_sections` tools. There is no second OIT tool family or dependency on a
separate engine PR. The CS fallback and public Prince search remain independently
available during an engine outage. Imported results and saved-plan validation
may still be stale until the importer is repaired and backfilled. A successful
one-course probe establishes only that some data exists for the requested term,
not that every department or section is complete. Do not claim a database refresh
or a full-catalog verification based on that probe.

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.
That is a historical observation, not proof of the current production state.
University-wide coverage requires verification of the importer backfill through
the existing engine tools; PI does not acquire or configure OIT credentials.

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.

### PI-only requests

The MCP instructions tell the host assistant to honor a student's PI-only request,
use the connector's own source tools and report gaps instead of silently switching
to web search or browser control. Official pages fetched server-side by PI remain
PI tool calls. An absent saved plan is not an empty transcript. These are assistant
instructions, not an access-control mechanism for the host's other tools. PI
cannot disable a separately enabled Chrome connector or verify that the host
complied. Strict tool isolation must be enforced in the host client.
24 changes: 24 additions & 0 deletions app/scripts/smoke-current-course-data.ts
Original file line number Diff line number Diff line change
@@ -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(); }
2 changes: 1 addition & 1 deletion app/src/server/course-consent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function consentPage(details: ConsentDescription, handle: string, netid:
<small>${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." : ""}</small>
<form method="post" action="/connect/authorize">
<input type="hidden" name="handle" value="${escapeHtml(handle)}"><input type="hidden" name="subject" value="${escapeHtml(subjectProof)}">
<label><input type="checkbox" checked disabled>Read course information and my saved plans<input type="hidden" name="scope" value="${COURSE_READ}"><small>Courses, sections, reviews, degree requirements, and your TigerJunction and TigerPath plans. Data requested by the assistant is sent to ${name}.</small></label>
<label><input type="checkbox" checked disabled>Read course information and my saved plans<input type="hidden" name="scope" value="${COURSE_READ}"><small>Courses, sections, reviews, degree requirements, public campus reporting, and your TigerJunction and TigerPath plans. Public search queries are sent to the selected source. Data requested by the assistant is sent to ${name}.</small></label>
<label><input type="checkbox" name="scope" value="${PLAN_WRITE}">Allow changes to my saved plans<small>Optional. Create, rename, add, or remove courses in TigerJunction and TigerPath when you ask. This does not register you for courses.</small></label>
<p>Your conversation stays in your assistant. This connection does not import memories, PI chats, Canvas, or calendars.</p>
<small>Access can renew for up to 30 days. Disconnect any time at PI / My apps / Course connector.</small>
Expand Down
43 changes: 34 additions & 9 deletions app/src/server/course-mcp.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { PUBLIC_COURSE_TOOLS, publicCourseData } from "./course-public-data";
import { Client, StreamableHTTPClientTransport } from "@modelcontextprotocol/client";
import { Server, WebStandardStreamableHTTPServerTransport } from "@modelcontextprotocol/server";

Expand Down Expand Up @@ -34,7 +35,9 @@ const policy = new Map<string, { source: Source; write: boolean }>(sources.flatM
]));

export const COURSE_INSTRUCTIONS = `Help Princeton students select courses using current TigerApps data.
Start with list_terms and use an explicit term throughout. Tool descriptions may contain stale labels such as 'current' or 'upcoming'; rely on returned catalog data. If the requested term is absent, check it explicitly and report missing coverage when no results are available. Never substitute an older offering or treat missing data as proof that a course will not be offered. Ask for the student's degree (AB or BSE), major, graduation year, completed courses, interests, and time constraints when unknown. Use saved plans only with their permission. A TigerPath plan is not an official transcript or proof of completed prerequisites.
Respect the student's source and tool restrictions. When they say 'PI only', use only this connector's tools. Those tools may retrieve official Princeton pages and public Prince reporting server-side; this remains a PI connector call and does not require opening Chrome. Do not switch to another connector, web search, or browser/computer control to fill a data gap unless the student explicitly authorizes it. If PI cannot verify something, state the exact missing coverage and continue with the supported parts. A missing saved plan means no saved plan was returned, not that the student has completed no courses. Never claim to have used a PI tool unless you actually called it.
Start with get_course_data_status for the requested term. Use list_terms, search_courses, get_course_details and get_course_sections from the maintained TigerJunction catalog for offerings, instructors, sections and prerequisite text. Catalog freshness depends on the existing importer. Keep that maintained catalog as the primary source; a separate public-page read does not verify its freshness. list_terms describes the imported TigerJunction database only, not everything Princeton has published. Use an explicit term throughout. Tool descriptions may contain stale labels such as 'current' or 'upcoming'; rely on returned catalog data. If the requested term is absent, check it explicitly and report missing coverage when no results are available. Never substitute an older offering or treat missing data as proof that a course will not be offered. Ask for the student's degree (AB or BSE), major, graduation year, completed courses, interests, and time constraints when unknown. Use saved plans only with their permission. A TigerPath plan is not an official transcript or proof of completed prerequisites.
If the engine catalog is unavailable or lacks the requested term, get_cs_course_schedule can verify COS course-level times directly from the department. Its coverage excludes full precept/lab combinations and other departments. Do not substitute this fallback for a complete schedule. search_prince_articles adds dated campus reporting from public Prince search, not Clio; reporting is context, not authoritative requirements or section times. Keep article publication dates, fetch times, corpus coverage and unknown ingestion history separate.
Read course details, sections, degree requirements, and reviews before recommending a shortlist. Distinguish catalog facts, historical student opinions, and your own assessment. Include course links or identifiers and explain workload, prerequisite uncertainty, and tradeoffs.
verify_schedule is an upstream screening check, not proof of a globally feasible selection of lecture, precept, and lab sections. Inspect the actual section choices and times. Never claim prerequisite eligibility, degree completion, available seats, or registration based solely on a plan or this check.
Propose alternatives before changing anything. Only call plan-writing tools after the student explicitly asks you to save or edit the named plan. Saving in TigerJunction or TigerPath does not enroll the student in a course. This connector cannot access TigerHub registration, Canvas, calendars, PI chats, or the assistant's private memory.
Expand Down Expand Up @@ -96,14 +99,19 @@ export function courseUpstream(env: EngineEnv, netid: string): CourseUpstream {
};
}

export function createCourseServer(identity: CourseIdentity, upstream: CourseUpstream): Server {
const livePublicData = publicCourseData();
const statusTool = { name: "get_course_data_status", description: "Check the maintained TigerJunction catalog with both its term list and an explicit-term course probe, plus the public CS schedule fallback. Does not read personal plans. Unknown import/ingestion timestamps remain unknown. Call this first when planning a semester.", inputSchema: { type: "object" as const, properties: { term: { type: "integer", minimum: 1000, maximum: 1999 } }, required: ["term"], additionalProperties: false }, annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: true } };
const localTools = [...PUBLIC_COURSE_TOOLS, statusTool];

export function createCourseServer(identity: CourseIdentity, upstream: CourseUpstream, publicData = livePublicData): Server {
if (!/^[a-z][a-z0-9]{0,63}$/.test(identity.netid) || !identity.scope.includes(COURSE_READ)) throw new Error("Course access requires a verified identity and read permission.");
const canWrite = identity.scope.includes(PLAN_WRITE);
const server = new Server({ name: "Princeton Courses by TigerApps", version: "1.0.0" }, {
capabilities: { tools: {}, prompts: {} }, instructions: COURSE_INSTRUCTIONS,
});
server.setRequestHandler("tools/list", async () => {
// Fail explicitly rather than making an outage look like a complete catalog.
// Keep independent public sources usable during an engine outage. The
// status tool reports source availability and coverage explicitly.
const catalogs = await Promise.allSettled(sources.map(async (source) => {
let tools: Tool[];
try { tools = await upstream.list(source); }
Expand All @@ -121,16 +129,14 @@ export function createCourseServer(identity: CourseIdentity, upstream: CourseUps
});
}));
// Let every connection finish its cleanup even if one source fails early.
return { tools: catalogs.flatMap((result) => {
if (result.status === "rejected") throw result.reason;
return result.value;
}) };
return { tools: [...localTools, ...catalogs.flatMap((result) => result.status === "fulfilled" ? result.value : [])] };
});
server.setRequestHandler("tools/call", async ({ params }) => {
const rule = policy.get(params.name);
const fail = (text: string) => ({ isError: true, content: [{ type: "text" as const, text }] });
if (!identity.scope.includes(COURSE_READ) || !rule) return fail("This tool is not available through this connector.");
if (rule.write && !canWrite) return fail("Plan editing is disabled. Reconnect and explicitly allow saved-plan changes first.");
const local = localTools.some(t => t.name === params.name);
if (!identity.scope.includes(COURSE_READ) || (!rule && !local)) return fail("This tool is not available through this connector.");
if (rule?.write && !canWrite) return fail("Plan editing is disabled. Reconnect and explicitly allow saved-plan changes first.");
const args = params.arguments ?? {};
// Instructor NetIDs are public search keys. No other tool accepts a caller-
// supplied identity; personal records are scoped by our verified header.
Expand All @@ -140,6 +146,25 @@ export function createCourseServer(identity: CourseIdentity, upstream: CourseUps
return fail("User identity comes from Princeton sign-in, not tool arguments.");
}
}
if (local) {
try {
let data: unknown;
if (params.name === "get_course_data_status") {
const term = args.term;
if (typeof term !== "number" || !Number.isInteger(term) || term < 1000 || term > 1999 || ![2, 4].includes(term % 10)) return fail("Provide an explicit four-digit Fall or Spring term.");
const checkedAt = new Date().toISOString();
const checks = await Promise.allSettled([
upstream.call("junction", "list_terms", {}),
upstream.call("junction", "search_courses", { term, limit: 1 }),
publicData.csSchedule(term),
]);
const names = ["tigerjunction_imported_catalog", "tigerjunction_requested_term_probe", "princeton_cs_schedule"];
data = { term, checkedAt, latestSuccessfulDatabaseImport: null, sources: checks.map((r, i) => ({ source: names[i], status: r.status === "fulfilled" && !(r.value as { isError?: boolean }).isError ? "available" : "unavailable", ...(r.status === "fulfilled" ? { result: r.value } : {}) })), warning: "Available means the source answered, not that it covers this term or all departments. Compare returned terms and coverage. Historical ratings and saved plans do not verify current offerings. No personal records were queried." };
} else data = await publicData.call(params.name, args);
return { content: [{ type: "text" as const, text: JSON.stringify(data) }] };
} catch { return fail("The public source is unavailable or returned an unexpected format, or the arguments are invalid. Coverage is unknown, not an empty catalog. Try another source and disclose the gap."); }
}
if (!rule) return fail("Unknown tool.");
try {
return await upstream.call(rule.source, params.name, args);
} catch {
Expand Down
Loading
Loading