Material from a Public Repository
A lot of what a course teaches lives outside its slides: in-class demos, lab instructions and the files students start from, a docs site that walks through them. The slides say “the IP gets an AXI4-Lite register interface”; the demo’s source shows the five #pragma HLS INTERFACE s_axilite lines that do it. Served by the MCP, a student’s assistant can answer “where is this shown?” and “how do I start the take-home?” from your own demos and labs, and give the student a link to the exact lines.
When that material is in a public GitHub repository, the portal can serve it straight from there: it keeps its own copy of the parts you name and follows the branch. Push a fix and students see it within ten minutes, without rebuilding or uploading the course package. Only a pointer to the repository goes in the package.
This is the mirror source. Everything else – slides, PDFs, files from a private repository – is the package source, built into the package by explicit path (Packaging). The two are kept apart on purpose: patterns (“one item per folder of labs/”) are allowed only here, because everything in a public repository is public already, while a private course repository also holds exams, keys and solutions that a pattern could sweep in.
What students get
The same four material tools as for everything else. A mirrored item’s parts are its docs pages (format page), its code and other text files (text), and any PDFs (pdf, read page by page). Every result links somewhere a student can open: a docs page to its published page on your docs site, and code to the exact lines on GitHub, pinned to the commit the portal is serving so the line numbers are always right. get_material also lists the slides that cite an item, and read_material of a slide lists the items it cites.
Step 1: Point the package at the repository
Add a <code> element to llmgrader_mcp_config.xml, before <materials>:
<code repo="https://github.com/sdrangan/hwdesign" branch="main" root="pub">
<exclude>demos/project/*</exclude>
<exclude>*.wcfg</exclude>
</code>
| Part | Meaning |
|---|---|
repo | The public GitHub repository. Only https://github.com/<owner>/<repo> is accepted. |
branch | The branch to follow. Default main. |
<exclude> | A glob to leave out, relative to the repository root (demos/project/*), or a file-name glob (*.wcfg). |
root | Recommended: a <root> holding your local checkout of the repository. The build then checks the mirrored items before you upload (step 4). |
site | Optional: where the docs pages are published. By default it is read from the repository’s _config.yml (url + baseurl), as GitHub Pages uses. |
overrides | Optional: the repository’s corrections file (step 5). Default materials.xml. |
<code> names no folders itself: the portal fetches exactly the paths your mirrored items and patterns name, below.
What is never served, whatever you name: build output (hls_component/, .Xil/, logs/, *_proj/, *.runs/ and the like), bitstreams and other binaries, Tcl that Vivado generated (Generated by Vivado in its header), files over 256 KB, images in a docs tree, and symbolic links. Notebooks are served with their outputs removed. In a docs folder, only .md files are served.
Step 2: Make the items
One item per folder, with <items> in <materials>:
<materials>
<kind id="demo" description="In-class demos: code with a docs walkthrough"/>
<kind id="lab" description="Lab instructions and the files students start from, such as a prompt template"/>
<items kind="lab" source="mirror" path="labs/*" docs="docs/labs/*"/>
<items kind="demo" source="mirror" path="demos/*" docs="docs/demos/*"/>
</materials>
| Attribute | Meaning |
|---|---|
kind | The kind each item gets. |
source | Always mirror: the package has no patterns. |
path | The folders to make items from. Only the last part may be a pattern: labs/*, demos/axi_*. |
docs | Optional: the docs folders that pair with them, by name. labs/cmdresp and docs/labs/cmdresp become one item, cmdresp. |
unit | Optional: a unit for every item it makes. |
Each folder name that path or docs matches becomes one item:
- Its id is the folder’s name. If another item already has that name – a deck called
fsmbeside a demo folder calledfsm– the id gets the kind after it:fsm-demo. - Its title and description come from the docs folder’s
index.md(the front matter’stitle, then the first paragraph); without a docs folder, from a README in the folder; without one, the folder’s name. - Its parts are the docs pages, in the site’s navigation order, then the rest of the files by path.
- A folder with only docs pages, or only code, is still an item.
One explicit item when a pattern would pair the wrong folders – say a docs walkthrough that builds code from a folder with a different name:
<item id="procif-demo" kind="demo" source="mirror"
docs="docs/demos/procif" path="demos/scalar_fun"/>
A mirror item takes path and docs (a folder or a single file), and more of either with <part path=...> or <part docs=...>. A folder an explicit item serves is not also made into an item by a pattern, whichever comes first in the file.
Mirrored items need units like any other (Packaging). They can get them in the config, in the repository’s own materials.xml (step 5), or from the slides (step 3).
Step 3: Let the slides link the items
The portal reads the references your slides and docs pages already make, on every sync:
- A slide that cites an item – a path such as
demos/stream/avgfiltin its text or notes, a GitHub link, or a link to a docs page, written out or as a hyperlink – links the item to that slide, and gives it the units of the slide’s deck. - A deck named like an item’s folder gives the item the deck’s units.
- A docs page that cites another item’s code or pages makes the two related;
get_materiallists them.
The best fix is at the source. A slide that says only sdrangan.github.io/hwdesign ties nothing to anything; one that names the demo’s folder, or links to its docs page, ties the demo to that slide and its unit by itself.
Step 4: Check the items
With root= set on <code>, see every item the portal will make before you upload:
llmgrader_mcp_build --materials
It reads your local checkout (tracked files only), exactly as the portal will read its copy, and prints each item with its units and where each came from – the config, materials.xml, or the slide that cites it:
[stream] AXI4-Streaming (mirror)
unit Unit 5: FIFOs and Streaming Interfaces <- slide fifo:28 cites demos/stream/avgfilt
parts 7 page, 19 text
slides fifo 28, fifo 60
llmgrader_mcp_build --links prints only the references worth fixing:
Broken reference: docs/demos/simp_fun/poly.md:32 cites demos/basic_logic/poly_fun.sv, which does not exist
create_soln_pkg runs the same check, and stops the build on an item with no unit or a correction that matches no item. Without a local checkout (root=), the mirrored items cannot be checked on your machine; the portal lists what it finds when it syncs.
Step 5 (optional): The repository’s materials.xml
For what neither the config nor a slide says, add materials.xml at the root of the repository. It is read on every sync, after the config’s own corrections, so a change needs no package rebuild. It is checked against llmgrader_materials.xsd; a commit with a broken one is refused and the previous copy stays in service.
<materials>
<!-- Units for items no slide cites. -->
<item id="cubic" unit="Unit 3: Floating and Fixed-Point"/>
<item id="cmdresp" unit="Command-Response Mini-Project"
also="Unit 5: FIFOs and Streaming Interfaces"/>
<!-- A title and description for an item with no docs page or README. -->
<item id="sharedmem-demo" title="Shared-memory accelerator in Vitis HLS">
<description>A Vitis HLS accelerator over an AXI master port, with a C
testbench and a notebook.</description>
</item>
<!-- Slides that go with an item: a range, or a whole deck's units. -->
<item id="vector_mult"><slides deck="unroll" first="6" last="6"/></item>
<item id="datatypes"><slides deck="basic-logic"/></item>
<!-- Drop a wrong link the slides made: that deck's slides and units. -->
<item id="sharedmem-demo"><not_slides deck="sharedmem"/></item>
<!-- A different kind: a setup guide that a pattern made a demo. -->
<item id="setup" kind="lab"/>
</materials>
id is the item’s id as --materials lists it. A unit is a <name> from llmgrader_config.xml or a material unit’s id; a deck is a slides item’s id. The config takes the same <item id> corrections, which need a package rebuild to change; put them where you would rather edit them.
Step 6: Turn it on
On Render, add the environment variable:
| Variable | Value | Remarks |
|---|---|---|
LLMGRADER_MCP_CODE | 1 | Serves the mirror source. Off when unset: delete it to turn it off, and only the package’s items are served. |
LLMGRADER_CODE_SYNC_TTL_S | seconds | Optional. How old the copy may get before it is refreshed. Default 600. |
Then rebuild the package (create_soln_pkg) and upload it as usual. The first MCP request after that clones the repository in the background, which takes a few seconds; in those seconds list_materials lists the package’s items and says the rest are being fetched.
The copy lives under <storage>/courses/<course_id>/code/. It is checked against GitHub at most every ten minutes, never while a student waits: a call is always answered from the copy in hand, and if GitHub cannot be reached, the last good copy keeps being served.
PDFs in the repository are rendered on the portal when they are synced, and kept by content, so a sync that did not change a PDF does no work. That needs PyMuPDF on the portal (pip install "llmgrader[mcp-build]"); without it, a mirrored PDF is listed and its pages are reported unavailable, with a link to the file on GitHub.
Checking and updating the served commit
Admin ▸ Manage Courses has a Demo code column. For each course with a mirror source it shows the commit of the repository the course MCP is serving, and a status:
| Status | Meaning |
|---|---|
| Up to date | GitHub’s branch head is the commit being served. |
| Update available | GitHub has a newer commit. Students get it within ten minutes anyway, or now with Update now. |
| Syncing… | A sync is running. |
| Error | The last sync or the last check of GitHub failed. The last good copy is still being served. |
| Not checked | GitHub has not been asked yet. |
| Not synced yet | No copy has been made. The first MCP request makes one. |
The column shows “—” for a course whose package has no <code>, and “off” when LLMGRADER_MCP_CODE is not set. Opening Manage Courses asks GitHub for the branch head of every course with a mirror, so the column fills in by itself within a few seconds.
Click the cell to open the course’s Demo code dialog. It shows:
- the commit being served, with its date and message, and the branch head on GitHub, with how long ago it was checked. Each commit links to GitHub. When they differ, See what changed on GitHub opens the comparison, which is worth a look before updating;
- when the copy was last synced and, if the last sync failed, why, and which commit is still being served.
Check again asks GitHub for the branch head again. Update now, offered when an update is available or the last sync failed, pulls the new commit in at once rather than waiting for the next refresh. The dialog shows the sync’s stages as it goes (checking remote, fetching, building snapshot, validating), then “Now serving” and the new commit. A sync with nothing new takes a second or two; one that fetches takes a few seconds. If the new commit is refused (say its materials.xml does not validate), the dialog says so and the old commit stays served.
Nothing in the dialog waits on GitHub: checking and updating run in the background on the portal, and the dialog follows them. Grading carries on throughout.
With several gunicorn workers, the sync runs in the worker that received the click; a second worker cannot start one on top of it. The others pick up the new commit on their next MCP request. So “Now serving” is true of the copy on disk at once and of every worker after its next MCP call. Render runs one worker, so there the two are the same.
What is recorded
Calls to the material tools are recorded like every other MCP call (what is recorded): the item, its kind and the file asked about, and the commit that answered, never the search terms. Analytics ▸ MCP DB ▸ Calls per material and kind and Most-read files group them.